@miller-tech/uap 1.136.2 → 1.137.1
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/dist/.tsbuildinfo +1 -1
- package/dist/benchmarks/paired/report.d.ts +13 -0
- package/dist/benchmarks/paired/report.d.ts.map +1 -1
- package/dist/benchmarks/paired/report.js +29 -3
- package/dist/benchmarks/paired/report.js.map +1 -1
- package/dist/benchmarks/paired/types.d.ts +59 -0
- package/dist/benchmarks/paired/types.d.ts.map +1 -1
- package/dist/benchmarks/paired/types.js +60 -0
- package/dist/benchmarks/paired/types.js.map +1 -1
- package/dist/bin/cli.js +30 -0
- package/dist/bin/cli.js.map +1 -1
- package/dist/cli/deliver.d.ts.map +1 -1
- package/dist/cli/deliver.js +111 -7
- package/dist/cli/deliver.js.map +1 -1
- package/dist/cli/react.d.ts.map +1 -1
- package/dist/cli/react.js +18 -0
- package/dist/cli/react.js.map +1 -1
- package/dist/cli/self-tuning.d.ts +33 -0
- package/dist/cli/self-tuning.d.ts.map +1 -0
- package/dist/cli/self-tuning.js +139 -0
- package/dist/cli/self-tuning.js.map +1 -0
- package/dist/cli/tune-adapter.d.ts +8 -0
- package/dist/cli/tune-adapter.d.ts.map +1 -0
- package/dist/cli/tune-adapter.js +26 -0
- package/dist/cli/tune-adapter.js.map +1 -0
- package/dist/config/settings-registry.d.ts.map +1 -1
- package/dist/config/settings-registry.js +10 -0
- package/dist/config/settings-registry.js.map +1 -1
- package/dist/coordination/adaptation-signal.d.ts +19 -0
- package/dist/coordination/adaptation-signal.d.ts.map +1 -0
- package/dist/coordination/adaptation-signal.js +36 -0
- package/dist/coordination/adaptation-signal.js.map +1 -0
- package/dist/delivery/agentic-executor.d.ts +16 -1
- package/dist/delivery/agentic-executor.d.ts.map +1 -1
- package/dist/delivery/agentic-executor.js +45 -4
- package/dist/delivery/agentic-executor.js.map +1 -1
- package/dist/delivery/decompose.d.ts +27 -0
- package/dist/delivery/decompose.d.ts.map +1 -1
- package/dist/delivery/decompose.js +31 -1
- package/dist/delivery/decompose.js.map +1 -1
- package/dist/delivery/repair-escalation.d.ts +49 -0
- package/dist/delivery/repair-escalation.d.ts.map +1 -0
- package/dist/delivery/repair-escalation.js +83 -0
- package/dist/delivery/repair-escalation.js.map +1 -0
- package/dist/delivery/verifier-ladder.d.ts +47 -0
- package/dist/delivery/verifier-ladder.d.ts.map +1 -1
- package/dist/delivery/verifier-ladder.js +87 -1
- package/dist/delivery/verifier-ladder.js.map +1 -1
- package/dist/self-harness/mods.d.ts +20 -1
- package/dist/self-harness/mods.d.ts.map +1 -1
- package/dist/self-harness/mods.js +41 -0
- package/dist/self-harness/mods.js.map +1 -1
- package/dist/self-harness/orchestrator.js +4 -0
- package/dist/self-harness/orchestrator.js.map +1 -1
- package/dist/self-harness/transfer.d.ts.map +1 -1
- package/dist/self-harness/transfer.js +2 -0
- package/dist/self-harness/transfer.js.map +1 -1
- package/dist/self-tuning/flag-writer.d.ts +48 -0
- package/dist/self-tuning/flag-writer.d.ts.map +1 -0
- package/dist/self-tuning/flag-writer.js +102 -0
- package/dist/self-tuning/flag-writer.js.map +1 -0
- package/dist/self-tuning/flags.d.ts +88 -0
- package/dist/self-tuning/flags.d.ts.map +1 -0
- package/dist/self-tuning/flags.js +189 -0
- package/dist/self-tuning/flags.js.map +1 -0
- package/dist/self-tuning/index.d.ts +25 -0
- package/dist/self-tuning/index.d.ts.map +1 -0
- package/dist/self-tuning/index.js +25 -0
- package/dist/self-tuning/index.js.map +1 -0
- package/dist/self-tuning/judge.d.ts +66 -0
- package/dist/self-tuning/judge.d.ts.map +1 -0
- package/dist/self-tuning/judge.js +145 -0
- package/dist/self-tuning/judge.js.map +1 -0
- package/dist/self-tuning/llm-tuner.d.ts +83 -0
- package/dist/self-tuning/llm-tuner.d.ts.map +1 -0
- package/dist/self-tuning/llm-tuner.js +191 -0
- package/dist/self-tuning/llm-tuner.js.map +1 -0
- package/dist/self-tuning/orchestrator.d.ts +90 -0
- package/dist/self-tuning/orchestrator.d.ts.map +1 -0
- package/dist/self-tuning/orchestrator.js +126 -0
- package/dist/self-tuning/orchestrator.js.map +1 -0
- package/dist/self-tuning/paired-validator.d.ts +50 -0
- package/dist/self-tuning/paired-validator.d.ts.map +1 -0
- package/dist/self-tuning/paired-validator.js +78 -0
- package/dist/self-tuning/paired-validator.js.map +1 -0
- package/dist/self-tuning/profiles/index.d.ts +11 -0
- package/dist/self-tuning/profiles/index.d.ts.map +1 -0
- package/dist/self-tuning/profiles/index.js +15 -0
- package/dist/self-tuning/profiles/index.js.map +1 -0
- package/dist/self-tuning/profiles/opus48.d.ts +11 -0
- package/dist/self-tuning/profiles/opus48.d.ts.map +1 -0
- package/dist/self-tuning/profiles/opus48.js +27 -0
- package/dist/self-tuning/profiles/opus48.js.map +1 -0
- package/dist/self-tuning/profiles/qwen36.d.ts +11 -0
- package/dist/self-tuning/profiles/qwen36.d.ts.map +1 -0
- package/dist/self-tuning/profiles/qwen36.js +33 -0
- package/dist/self-tuning/profiles/qwen36.js.map +1 -0
- package/dist/self-tuning/quality-scorer.d.ts +90 -0
- package/dist/self-tuning/quality-scorer.d.ts.map +1 -0
- package/dist/self-tuning/quality-scorer.js +180 -0
- package/dist/self-tuning/quality-scorer.js.map +1 -0
- package/dist/self-tuning/realtime-adaptor.d.ts +78 -0
- package/dist/self-tuning/realtime-adaptor.d.ts.map +1 -0
- package/dist/self-tuning/realtime-adaptor.js +127 -0
- package/dist/self-tuning/realtime-adaptor.js.map +1 -0
- package/dist/self-tuning/run.d.ts +61 -0
- package/dist/self-tuning/run.d.ts.map +1 -0
- package/dist/self-tuning/run.js +122 -0
- package/dist/self-tuning/run.js.map +1 -0
- package/dist/self-tuning/search-reducer.d.ts +76 -0
- package/dist/self-tuning/search-reducer.d.ts.map +1 -0
- package/dist/self-tuning/search-reducer.js +349 -0
- package/dist/self-tuning/search-reducer.js.map +1 -0
- package/dist/self-tuning/tuning-profile.d.ts +72 -0
- package/dist/self-tuning/tuning-profile.d.ts.map +1 -0
- package/dist/self-tuning/tuning-profile.js +134 -0
- package/dist/self-tuning/tuning-profile.js.map +1 -0
- package/dist/telemetry/session-telemetry.d.ts +25 -0
- package/dist/telemetry/session-telemetry.d.ts.map +1 -1
- package/dist/telemetry/session-telemetry.js +32 -0
- package/dist/telemetry/session-telemetry.js.map +1 -1
- package/dist/types/config.d.ts +13 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +3 -0
- package/dist/types/config.js.map +1 -1
- package/docs/design/LLM_SELF_TUNING_ANALYSIS.md +617 -0
- package/docs/guides/SELF_TUNING.md +137 -0
- package/package.json +1 -1
- package/src/policies/enforcers/__pycache__/_common.cpython-312.pyc +0 -0
- package/tools/agents/scripts/__pycache__/toolcall_path_normalizer.cpython-312.pyc +0 -0
- package/tools/agents/scripts/anthropic_proxy.py +355 -29
- package/tools/agents/scripts/confidence_escalation.py +60 -4
- package/tools/agents/tests/test_confidence_escalation.py +77 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Self-Tuning — the closed-loop orchestrator (P2).
|
|
3
|
+
*
|
|
4
|
+
* One tuning iteration: propose → apply → validate → decide → learn.
|
|
5
|
+
*
|
|
6
|
+
* 1. PROPOSE the next config (LLM tuner, or GP-BO fallback).
|
|
7
|
+
* 2. APPLY the change set onto the current config (in-memory here; the
|
|
8
|
+
* committing loop in run.ts persists it via the flag-writer).
|
|
9
|
+
* 3. VALIDATE it with the INJECTED paired-bench validator — it runs the
|
|
10
|
+
* candidate config against the current config over the validation
|
|
11
|
+
* (and held-out) suites and returns the quality-scored comparison.
|
|
12
|
+
* 4. DECIDE accept iff the composite-QUALITY delta clears a hysteresis band,
|
|
13
|
+
* is statistically supported, and the held-out suite doesn't
|
|
14
|
+
* regress — the "conservative validation preventing regressions"
|
|
15
|
+
* rule, keyed to quality rather than raw correctness.
|
|
16
|
+
* 5. LEARN accepted configs advance the model's TuningProfile; the loop's
|
|
17
|
+
* observations feed the GP so the next proposal is better-informed.
|
|
18
|
+
*
|
|
19
|
+
* The validator is injected so the loop is unit-testable without a live model,
|
|
20
|
+
* exactly like the self-harness orchestrator.
|
|
21
|
+
*/
|
|
22
|
+
import { applyChanges } from './flags.js';
|
|
23
|
+
import { proposeTuning, } from './llm-tuner.js';
|
|
24
|
+
/**
|
|
25
|
+
* Accept a candidate iff its validation quality delta clears the hysteresis band
|
|
26
|
+
* AND is significant AND the held-out suite shows no significant quality
|
|
27
|
+
* regression. Falls back to the correctness delta when quality scores are
|
|
28
|
+
* absent (a bench run without scoring).
|
|
29
|
+
*/
|
|
30
|
+
export function decideTuning(validation, heldout, opts = {}) {
|
|
31
|
+
const minGain = opts.minQualityGain ?? 2;
|
|
32
|
+
const tol = opts.heldoutRegressionTolerance ?? 2;
|
|
33
|
+
const q = validation.quality;
|
|
34
|
+
const useQuality = !!q;
|
|
35
|
+
const vDelta = useQuality ? q.meanDelta : validation.correctness.delta.meanDelta;
|
|
36
|
+
const vSig = useQuality ? q.significant : validation.correctness.delta.significant;
|
|
37
|
+
const hDelta = useQuality
|
|
38
|
+
? heldout?.quality?.meanDelta ?? null
|
|
39
|
+
: heldout?.correctness.delta.meanDelta ?? null;
|
|
40
|
+
const scaleMinGain = useQuality ? minGain : minGain / 100; // correctness is 0..1
|
|
41
|
+
if (!(vDelta > scaleMinGain && vSig)) {
|
|
42
|
+
return {
|
|
43
|
+
verdict: 'reject',
|
|
44
|
+
reason: `no ${useQuality ? 'quality' : 'correctness'} lift past hysteresis (Δ=${vDelta.toFixed(3)}, sig=${vSig}, need>${scaleMinGain})`,
|
|
45
|
+
qualityDelta: vDelta,
|
|
46
|
+
heldoutQualityDelta: hDelta,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const heldoutRegression = useQuality
|
|
50
|
+
? heldout?.quality && heldout.quality.significant && heldout.quality.meanDelta < -tol
|
|
51
|
+
: heldout?.correctness.delta.significant && heldout.correctness.delta.meanDelta < -(tol / 100);
|
|
52
|
+
if (heldoutRegression) {
|
|
53
|
+
return {
|
|
54
|
+
verdict: 'reject',
|
|
55
|
+
reason: `held-out regression (Δ=${hDelta.toFixed(3)}, significant) despite validation lift`,
|
|
56
|
+
qualityDelta: vDelta,
|
|
57
|
+
heldoutQualityDelta: hDelta,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
verdict: 'accept',
|
|
62
|
+
reason: `validation lift Δ=${vDelta.toFixed(3)} (sig=${vSig})` +
|
|
63
|
+
(hDelta != null ? `, held-out clean (Δ=${hDelta.toFixed(3)})` : `, held-out not run`),
|
|
64
|
+
qualityDelta: vDelta,
|
|
65
|
+
heldoutQualityDelta: hDelta,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** Run ONE tuning iteration (propose → validate → decide). Never throws. */
|
|
69
|
+
export async function runTuningIteration(opts) {
|
|
70
|
+
const log = opts.log ?? (() => { });
|
|
71
|
+
const tunerOpts = { ...opts.tuner, phase: opts.phase ?? opts.tuner?.phase };
|
|
72
|
+
const proposal = await proposeTuning(opts.ctx, tunerOpts);
|
|
73
|
+
log(`proposed ${proposal.changes.length} change(s) via ${proposal.source}: ${proposal.rationale.slice(0, 120)}`);
|
|
74
|
+
if (proposal.changes.length === 0) {
|
|
75
|
+
return {
|
|
76
|
+
proposal,
|
|
77
|
+
candidateConfig: opts.ctx.currentConfig,
|
|
78
|
+
decision: null,
|
|
79
|
+
accepted: false,
|
|
80
|
+
config: opts.ctx.currentConfig,
|
|
81
|
+
observation: null,
|
|
82
|
+
outcome: 'plateau',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const candidateConfig = applyChanges(opts.ctx.currentConfig, proposal.changes);
|
|
86
|
+
let decision;
|
|
87
|
+
let candidateQuality = NaN;
|
|
88
|
+
try {
|
|
89
|
+
const res = await opts.validate(candidateConfig, opts.ctx.currentConfig);
|
|
90
|
+
candidateQuality = res.candidateQuality;
|
|
91
|
+
decision = decideTuning(res.validation, res.heldout, opts.decision);
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
95
|
+
log(` -> ERROR during validation: ${msg}`);
|
|
96
|
+
return {
|
|
97
|
+
proposal,
|
|
98
|
+
candidateConfig,
|
|
99
|
+
decision: null,
|
|
100
|
+
accepted: false,
|
|
101
|
+
config: opts.ctx.currentConfig,
|
|
102
|
+
observation: null,
|
|
103
|
+
outcome: 'error',
|
|
104
|
+
error: msg,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const accepted = decision.verdict === 'accept';
|
|
108
|
+
log(` -> ${decision.verdict.toUpperCase()}: ${decision.reason}`);
|
|
109
|
+
const observation = Number.isFinite(candidateQuality)
|
|
110
|
+
? { config: candidateConfig, quality: candidateQuality }
|
|
111
|
+
: null;
|
|
112
|
+
return {
|
|
113
|
+
proposal,
|
|
114
|
+
candidateConfig,
|
|
115
|
+
decision,
|
|
116
|
+
accepted,
|
|
117
|
+
config: accepted ? candidateConfig : opts.ctx.currentConfig,
|
|
118
|
+
observation,
|
|
119
|
+
outcome: accepted ? 'accepted' : 'rejected',
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** Convert an accepted proposal's changes into a compact one-line audit string. */
|
|
123
|
+
export function describeChanges(changes) {
|
|
124
|
+
return changes.map((c) => `${c.key}: ${c.from} -> ${c.to}`).join(', ');
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=orchestrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/self-tuning/orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAA0B,YAAY,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAIL,aAAa,GACd,MAAM,gBAAgB,CAAC;AA2CxB;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,UAAsB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,EAAE,OAAO;YAChB,KAAK,EAAE,GAAG;SACX,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC;IAC/C,GAAG,CAAC,QAAQ,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAElE,MAAM,WAAW,GAAuB,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QACvE,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,gBAAgB,EAAE;QACxD,CAAC,CAAC,IAAI,CAAC;IAET,OAAO;QACL,QAAQ;QACR,eAAe;QACf,QAAQ;QACR,QAAQ;QACR,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa;QAC3D,WAAW;QACX,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU;KAC5C,CAAC;AACJ,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,eAAe,CAAC,OAAqB;IACnD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Self-Tuning — the real paired-bench tuning validator (P2).
|
|
3
|
+
*
|
|
4
|
+
* Turns a candidate flag config into a quality-scored paired `Comparison` vs the
|
|
5
|
+
* current config, which the orchestrator's `decideTuning` accepts/rejects. For
|
|
6
|
+
* each arm it: applies the arm's config (flag-writer, incl. shell env for the
|
|
7
|
+
* child), runs the task suite, then reverts — so a trial never leaks state. Both
|
|
8
|
+
* arms use the SAME tasks + seeds, so cells pair for the paired statistics, and
|
|
9
|
+
* both record sets are quality-scored before `analyze`.
|
|
10
|
+
*
|
|
11
|
+
* `runArm` (run the suite and return records) is injected so this is unit-
|
|
12
|
+
* testable with synthetic records; the CLI wires it to the paired `runPaired`.
|
|
13
|
+
*/
|
|
14
|
+
import { type AnalyzeOptions } from '../benchmarks/paired/report.js';
|
|
15
|
+
import type { RunRecord } from '../benchmarks/paired/types.js';
|
|
16
|
+
import { type QualityScoreInput, type ScoreOptions } from './quality-scorer.js';
|
|
17
|
+
import type { JudgeClient } from './judge.js';
|
|
18
|
+
import type { TuningValidator } from './orchestrator.js';
|
|
19
|
+
export interface PairedValidatorDeps {
|
|
20
|
+
/** Project dir the flag-writer targets. */
|
|
21
|
+
cwd: string;
|
|
22
|
+
/**
|
|
23
|
+
* Run the task suite once (under whatever config is currently applied) and
|
|
24
|
+
* return the raw records. The validator handles apply/revert + labeling.
|
|
25
|
+
*/
|
|
26
|
+
runArm: (label: string) => Promise<RunRecord[]>;
|
|
27
|
+
/** Per-record evidence for the quality scorer. */
|
|
28
|
+
scoreInput: (r: RunRecord) => QualityScoreInput;
|
|
29
|
+
/** Judge client for the scorer (null → heuristic scoring). */
|
|
30
|
+
judge?: JudgeClient | null;
|
|
31
|
+
/** Extra scorer options (weights, refTokens, …). */
|
|
32
|
+
scoreOptions?: ScoreOptions;
|
|
33
|
+
/** analyze() options (iterations, seed, qualityMargin, …). */
|
|
34
|
+
analyzeOptions?: AnalyzeOptions;
|
|
35
|
+
/** Model/adapter labels for the synthesized RunnerOutput. */
|
|
36
|
+
model?: string;
|
|
37
|
+
adapter?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Called after applying a proxyEnv-affecting config so the running proxy picks
|
|
40
|
+
* up new PROXY_* values. Optional; without it, proxyEnv changes only take
|
|
41
|
+
* effect on the next proxy start (the loop still measures json/shell effects).
|
|
42
|
+
*/
|
|
43
|
+
restartProxy?: () => Promise<void>;
|
|
44
|
+
/** Stable timestamps for the RunnerOutput. */
|
|
45
|
+
now?: string;
|
|
46
|
+
log?: (msg: string) => void;
|
|
47
|
+
}
|
|
48
|
+
/** Build a `TuningValidator` that runs the real (or injected) paired bench. */
|
|
49
|
+
export declare function buildPairedTuningValidator(deps: PairedValidatorDeps): TuningValidator;
|
|
50
|
+
//# sourceMappingURL=paired-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paired-validator.d.ts","sourceRoot":"","sources":["../../src/self-tuning/paired-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAE9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,EAAa,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAA2B,MAAM,mBAAmB,CAAC;AAKlF,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAChD,kDAAkD;IAClD,UAAU,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,iBAAiB,CAAC;IAChD,8DAA8D;IAC9D,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,oDAAoD;IACpD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,8DAA8D;IAC9D,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,8CAA8C;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AA4BD,+EAA+E;AAC/E,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,mBAAmB,GAAG,eAAe,CAsCrF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Self-Tuning — the real paired-bench tuning validator (P2).
|
|
3
|
+
*
|
|
4
|
+
* Turns a candidate flag config into a quality-scored paired `Comparison` vs the
|
|
5
|
+
* current config, which the orchestrator's `decideTuning` accepts/rejects. For
|
|
6
|
+
* each arm it: applies the arm's config (flag-writer, incl. shell env for the
|
|
7
|
+
* child), runs the task suite, then reverts — so a trial never leaks state. Both
|
|
8
|
+
* arms use the SAME tasks + seeds, so cells pair for the paired statistics, and
|
|
9
|
+
* both record sets are quality-scored before `analyze`.
|
|
10
|
+
*
|
|
11
|
+
* `runArm` (run the suite and return records) is injected so this is unit-
|
|
12
|
+
* testable with synthetic records; the CLI wires it to the paired `runPaired`.
|
|
13
|
+
*/
|
|
14
|
+
import { mean } from '../benchmarks/paired/stats.js';
|
|
15
|
+
import { analyze } from '../benchmarks/paired/report.js';
|
|
16
|
+
import { applyFlagConfig } from './flag-writer.js';
|
|
17
|
+
import { scoreRuns } from './quality-scorer.js';
|
|
18
|
+
const BASELINE_LABEL = 'baseline';
|
|
19
|
+
const CANDIDATE_LABEL = 'candidate';
|
|
20
|
+
async function runUnderConfig(deps, config, label) {
|
|
21
|
+
const applied = applyFlagConfig(deps.cwd, config);
|
|
22
|
+
const savedEnv = {};
|
|
23
|
+
for (const [k, v] of Object.entries(applied.shellEnv)) {
|
|
24
|
+
savedEnv[k] = process.env[k];
|
|
25
|
+
process.env[k] = v;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
if (deps.restartProxy)
|
|
29
|
+
await deps.restartProxy();
|
|
30
|
+
const records = await deps.runArm(label);
|
|
31
|
+
// Force the arm label so both arms pair under a stable baseline/candidate id.
|
|
32
|
+
return records.map((r) => ({ ...r, condition: label }));
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
for (const [k, v] of Object.entries(savedEnv)) {
|
|
36
|
+
if (v === undefined)
|
|
37
|
+
delete process.env[k];
|
|
38
|
+
else
|
|
39
|
+
process.env[k] = v;
|
|
40
|
+
}
|
|
41
|
+
applied.rollback();
|
|
42
|
+
if (deps.restartProxy)
|
|
43
|
+
await deps.restartProxy().catch(() => undefined);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Build a `TuningValidator` that runs the real (or injected) paired bench. */
|
|
47
|
+
export function buildPairedTuningValidator(deps) {
|
|
48
|
+
const log = deps.log ?? (() => { });
|
|
49
|
+
const now = deps.now ?? '1970-01-01T00:00:00.000Z';
|
|
50
|
+
return async function validate(candidate, current) {
|
|
51
|
+
log(' validating: baseline arm');
|
|
52
|
+
const baseRaw = await runUnderConfig(deps, current, BASELINE_LABEL);
|
|
53
|
+
log(' validating: candidate arm');
|
|
54
|
+
const candRaw = await runUnderConfig(deps, candidate, CANDIDATE_LABEL);
|
|
55
|
+
const scoreOpts = { judge: deps.judge, ...deps.scoreOptions };
|
|
56
|
+
const scored = await scoreRuns([...baseRaw, ...candRaw], deps.scoreInput, scoreOpts);
|
|
57
|
+
const output = {
|
|
58
|
+
records: scored,
|
|
59
|
+
model: deps.model ?? scored[0]?.model ?? 'model',
|
|
60
|
+
adapter: deps.adapter ?? scored[0]?.adapter ?? 'adapter',
|
|
61
|
+
epochs: new Set(scored.map((r) => r.seed)).size,
|
|
62
|
+
startedAt: now,
|
|
63
|
+
finishedAt: now,
|
|
64
|
+
};
|
|
65
|
+
const report = analyze(output, { baselineLabel: BASELINE_LABEL, ...deps.analyzeOptions });
|
|
66
|
+
const validation = report.comparisons.find((c) => c.label === CANDIDATE_LABEL);
|
|
67
|
+
if (!validation) {
|
|
68
|
+
throw new Error('paired-validator: candidate arm produced no comparable cells');
|
|
69
|
+
}
|
|
70
|
+
const candComposites = scored
|
|
71
|
+
.filter((r) => r.condition === CANDIDATE_LABEL)
|
|
72
|
+
.map((r) => r.qualityScore?.composite)
|
|
73
|
+
.filter((v) => v != null);
|
|
74
|
+
const candidateQuality = candComposites.length ? mean(candComposites) : NaN;
|
|
75
|
+
return { validation, heldout: null, candidateQuality };
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=paired-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paired-validator.js","sourceRoot":"","sources":["../../src/self-tuning/paired-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAuB,MAAM,gCAAgC,CAAC;AAI9E,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,SAAS,EAA6C,MAAM,qBAAqB,CAAC;AAI3F,MAAM,cAAc,GAAG,UAAU,CAAC;AAClC,MAAM,eAAe,GAAG,WAAW,CAAC;AAgCpC,KAAK,UAAU,cAAc,CAC3B,IAAyB,EACzB,MAAkB,EAClB,KAAa;IAEb,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAuC,EAAE,CAAC;IACxD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtD,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,CAAC;QACH,IAAI,IAAI,CAA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AS,CAAC;aACrC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;QACzC,MAAM,gBAAgB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAE5E,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundled starter/reference tuning profiles, keyed by model family. Shipped as
|
|
3
|
+
* typed constants (not loose JSON) so they are guaranteed present at runtime in
|
|
4
|
+
* `dist/` regardless of asset-copy steps.
|
|
5
|
+
*/
|
|
6
|
+
import type { FlagConfig } from '../flags.js';
|
|
7
|
+
export { QWEN36_PROFILE } from './qwen36.js';
|
|
8
|
+
export { OPUS48_PROFILE } from './opus48.js';
|
|
9
|
+
/** model-family key → bundled config. Keys are matched via normalizeModel. */
|
|
10
|
+
export declare const BUNDLED_PROFILES: Record<string, FlagConfig>;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/self-tuning/profiles/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAGvD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundled starter/reference tuning profiles, keyed by model family. Shipped as
|
|
3
|
+
* typed constants (not loose JSON) so they are guaranteed present at runtime in
|
|
4
|
+
* `dist/` regardless of asset-copy steps.
|
|
5
|
+
*/
|
|
6
|
+
import { QWEN36_PROFILE } from './qwen36.js';
|
|
7
|
+
import { OPUS48_PROFILE } from './opus48.js';
|
|
8
|
+
export { QWEN36_PROFILE } from './qwen36.js';
|
|
9
|
+
export { OPUS48_PROFILE } from './opus48.js';
|
|
10
|
+
/** model-family key → bundled config. Keys are matched via normalizeModel. */
|
|
11
|
+
export const BUNDLED_PROFILES = {
|
|
12
|
+
'qwen36-a3b': QWEN36_PROFILE,
|
|
13
|
+
'opus-4.8': OPUS48_PROFILE,
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/self-tuning/profiles/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAA+B;IAC1D,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,cAAc;CAC3B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference tuning profile for Claude Opus 4.8 — the quality UPPER BOUND the
|
|
3
|
+
* small-model tuner aims toward (LLM_SELF_TUNING_ANALYSIS §Phase 3). A frontier
|
|
4
|
+
* model is self-sufficient, so most guardrail/scaffold knobs are relaxed: it
|
|
5
|
+
* needs neither fusion nor aggressive hands-free to produce Opus-level output.
|
|
6
|
+
* Useful as the "what good looks like" comparison in reports and as a sanity
|
|
7
|
+
* anchor (the tuner should never propose Opus-style relaxation for qwen).
|
|
8
|
+
*/
|
|
9
|
+
import type { FlagConfig } from '../flags.js';
|
|
10
|
+
export declare const OPUS48_PROFILE: FlagConfig;
|
|
11
|
+
//# sourceMappingURL=opus48.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opus48.d.ts","sourceRoot":"","sources":["../../../src/self-tuning/profiles/opus48.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,cAAc,EAAE,UAiB5B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference tuning profile for Claude Opus 4.8 — the quality UPPER BOUND the
|
|
3
|
+
* small-model tuner aims toward (LLM_SELF_TUNING_ANALYSIS §Phase 3). A frontier
|
|
4
|
+
* model is self-sufficient, so most guardrail/scaffold knobs are relaxed: it
|
|
5
|
+
* needs neither fusion nor aggressive hands-free to produce Opus-level output.
|
|
6
|
+
* Useful as the "what good looks like" comparison in reports and as a sanity
|
|
7
|
+
* anchor (the tuner should never propose Opus-style relaxation for qwen).
|
|
8
|
+
*/
|
|
9
|
+
export const OPUS48_PROFILE = {
|
|
10
|
+
'recipes.enabled': false,
|
|
11
|
+
'recipes.recipe': 'auto',
|
|
12
|
+
'recipes.confidenceThreshold': 0.5,
|
|
13
|
+
'recipes.fusionN': 3,
|
|
14
|
+
'recipes.allowSelfJudge': true,
|
|
15
|
+
'handsfree.enabled': false,
|
|
16
|
+
'handsfree.intensity': 'normal',
|
|
17
|
+
UAP_HANDSFREE_STAGNATION_LIMIT: 8,
|
|
18
|
+
'modelConcurrency.slots': 4,
|
|
19
|
+
'modelConcurrency.adaptive': true,
|
|
20
|
+
'memory.shortTerm.maxEntries': 50,
|
|
21
|
+
'memory.patternRag.enabled': false,
|
|
22
|
+
'delivery.runtimeVerify': false,
|
|
23
|
+
PROXY_RECON_CONVERGENCE_THRESHOLD: 60,
|
|
24
|
+
PROXY_LOOP_BREAKER: true,
|
|
25
|
+
PROXY_STUCK_BREAK: true,
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=opus48.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opus48.js","sourceRoot":"","sources":["../../../src/self-tuning/profiles/opus48.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,iBAAiB,EAAE,KAAK;IACxB,gBAAgB,EAAE,MAAM;IACxB,6BAA6B,EAAE,GAAG;IAClC,iBAAiB,EAAE,CAAC;IACpB,wBAAwB,EAAE,IAAI;IAC9B,mBAAmB,EAAE,KAAK;IAC1B,qBAAqB,EAAE,QAAQ;IAC/B,8BAA8B,EAAE,CAAC;IACjC,wBAAwB,EAAE,CAAC;IAC3B,2BAA2B,EAAE,IAAI;IACjC,6BAA6B,EAAE,EAAE;IACjC,2BAA2B,EAAE,KAAK;IAClC,wBAAwB,EAAE,KAAK;IAC/B,iCAAiC,EAAE,EAAE;IACrC,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EAAE,IAAI;CACxB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundled starter tuning profile for qwen3.6-a3b (the small executor UAP raises
|
|
3
|
+
* toward Opus). This is the design's hypothesis config (LLM_SELF_TUNING_ANALYSIS
|
|
4
|
+
* §Phase 3) — guardrail-heavy, judge-backed fusion, aggressive hands-free — used
|
|
5
|
+
* as the seed config and as the first thing the tuning loop tries to beat.
|
|
6
|
+
*
|
|
7
|
+
* Values are keyed by settings-registry key (see src/self-tuning/flags.ts).
|
|
8
|
+
*/
|
|
9
|
+
import type { FlagConfig } from '../flags.js';
|
|
10
|
+
export declare const QWEN36_PROFILE: FlagConfig;
|
|
11
|
+
//# sourceMappingURL=qwen36.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qwen36.d.ts","sourceRoot":"","sources":["../../../src/self-tuning/profiles/qwen36.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,cAAc,EAAE,UAuB5B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundled starter tuning profile for qwen3.6-a3b (the small executor UAP raises
|
|
3
|
+
* toward Opus). This is the design's hypothesis config (LLM_SELF_TUNING_ANALYSIS
|
|
4
|
+
* §Phase 3) — guardrail-heavy, judge-backed fusion, aggressive hands-free — used
|
|
5
|
+
* as the seed config and as the first thing the tuning loop tries to beat.
|
|
6
|
+
*
|
|
7
|
+
* Values are keyed by settings-registry key (see src/self-tuning/flags.ts).
|
|
8
|
+
*/
|
|
9
|
+
export const QWEN36_PROFILE = {
|
|
10
|
+
// Recipes: fusion with a strong distinct judge is the small-model lever.
|
|
11
|
+
'recipes.enabled': true,
|
|
12
|
+
'recipes.recipe': 'fusion',
|
|
13
|
+
'recipes.confidenceThreshold': 0.6,
|
|
14
|
+
'recipes.fusionN': 3,
|
|
15
|
+
'recipes.allowSelfJudge': false,
|
|
16
|
+
// Hands-free: a small model gives up early; push hard toward the ledger.
|
|
17
|
+
'handsfree.enabled': true,
|
|
18
|
+
'handsfree.intensity': 'aggressive',
|
|
19
|
+
UAP_HANDSFREE_STAGNATION_LIMIT: 6,
|
|
20
|
+
// Concurrency.
|
|
21
|
+
'modelConcurrency.slots': 4,
|
|
22
|
+
'modelConcurrency.adaptive': true,
|
|
23
|
+
// Memory: bigger short-term window + pattern RAG compensate for weak planning.
|
|
24
|
+
'memory.shortTerm.maxEntries': 80,
|
|
25
|
+
'memory.patternRag.enabled': true,
|
|
26
|
+
// Verification: prove it runs (catches "declared done but never ran").
|
|
27
|
+
'delivery.runtimeVerify': true,
|
|
28
|
+
// Proxy guardrails: converge sooner, keep loop/stuck breakers on.
|
|
29
|
+
PROXY_RECON_CONVERGENCE_THRESHOLD: 30,
|
|
30
|
+
PROXY_LOOP_BREAKER: true,
|
|
31
|
+
PROXY_STUCK_BREAK: true,
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=qwen36.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qwen36.js","sourceRoot":"","sources":["../../../src/self-tuning/profiles/qwen36.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,yEAAyE;IACzE,iBAAiB,EAAE,IAAI;IACvB,gBAAgB,EAAE,QAAQ;IAC1B,6BAA6B,EAAE,GAAG;IAClC,iBAAiB,EAAE,CAAC;IACpB,wBAAwB,EAAE,KAAK;IAC/B,yEAAyE;IACzE,mBAAmB,EAAE,IAAI;IACzB,qBAAqB,EAAE,YAAY;IACnC,8BAA8B,EAAE,CAAC;IACjC,eAAe;IACf,wBAAwB,EAAE,CAAC;IAC3B,2BAA2B,EAAE,IAAI;IACjC,+EAA+E;IAC/E,6BAA6B,EAAE,EAAE;IACjC,2BAA2B,EAAE,IAAI;IACjC,uEAAuE;IACvE,wBAAwB,EAAE,IAAI;IAC9B,kEAAkE;IAClE,iCAAiC,EAAE,EAAE;IACrC,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EAAE,IAAI;CACxB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Self-Tuning — the Quality Scorer (P0).
|
|
3
|
+
*
|
|
4
|
+
* The paired benchmark answers "did the code work" (pass/fail). Raising a small
|
|
5
|
+
* model toward Opus 4.8 is a QUALITY problem, not just a correctness one, so the
|
|
6
|
+
* tuner needs a richer signal. This module produces a `QualityScore`
|
|
7
|
+
* (correctness, quality, efficiency, toolReliability, planning + composite) per
|
|
8
|
+
* run so the tuner has something continuous to optimize.
|
|
9
|
+
*
|
|
10
|
+
* Two production paths, chosen by whether a judge model is available:
|
|
11
|
+
* - HEURISTIC (no judge): every dimension derived deterministically from the
|
|
12
|
+
* metric vector + ground-truth `correct`. Zero cost, fully reproducible,
|
|
13
|
+
* network-free — the default and the test path.
|
|
14
|
+
* - JUDGE (a stronger model configured): correctness/quality/planning graded
|
|
15
|
+
* by the judge over the task spec + agent output; efficiency/toolReliability
|
|
16
|
+
* stay deterministic (they are metric facts, not opinions). The two are
|
|
17
|
+
* fused into a 'hybrid' score.
|
|
18
|
+
*
|
|
19
|
+
* The composite weighting (correctness 40 / quality 30 / efficiency 15 /
|
|
20
|
+
* toolReliability 15) matches docs/design/LLM_SELF_TUNING_ANALYSIS.md §3.3.1.
|
|
21
|
+
*/
|
|
22
|
+
import { QualityScore, QualityDimension, MetricVector, RunRecord } from '../benchmarks/paired/types.js';
|
|
23
|
+
import type { JudgeClient } from './judge.js';
|
|
24
|
+
export type { QualityScore, QualityDimension } from '../benchmarks/paired/types.js';
|
|
25
|
+
/** The evidence a scorer needs about a single run. */
|
|
26
|
+
export interface QualityScoreInput {
|
|
27
|
+
/** The verbatim task instruction handed to the agent. */
|
|
28
|
+
taskInstruction: string;
|
|
29
|
+
/** Ground-truth correctness from the deterministic verify command. */
|
|
30
|
+
correct: boolean;
|
|
31
|
+
/** The run's metric vector (tokens/turns/toolCalls/wellFormed/…). */
|
|
32
|
+
metrics: MetricVector;
|
|
33
|
+
/** Agent output evidence for the judge: the diff, final answer, or raw log tail. */
|
|
34
|
+
output?: string;
|
|
35
|
+
/** Optional reference / rubric the judge grades against. */
|
|
36
|
+
reference?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ScoreOptions {
|
|
39
|
+
/** A resolved judge client. When omitted, the heuristic path is used. */
|
|
40
|
+
judge?: JudgeClient | null;
|
|
41
|
+
/** Composite weights override (renormalized over supplied dims). */
|
|
42
|
+
weights?: Partial<Record<QualityDimension, number>>;
|
|
43
|
+
/**
|
|
44
|
+
* Reference "good" token spend for efficiency normalization. Efficiency is
|
|
45
|
+
* refTokens / (refTokens + tokens) → 50 at refTokens, →100 as tokens→0.
|
|
46
|
+
* Default 15000 (the doc's qwen3.6 baseline tokens-per-correct-answer).
|
|
47
|
+
*/
|
|
48
|
+
refTokens?: number;
|
|
49
|
+
/** Reference "good" turn count for the planning heuristic. Default 6. */
|
|
50
|
+
refTurns?: number;
|
|
51
|
+
/** Max chars of `output` fed to the judge. Default 6000. */
|
|
52
|
+
maxOutputChars?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Deterministic efficiency (0-100). An INCORRECT run spent its tokens on a wrong
|
|
56
|
+
* answer, so efficiency is heavily penalized (tokens were wasted). A correct run
|
|
57
|
+
* scores by leanness against `refTokens`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function efficiencyScore(metrics: MetricVector, refTokens?: number): number;
|
|
60
|
+
/**
|
|
61
|
+
* Deterministic tool reliability (0-100) from well-formedness + productivity.
|
|
62
|
+
* A malformed edit is the small-model failure mode this dimension surfaces.
|
|
63
|
+
*/
|
|
64
|
+
export declare function toolReliabilityScore(metrics: MetricVector): number;
|
|
65
|
+
/** Deterministic planning heuristic (0-100): correct + few turns == coherent. */
|
|
66
|
+
export declare function planningScore(metrics: MetricVector, refTurns?: number): number;
|
|
67
|
+
/**
|
|
68
|
+
* Purely deterministic score — no network. Correctness is the ground-truth
|
|
69
|
+
* boolean projected to 0/100; quality is proxied from correctness + wellFormed;
|
|
70
|
+
* the rest come from the heuristics above. This is the default and test path.
|
|
71
|
+
*/
|
|
72
|
+
export declare function heuristicQuality(input: QualityScoreInput, opts?: ScoreOptions): QualityScore;
|
|
73
|
+
/** Build the judge prompt: grade correctness/quality/planning as 0-100 JSON. */
|
|
74
|
+
export declare function buildJudgePrompt(input: QualityScoreInput, maxOutputChars: number): string;
|
|
75
|
+
/**
|
|
76
|
+
* Score a single run. Uses the judge for correctness/quality/planning when one
|
|
77
|
+
* is supplied and reachable; efficiency/toolReliability are always the
|
|
78
|
+
* deterministic metric facts. Any judge failure degrades gracefully to the
|
|
79
|
+
* heuristic score (never throws), so a scoring pass can never wedge a bench.
|
|
80
|
+
*/
|
|
81
|
+
export declare function scoreQuality(input: QualityScoreInput, opts?: ScoreOptions): Promise<QualityScore>;
|
|
82
|
+
/**
|
|
83
|
+
* Attach quality scores to a set of run records in place-returning form. The
|
|
84
|
+
* `inputFor` mapper supplies the per-record evidence (task instruction, output).
|
|
85
|
+
* Scoring is bounded-concurrent to avoid overwhelming the judge endpoint.
|
|
86
|
+
*/
|
|
87
|
+
export declare function scoreRuns(records: RunRecord[], inputFor: (r: RunRecord) => QualityScoreInput, opts?: ScoreOptions & {
|
|
88
|
+
concurrency?: number;
|
|
89
|
+
}): Promise<RunRecord[]>;
|
|
90
|
+
//# sourceMappingURL=quality-scorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quality-scorer.d.ts","sourceRoot":"","sources":["../../src/self-tuning/quality-scorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,YAAY,EAEZ,gBAAgB,EAGhB,YAAY,EACZ,SAAS,EACV,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM9C,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEpF,sDAAsD;AACtD,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,eAAe,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;IACjB,qEAAqE;IACrE,OAAO,EAAE,YAAY,CAAC;IACtB,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,yEAAyE;IACzE,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,oEAAoE;IACpE,OAAO,CA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