@tangle-network/agent-eval 0.126.7 → 0.127.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 +44 -0
- package/README.md +2 -2
- package/dist/analyst/index.d.ts +51 -39
- package/dist/analyst/index.js +4 -4
- package/dist/belief-state/index.d.ts +34 -36
- package/dist/belief-state/index.js +2 -2
- package/dist/benchmarks/index.d.ts +30 -12
- package/dist/benchmarks/index.js +12 -10
- package/dist/builder-eval/index.js +1 -1
- package/dist/campaign/index.d.ts +432 -146
- package/dist/campaign/index.js +11 -9
- package/dist/{chunk-ARU2PZFM.js → chunk-424XHVKV.js} +43 -23
- package/dist/chunk-424XHVKV.js.map +1 -0
- package/dist/{chunk-NUKSVU3W.js → chunk-5DTSBUL2.js} +2 -2
- package/dist/{chunk-BTACVO2W.js → chunk-65QETEKG.js} +542 -258
- package/dist/chunk-65QETEKG.js.map +1 -0
- package/dist/{chunk-CGG5SLH3.js → chunk-ARCFIY7U.js} +2 -2
- package/dist/{chunk-P22LJ3Y2.js → chunk-CLELFRQG.js} +6 -4
- package/dist/chunk-CLELFRQG.js.map +1 -0
- package/dist/{chunk-LUNF2SEL.js → chunk-DJKY2TSY.js} +3 -3
- package/dist/chunk-DPUHNQLN.js +232 -0
- package/dist/chunk-DPUHNQLN.js.map +1 -0
- package/dist/{chunk-IPYXE555.js → chunk-EJGRPCO3.js} +36 -13
- package/dist/chunk-EJGRPCO3.js.map +1 -0
- package/dist/{chunk-K6IAZZ6L.js → chunk-FA3MFYNA.js} +132 -110
- package/dist/chunk-FA3MFYNA.js.map +1 -0
- package/dist/chunk-IG35YDN3.js +614 -0
- package/dist/chunk-IG35YDN3.js.map +1 -0
- package/dist/{chunk-DPZAEKA6.js → chunk-IMGJZBFG.js} +84 -56
- package/dist/chunk-IMGJZBFG.js.map +1 -0
- package/dist/{chunk-H5UD2323.js → chunk-IN455XKS.js} +53 -1
- package/dist/chunk-IN455XKS.js.map +1 -0
- package/dist/{chunk-PJQFMIOX.js → chunk-MHELPNRP.js} +31 -1
- package/dist/chunk-MHELPNRP.js.map +1 -0
- package/dist/{chunk-IILEIWGW.js → chunk-NL33OXEP.js} +41 -36
- package/dist/chunk-NL33OXEP.js.map +1 -0
- package/dist/{chunk-474LBSOX.js → chunk-OD5NQ2CS.js} +41 -16
- package/dist/chunk-OD5NQ2CS.js.map +1 -0
- package/dist/{chunk-QOTFXW5L.js → chunk-P5W7RQKK.js} +2 -2
- package/dist/{chunk-IR3KBHOY.js → chunk-P6FYH6K4.js} +39 -3
- package/dist/chunk-P6FYH6K4.js.map +1 -0
- package/dist/{chunk-J5SQWP6Y.js → chunk-PBE2LOSS.js} +18 -2
- package/dist/chunk-PBE2LOSS.js.map +1 -0
- package/dist/{chunk-E3IADPLG.js → chunk-PRB53E3J.js} +50 -224
- package/dist/chunk-PRB53E3J.js.map +1 -0
- package/dist/{chunk-X4UCIOTZ.js → chunk-S5YLIBFX.js} +2 -2
- package/dist/{chunk-7VYEGHWF.js → chunk-SZLVEKMJ.js} +41 -20
- package/dist/chunk-SZLVEKMJ.js.map +1 -0
- package/dist/{chunk-LKKT3IVV.js → chunk-TSN7JT6D.js} +6 -4
- package/dist/{chunk-LKKT3IVV.js.map → chunk-TSN7JT6D.js.map} +1 -1
- package/dist/{chunk-M7AH34KV.js → chunk-UTA2TGC4.js} +32 -16
- package/dist/chunk-UTA2TGC4.js.map +1 -0
- package/dist/{chunk-MAX3TN3C.js → chunk-UWZZKKU7.js} +7 -19
- package/dist/chunk-UWZZKKU7.js.map +1 -0
- package/dist/{chunk-ZVCHKKOP.js → chunk-WED5KLZQ.js} +39 -15
- package/dist/chunk-WED5KLZQ.js.map +1 -0
- package/dist/{chunk-OCFJACJU.js → chunk-X6VOPMLD.js} +74 -14
- package/dist/chunk-X6VOPMLD.js.map +1 -0
- package/dist/{chunk-MOXWMGPC.js → chunk-Y5CYOL42.js} +159 -70
- package/dist/chunk-Y5CYOL42.js.map +1 -0
- package/dist/{chunk-FO7HEH76.js → chunk-YJBNWCAA.js} +2 -2
- package/dist/chunk-ZPUEEM5U.js +179 -0
- package/dist/chunk-ZPUEEM5U.js.map +1 -0
- package/dist/{chunk-KE2VWPZX.js → chunk-ZUUWPZCV.js} +3 -3
- package/dist/cli.js +4 -4
- package/dist/contract/index.d.ts +421 -124
- package/dist/contract/index.js +242 -115
- package/dist/contract/index.js.map +1 -1
- package/dist/control.d.ts +34 -32
- package/dist/control.js +2 -2
- package/dist/hosted/index.d.ts +142 -41
- package/dist/hosted/index.js +23 -1
- package/dist/index.d.ts +364 -255
- package/dist/index.js +315 -226
- package/dist/index.js.map +1 -1
- package/dist/meta-eval/index.d.ts +32 -32
- package/dist/meta-eval/index.js +2 -2
- package/dist/multishot/index.d.ts +1 -0
- package/dist/openapi.json +1 -1
- package/dist/pipelines/index.js +2 -2
- package/dist/reporting.d.ts +97 -74
- package/dist/reporting.js +5 -4
- package/dist/rl.d.ts +177 -131
- package/dist/rl.js +232 -126
- package/dist/rl.js.map +1 -1
- package/dist/rollout/index.d.ts +53 -63
- package/dist/rollout/index.js +7 -5
- package/dist/{run-campaign-FFRM3RH5.js → run-campaign-3A2EBYBE.js} +4 -3
- package/dist/supervisor-run/index.d.ts +7 -15
- package/dist/supervisor-run/index.js +2 -2
- package/dist/traces.d.ts +66 -41
- package/dist/traces.js +9 -5
- package/dist/wire/index.d.ts +1 -0
- package/dist/wire/index.js +2 -2
- package/docs/concepts.md +18 -1
- package/docs/hosted-ingest-spec.md +37 -40
- package/docs/insight-report.md +57 -7
- package/docs/research-report-methodology.md +20 -21
- package/docs/rollout.md +13 -8
- package/package.json +4 -3
- package/dist/chunk-474LBSOX.js.map +0 -1
- package/dist/chunk-7VYEGHWF.js.map +0 -1
- package/dist/chunk-ARU2PZFM.js.map +0 -1
- package/dist/chunk-BTACVO2W.js.map +0 -1
- package/dist/chunk-DPZAEKA6.js.map +0 -1
- package/dist/chunk-E3IADPLG.js.map +0 -1
- package/dist/chunk-H5UD2323.js.map +0 -1
- package/dist/chunk-IILEIWGW.js.map +0 -1
- package/dist/chunk-IPYXE555.js.map +0 -1
- package/dist/chunk-IR3KBHOY.js.map +0 -1
- package/dist/chunk-J5SQWP6Y.js.map +0 -1
- package/dist/chunk-K6IAZZ6L.js.map +0 -1
- package/dist/chunk-M7AH34KV.js.map +0 -1
- package/dist/chunk-MAX3TN3C.js.map +0 -1
- package/dist/chunk-MOXWMGPC.js.map +0 -1
- package/dist/chunk-OCFJACJU.js.map +0 -1
- package/dist/chunk-P22LJ3Y2.js.map +0 -1
- package/dist/chunk-PJQFMIOX.js.map +0 -1
- package/dist/chunk-ZVCHKKOP.js.map +0 -1
- package/dist/chunk-ZZUXHH3R.js +0 -99
- package/dist/chunk-ZZUXHH3R.js.map +0 -1
- /package/dist/{chunk-NUKSVU3W.js.map → chunk-5DTSBUL2.js.map} +0 -0
- /package/dist/{chunk-CGG5SLH3.js.map → chunk-ARCFIY7U.js.map} +0 -0
- /package/dist/{chunk-LUNF2SEL.js.map → chunk-DJKY2TSY.js.map} +0 -0
- /package/dist/{chunk-QOTFXW5L.js.map → chunk-P5W7RQKK.js.map} +0 -0
- /package/dist/{chunk-X4UCIOTZ.js.map → chunk-S5YLIBFX.js.map} +0 -0
- /package/dist/{chunk-FO7HEH76.js.map → chunk-YJBNWCAA.js.map} +0 -0
- /package/dist/{chunk-KE2VWPZX.js.map → chunk-ZUUWPZCV.js.map} +0 -0
- /package/dist/{run-campaign-FFRM3RH5.js.map → run-campaign-3A2EBYBE.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
checkBehavioralCanary,
|
|
10
10
|
checkCanaries,
|
|
11
11
|
runBehavioralCanaries
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-FA3MFYNA.js";
|
|
13
13
|
import {
|
|
14
14
|
mintRolloutRows,
|
|
15
15
|
rolloutReward
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-UTA2TGC4.js";
|
|
17
17
|
import {
|
|
18
18
|
SUPERVISOR_RUN_SCHEMA,
|
|
19
19
|
analyzeSupervisorRun,
|
|
@@ -27,26 +27,25 @@ import {
|
|
|
27
27
|
showMeasured,
|
|
28
28
|
supervisorRunRolloutLines,
|
|
29
29
|
writeSupervisorRunReport
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-TSN7JT6D.js";
|
|
31
31
|
import "./chunk-VBQ3CRKH.js";
|
|
32
32
|
import {
|
|
33
33
|
toJsonl,
|
|
34
34
|
toRewardRows,
|
|
35
35
|
toSftRows
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-EJGRPCO3.js";
|
|
37
37
|
import {
|
|
38
|
-
ROLLOUT_FORMAT,
|
|
39
38
|
ROLLOUT_SCHEMA,
|
|
40
39
|
assertRolloutLine,
|
|
41
40
|
isRolloutLine,
|
|
42
41
|
isTrainableSplit,
|
|
43
42
|
validateRolloutLine
|
|
44
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-UWZZKKU7.js";
|
|
45
44
|
import {
|
|
46
45
|
BENCHMARK_SPLIT_SEED,
|
|
47
46
|
benchmarks_exports,
|
|
48
47
|
deterministicSplit
|
|
49
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-ARCFIY7U.js";
|
|
50
49
|
import {
|
|
51
50
|
DEFAULT_RULES,
|
|
52
51
|
classifyFailure,
|
|
@@ -54,7 +53,7 @@ import {
|
|
|
54
53
|
computeToolUseMetrics,
|
|
55
54
|
iqr,
|
|
56
55
|
welchsTTest
|
|
57
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-P5W7RQKK.js";
|
|
58
57
|
import {
|
|
59
58
|
buildTrajectory
|
|
60
59
|
} from "./chunk-RZTMDUO7.js";
|
|
@@ -77,17 +76,15 @@ import {
|
|
|
77
76
|
agentProfileHash,
|
|
78
77
|
agentProfileId,
|
|
79
78
|
agentProfileModelId,
|
|
80
|
-
comparePairedArms,
|
|
81
79
|
completionVerdict,
|
|
82
80
|
createLlmCorrectnessChecker,
|
|
83
81
|
createTokenRecallChecker,
|
|
84
82
|
expandProfileAxes,
|
|
85
83
|
extractProducedState,
|
|
86
84
|
harnessAxisOf,
|
|
87
|
-
pairArms,
|
|
88
85
|
parseCorrectnessResponse,
|
|
89
86
|
verifyCompletion
|
|
90
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-PRB53E3J.js";
|
|
91
88
|
import {
|
|
92
89
|
DEFAULT_MUTATION_PRIMITIVES,
|
|
93
90
|
DEFAULT_RED_TEAM_CORPUS,
|
|
@@ -121,7 +118,7 @@ import {
|
|
|
121
118
|
scoreRedTeamOutput,
|
|
122
119
|
surfaceContentHash,
|
|
123
120
|
toolNamesForRun
|
|
124
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-65QETEKG.js";
|
|
125
122
|
import {
|
|
126
123
|
BackendIntegrityError,
|
|
127
124
|
assertRealAgentReceipts,
|
|
@@ -133,7 +130,7 @@ import {
|
|
|
133
130
|
inMemoryVerdictCache,
|
|
134
131
|
summarizeAgentReceiptIntegrity,
|
|
135
132
|
summarizeBackendIntegrity
|
|
136
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-WED5KLZQ.js";
|
|
137
134
|
import {
|
|
138
135
|
DEFAULT_COMPLEXITY_WEIGHTS,
|
|
139
136
|
FindingsStore,
|
|
@@ -146,7 +143,7 @@ import {
|
|
|
146
143
|
defaultIsMaterial,
|
|
147
144
|
diffFindings,
|
|
148
145
|
runSemanticConceptJudge
|
|
149
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-ZUUWPZCV.js";
|
|
150
147
|
import {
|
|
151
148
|
AnalystRegistry,
|
|
152
149
|
DEFAULT_TRACE_ANALYST_KINDS,
|
|
@@ -163,7 +160,7 @@ import {
|
|
|
163
160
|
makeFinding,
|
|
164
161
|
renderPriorFindings,
|
|
165
162
|
renderUpstreamFindings
|
|
166
|
-
} from "./chunk-
|
|
163
|
+
} from "./chunk-DJKY2TSY.js";
|
|
167
164
|
import "./chunk-HHWE3POT.js";
|
|
168
165
|
import {
|
|
169
166
|
DEFAULT_RUN_SCORE_WEIGHTS,
|
|
@@ -192,18 +189,19 @@ import {
|
|
|
192
189
|
stopOnNoProgress,
|
|
193
190
|
stopOnRepeatedAction,
|
|
194
191
|
subjectiveEval
|
|
195
|
-
} from "./chunk-
|
|
192
|
+
} from "./chunk-OD5NQ2CS.js";
|
|
196
193
|
import {
|
|
197
194
|
assertReleaseConfidence,
|
|
198
195
|
bootstrapCi,
|
|
199
196
|
evaluateReleaseConfidence,
|
|
200
197
|
judgeReplayGate,
|
|
201
198
|
renderReleaseReport
|
|
202
|
-
} from "./chunk-
|
|
199
|
+
} from "./chunk-Y5CYOL42.js";
|
|
203
200
|
import {
|
|
204
201
|
runEvalCampaign
|
|
205
|
-
} from "./chunk-
|
|
206
|
-
import "./chunk-
|
|
202
|
+
} from "./chunk-CLELFRQG.js";
|
|
203
|
+
import "./chunk-424XHVKV.js";
|
|
204
|
+
import "./chunk-ZPUEEM5U.js";
|
|
207
205
|
import {
|
|
208
206
|
LlmCallError,
|
|
209
207
|
LlmClient,
|
|
@@ -219,7 +217,7 @@ import {
|
|
|
219
217
|
maximumChargeForLlmRequest,
|
|
220
218
|
probeLlm,
|
|
221
219
|
stripFencedJson
|
|
222
|
-
} from "./chunk-
|
|
220
|
+
} from "./chunk-PBE2LOSS.js";
|
|
223
221
|
import {
|
|
224
222
|
evaluateInterimReleaseConfidence,
|
|
225
223
|
pairedEvalueSequence
|
|
@@ -230,7 +228,12 @@ import {
|
|
|
230
228
|
paretoChart,
|
|
231
229
|
researchReport,
|
|
232
230
|
summaryTable
|
|
233
|
-
} from "./chunk-
|
|
231
|
+
} from "./chunk-IMGJZBFG.js";
|
|
232
|
+
import {
|
|
233
|
+
comparePairedArms,
|
|
234
|
+
pairArms,
|
|
235
|
+
pairRunRecords
|
|
236
|
+
} from "./chunk-DPUHNQLN.js";
|
|
234
237
|
import {
|
|
235
238
|
benjaminiHochberg,
|
|
236
239
|
bonferroni,
|
|
@@ -253,6 +256,7 @@ import {
|
|
|
253
256
|
mulberry32,
|
|
254
257
|
normalizeScores,
|
|
255
258
|
pairedBootstrap,
|
|
259
|
+
pairedCohensDz,
|
|
256
260
|
pairedMde,
|
|
257
261
|
pairedRiskDifference,
|
|
258
262
|
pairedSignTest,
|
|
@@ -262,6 +266,7 @@ import {
|
|
|
262
266
|
pearsonR,
|
|
263
267
|
positionalBias,
|
|
264
268
|
ranks,
|
|
269
|
+
requiredPairedSampleSize,
|
|
265
270
|
requiredSampleSize,
|
|
266
271
|
selfPreference,
|
|
267
272
|
spearmanR,
|
|
@@ -270,7 +275,7 @@ import {
|
|
|
270
275
|
weightedMean,
|
|
271
276
|
wilcoxonSignedRank,
|
|
272
277
|
wilson
|
|
273
|
-
} from "./chunk-
|
|
278
|
+
} from "./chunk-MHELPNRP.js";
|
|
274
279
|
import {
|
|
275
280
|
CostAccountingIncompleteError,
|
|
276
281
|
CostCallConflictError,
|
|
@@ -321,8 +326,8 @@ import {
|
|
|
321
326
|
scoreTraceInsightReadiness,
|
|
322
327
|
tokenizeDomainWords,
|
|
323
328
|
traceAnalystOnRunComplete
|
|
324
|
-
} from "./chunk-
|
|
325
|
-
import "./chunk-
|
|
329
|
+
} from "./chunk-X6VOPMLD.js";
|
|
330
|
+
import "./chunk-IN455XKS.js";
|
|
326
331
|
import {
|
|
327
332
|
extractUsage,
|
|
328
333
|
extractUsageFromResponse,
|
|
@@ -343,7 +348,7 @@ import {
|
|
|
343
348
|
TRACE_ANALYST_ACTOR_DESCRIPTION,
|
|
344
349
|
TRACE_ANALYST_ACTOR_DESCRIPTION_VERSION,
|
|
345
350
|
analyzeTraces
|
|
346
|
-
} from "./chunk-
|
|
351
|
+
} from "./chunk-5DTSBUL2.js";
|
|
347
352
|
import {
|
|
348
353
|
DEFAULT_REDACTION_RULES,
|
|
349
354
|
REDACTION_VERSION,
|
|
@@ -360,15 +365,17 @@ import {
|
|
|
360
365
|
applyToolSpanOtlpAttributes,
|
|
361
366
|
asString,
|
|
362
367
|
buildTraceAnalystTools,
|
|
368
|
+
classifyOtlpSpanRole,
|
|
363
369
|
extractOtlpAttributes,
|
|
364
370
|
firstStringAttr,
|
|
365
371
|
inferOtlpKind,
|
|
372
|
+
isOtlpModelCall,
|
|
366
373
|
projectOtlpFlatLine,
|
|
367
374
|
readOtlpStatus,
|
|
368
375
|
stringField,
|
|
369
376
|
traceAnalystFunctionGroup,
|
|
370
377
|
traceSpanKindToOpenInferenceKind
|
|
371
|
-
} from "./chunk-
|
|
378
|
+
} from "./chunk-P6FYH6K4.js";
|
|
372
379
|
import {
|
|
373
380
|
RunIntegrityError,
|
|
374
381
|
assertRunCaptured,
|
|
@@ -399,13 +406,13 @@ import {
|
|
|
399
406
|
modelHasSnapshot,
|
|
400
407
|
parseRunRecordSafe,
|
|
401
408
|
requireAgentProfileCell,
|
|
402
|
-
resolveRunCostProvenance,
|
|
403
409
|
roundTripRunRecord,
|
|
410
|
+
runTaskScore,
|
|
404
411
|
toAgentProfileJson,
|
|
405
412
|
validateAgentProfileCell,
|
|
406
413
|
validateRunRecord,
|
|
407
414
|
verifyAgentProfileCell
|
|
408
|
-
} from "./chunk-
|
|
415
|
+
} from "./chunk-NL33OXEP.js";
|
|
409
416
|
import {
|
|
410
417
|
FAILURE_CLASSES,
|
|
411
418
|
TRACE_SCHEMA_VERSION,
|
|
@@ -918,8 +925,8 @@ async function executeScenario(tc, scenario, config) {
|
|
|
918
925
|
console.log(` ${judgeName} retry ${attempt}/2 (waiting ${wait / 1e3}s)`);
|
|
919
926
|
await sleep2(wait);
|
|
920
927
|
}
|
|
921
|
-
const
|
|
922
|
-
judgeResults.push(
|
|
928
|
+
const scores = await judge(tc, judgeInput);
|
|
929
|
+
judgeResults.push(scores);
|
|
923
930
|
await sleep2(3e3);
|
|
924
931
|
lastError = void 0;
|
|
925
932
|
break;
|
|
@@ -1536,19 +1543,19 @@ function projectSelectedRows(rows, options) {
|
|
|
1536
1543
|
const arm = options.arm(original);
|
|
1537
1544
|
assertNonEmptyString("arm", arm);
|
|
1538
1545
|
if (arm !== options.baselineArm && arm !== options.treatmentArm) continue;
|
|
1539
|
-
const
|
|
1546
|
+
const pairKey = options.pairKey(original);
|
|
1540
1547
|
const clusterKey = options.clusterKey(original);
|
|
1541
1548
|
const pass = options.pass(original);
|
|
1542
1549
|
const repKey = options.repKey?.(original);
|
|
1543
|
-
assertNonEmptyString("pairKey",
|
|
1550
|
+
assertNonEmptyString("pairKey", pairKey);
|
|
1544
1551
|
assertNonEmptyString("clusterKey", clusterKey);
|
|
1545
1552
|
if (typeof pass !== "boolean") {
|
|
1546
1553
|
throw new ValidationError(
|
|
1547
|
-
`clusteredPairedBinary: pass accessor must return boolean for pairKey '${
|
|
1554
|
+
`clusteredPairedBinary: pass accessor must return boolean for pairKey '${pairKey}'`
|
|
1548
1555
|
);
|
|
1549
1556
|
}
|
|
1550
1557
|
if (repKey !== void 0) assertNonEmptyString("repKey", repKey);
|
|
1551
|
-
projected.push({ pairKey
|
|
1558
|
+
projected.push({ pairKey, clusterKey, arm, pass, repKey, original });
|
|
1552
1559
|
}
|
|
1553
1560
|
return projected;
|
|
1554
1561
|
}
|
|
@@ -2941,9 +2948,9 @@ function scorePrReviewComments(auditCase, comments, source, weights = {}) {
|
|
|
2941
2948
|
})
|
|
2942
2949
|
};
|
|
2943
2950
|
}
|
|
2944
|
-
function summarizePrReviewBenchmark(
|
|
2951
|
+
function summarizePrReviewBenchmark(scores) {
|
|
2945
2952
|
const bySource = /* @__PURE__ */ new Map();
|
|
2946
|
-
for (const score of
|
|
2953
|
+
for (const score of scores) {
|
|
2947
2954
|
bySource.set(score.source, [...bySource.get(score.source) ?? [], score]);
|
|
2948
2955
|
}
|
|
2949
2956
|
return [...bySource.entries()].map(([source, sourceScores]) => ({
|
|
@@ -3688,12 +3695,12 @@ function runJudgesTool(judges) {
|
|
|
3688
3695
|
}
|
|
3689
3696
|
const signal = ctx?.signal ?? new AbortController().signal;
|
|
3690
3697
|
const scenario = a.scenario;
|
|
3691
|
-
const
|
|
3698
|
+
const scores = {};
|
|
3692
3699
|
for (const judge of selected) {
|
|
3693
3700
|
if (scenario !== void 0 && judge.appliesTo && !judge.appliesTo(scenario)) continue;
|
|
3694
|
-
|
|
3701
|
+
scores[judge.name] = await judge.score({ artifact: a.artifact, scenario, signal });
|
|
3695
3702
|
}
|
|
3696
|
-
return { scores
|
|
3703
|
+
return { scores };
|
|
3697
3704
|
}
|
|
3698
3705
|
};
|
|
3699
3706
|
}
|
|
@@ -3807,14 +3814,14 @@ async function runHarnessExperiment(config) {
|
|
|
3807
3814
|
const score = config.score ?? ((trace) => critic.scoreTrace(trace));
|
|
3808
3815
|
const results = await mapLimit(jobs, config.parallelism ?? 1, async (request) => {
|
|
3809
3816
|
const trace = await config.adapter.run(request);
|
|
3810
|
-
const
|
|
3817
|
+
const runScore3 = await score(trace, request);
|
|
3811
3818
|
const result = {
|
|
3812
3819
|
variant: request.variant,
|
|
3813
3820
|
scenario: request.scenario,
|
|
3814
3821
|
trialIndex: request.trialIndex,
|
|
3815
3822
|
trace,
|
|
3816
|
-
score:
|
|
3817
|
-
aggregate: aggregateRunScore(
|
|
3823
|
+
score: runScore3,
|
|
3824
|
+
aggregate: aggregateRunScore(runScore3, config.weights)
|
|
3818
3825
|
};
|
|
3819
3826
|
await config.onResult?.(result);
|
|
3820
3827
|
return result;
|
|
@@ -3884,20 +3891,20 @@ async function mapLimit(items, limit, fn) {
|
|
|
3884
3891
|
function mean3(values) {
|
|
3885
3892
|
return values.length ? values.reduce((sum4, value) => sum4 + value, 0) / values.length : 0;
|
|
3886
3893
|
}
|
|
3887
|
-
function meanRunScore(
|
|
3894
|
+
function meanRunScore(scores) {
|
|
3888
3895
|
return {
|
|
3889
|
-
success: mean3(
|
|
3890
|
-
goalProgress: mean3(
|
|
3891
|
-
repoGroundedness: mean3(
|
|
3892
|
-
driftPenalty: mean3(
|
|
3893
|
-
toolUseQuality: mean3(
|
|
3894
|
-
patchQuality: mean3(
|
|
3895
|
-
testReality: mean3(
|
|
3896
|
-
finalGate: mean3(
|
|
3897
|
-
reviewerBlockers: mean3(
|
|
3898
|
-
costUsd: mean3(
|
|
3899
|
-
wallSeconds: mean3(
|
|
3900
|
-
notes:
|
|
3896
|
+
success: mean3(scores.map((s) => s.success)),
|
|
3897
|
+
goalProgress: mean3(scores.map((s) => s.goalProgress)),
|
|
3898
|
+
repoGroundedness: mean3(scores.map((s) => s.repoGroundedness)),
|
|
3899
|
+
driftPenalty: mean3(scores.map((s) => s.driftPenalty)),
|
|
3900
|
+
toolUseQuality: mean3(scores.map((s) => s.toolUseQuality)),
|
|
3901
|
+
patchQuality: mean3(scores.map((s) => s.patchQuality)),
|
|
3902
|
+
testReality: mean3(scores.map((s) => s.testReality)),
|
|
3903
|
+
finalGate: mean3(scores.map((s) => s.finalGate)),
|
|
3904
|
+
reviewerBlockers: mean3(scores.map((s) => s.reviewerBlockers)),
|
|
3905
|
+
costUsd: mean3(scores.map((s) => s.costUsd)),
|
|
3906
|
+
wallSeconds: mean3(scores.map((s) => s.wallSeconds)),
|
|
3907
|
+
notes: scores.flatMap((s) => s.notes ?? [])
|
|
3901
3908
|
};
|
|
3902
3909
|
}
|
|
3903
3910
|
|
|
@@ -4837,12 +4844,7 @@ function assertNonNegative(n, name) {
|
|
|
4837
4844
|
|
|
4838
4845
|
// src/eval-trace-store.ts
|
|
4839
4846
|
function runScore(record) {
|
|
4840
|
-
|
|
4841
|
-
if (typeof holdoutScore === "number") return holdoutScore;
|
|
4842
|
-
if (typeof searchScore === "number") return searchScore;
|
|
4843
|
-
throw new ValidationError(
|
|
4844
|
-
`EvalTraceStore: run ${record.runId} has neither holdoutScore nor searchScore`
|
|
4845
|
-
);
|
|
4847
|
+
return runTaskScore(record);
|
|
4846
4848
|
}
|
|
4847
4849
|
function matches(record, f) {
|
|
4848
4850
|
if (f.experimentId && record.experimentId !== f.experimentId) return false;
|
|
@@ -4850,8 +4852,12 @@ function matches(record, f) {
|
|
|
4850
4852
|
if (f.scenarioId && record.scenarioId !== f.scenarioId) return false;
|
|
4851
4853
|
if (f.model && record.model !== f.model) return false;
|
|
4852
4854
|
if (f.splitTag && record.splitTag !== f.splitTag) return false;
|
|
4853
|
-
if (f.minScore !== void 0
|
|
4854
|
-
|
|
4855
|
+
if (f.minScore !== void 0 || f.maxScore !== void 0) {
|
|
4856
|
+
const score = runScore(record);
|
|
4857
|
+
if (score === void 0) return false;
|
|
4858
|
+
if (f.minScore !== void 0 && score < f.minScore) return false;
|
|
4859
|
+
if (f.maxScore !== void 0 && score > f.maxScore) return false;
|
|
4860
|
+
}
|
|
4855
4861
|
if (f.rawEquals && record.outcome.raw[f.rawEquals.key] !== f.rawEquals.value) return false;
|
|
4856
4862
|
if (f.where && !f.where(record)) return false;
|
|
4857
4863
|
return true;
|
|
@@ -4941,13 +4947,17 @@ var EvalTraceStore = class {
|
|
|
4941
4947
|
candidateId: opts.candidateId,
|
|
4942
4948
|
splitTag: opts.splitTag
|
|
4943
4949
|
});
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4950
|
+
const scored = rows.flatMap((record) => {
|
|
4951
|
+
const score = runScore(record);
|
|
4952
|
+
return score === void 0 ? [] : [{ record, score }];
|
|
4953
|
+
});
|
|
4954
|
+
if (scored.length === 0) return null;
|
|
4955
|
+
let best = scored[0].record;
|
|
4956
|
+
let bestScore = scored[0].score;
|
|
4957
|
+
for (let i = 1; i < scored.length; i++) {
|
|
4958
|
+
const s = scored[i].score;
|
|
4949
4959
|
if (s > bestScore) {
|
|
4950
|
-
best =
|
|
4960
|
+
best = scored[i].record;
|
|
4951
4961
|
bestScore = s;
|
|
4952
4962
|
}
|
|
4953
4963
|
}
|
|
@@ -4973,6 +4983,7 @@ var EvalTraceStore = class {
|
|
|
4973
4983
|
const sid = r.scenarioId;
|
|
4974
4984
|
if (!sid) continue;
|
|
4975
4985
|
const s = runScore(r);
|
|
4986
|
+
if (s === void 0) continue;
|
|
4976
4987
|
const prev = m.get(sid);
|
|
4977
4988
|
if (prev === void 0 || s > prev) m.set(sid, s);
|
|
4978
4989
|
}
|
|
@@ -5050,9 +5061,9 @@ function median(sorted) {
|
|
|
5050
5061
|
const mid = Math.floor(n / 2);
|
|
5051
5062
|
return n % 2 === 0 ? (sorted[mid - 1] + sorted[mid]) / 2 : sorted[mid];
|
|
5052
5063
|
}
|
|
5053
|
-
function stddev(values,
|
|
5064
|
+
function stddev(values, mean6) {
|
|
5054
5065
|
if (values.length < 2) return 0;
|
|
5055
|
-
const variance = values.reduce((acc, v) => acc + (v -
|
|
5066
|
+
const variance = values.reduce((acc, v) => acc + (v - mean6) ** 2, 0) / values.length;
|
|
5056
5067
|
return Math.sqrt(variance);
|
|
5057
5068
|
}
|
|
5058
5069
|
function computeExperimentStats(reps, thresholds) {
|
|
@@ -5071,22 +5082,22 @@ function computeExperimentStats(reps, thresholds) {
|
|
|
5071
5082
|
stable: false
|
|
5072
5083
|
};
|
|
5073
5084
|
}
|
|
5074
|
-
const
|
|
5085
|
+
const scores = reps.map((r) => {
|
|
5075
5086
|
if (!Number.isFinite(r.score)) {
|
|
5076
5087
|
throw new ValidationError(`experiment-tracker: rep ${r.rep} has non-finite score ${r.score}`);
|
|
5077
5088
|
}
|
|
5078
5089
|
return r.score;
|
|
5079
5090
|
});
|
|
5080
|
-
const sorted = [...
|
|
5081
|
-
const
|
|
5082
|
-
const sd = stddev(
|
|
5083
|
-
const spread = iqr(
|
|
5091
|
+
const sorted = [...scores].sort((a, b) => a - b);
|
|
5092
|
+
const mean6 = scores.reduce((s, v) => s + v, 0) / n;
|
|
5093
|
+
const sd = stddev(scores, mean6);
|
|
5094
|
+
const spread = iqr(scores);
|
|
5084
5095
|
const rated = reps.filter((r) => typeof r.passed === "boolean");
|
|
5085
5096
|
const passRate = rated.length === 0 ? null : rated.filter((r) => r.passed).length / rated.length;
|
|
5086
5097
|
const stable = spread < t.iqrUnstableAbove && sd < t.stddevUnstableAbove;
|
|
5087
5098
|
return {
|
|
5088
5099
|
median: median(sorted),
|
|
5089
|
-
mean:
|
|
5100
|
+
mean: mean6,
|
|
5090
5101
|
min: sorted[0],
|
|
5091
5102
|
max: sorted[n - 1],
|
|
5092
5103
|
iqr: spread,
|
|
@@ -5275,6 +5286,7 @@ function leaderboard(records, opts) {
|
|
|
5275
5286
|
const profile = rs[0].agentProfile;
|
|
5276
5287
|
const harness = profile?.harness?.id;
|
|
5277
5288
|
const model = profile?.model;
|
|
5289
|
+
const knownCosts = rs.map((r) => r.costUsd).filter(isFiniteNumber);
|
|
5278
5290
|
return {
|
|
5279
5291
|
key,
|
|
5280
5292
|
label: harness && model ? `${harness} \xB7 ${model}` : key,
|
|
@@ -5284,7 +5296,7 @@ function leaderboard(records, opts) {
|
|
|
5284
5296
|
n: rs.length,
|
|
5285
5297
|
passRate: ci.estimate,
|
|
5286
5298
|
passRateCi95: [ci.lower, ci.upper],
|
|
5287
|
-
meanCostUsd:
|
|
5299
|
+
meanCostUsd: knownCosts.length === rs.length ? mean4(knownCosts) : null,
|
|
5288
5300
|
meanTokensIn: mean4(rs.map((r) => r.tokenUsage.input)),
|
|
5289
5301
|
meanTokensOut: mean4(rs.map((r) => r.tokenUsage.output)),
|
|
5290
5302
|
meanWallMs: mean4(rs.map((r) => r.wallMs))
|
|
@@ -5298,6 +5310,9 @@ function leaderboard(records, opts) {
|
|
|
5298
5310
|
});
|
|
5299
5311
|
return rows;
|
|
5300
5312
|
}
|
|
5313
|
+
function isFiniteNumber(value) {
|
|
5314
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
5315
|
+
}
|
|
5301
5316
|
|
|
5302
5317
|
// src/muffled-gate-scanner.ts
|
|
5303
5318
|
import { existsSync, readdirSync, readFileSync, statSync } from "fs";
|
|
@@ -5687,9 +5702,6 @@ function median2(xs) {
|
|
|
5687
5702
|
const mid = Math.floor(sorted.length / 2);
|
|
5688
5703
|
return sorted.length % 2 === 0 ? (sorted[mid - 1] + sorted[mid]) / 2 : sorted[mid];
|
|
5689
5704
|
}
|
|
5690
|
-
function runScore2(run) {
|
|
5691
|
-
return run.outcome.holdoutScore ?? run.outcome.searchScore;
|
|
5692
|
-
}
|
|
5693
5705
|
function aggregatePerDimension(runs) {
|
|
5694
5706
|
const sums = /* @__PURE__ */ new Map();
|
|
5695
5707
|
for (const run of runs) {
|
|
@@ -5722,14 +5734,14 @@ function recordRuns(runs, opts) {
|
|
|
5722
5734
|
}
|
|
5723
5735
|
const lines = [];
|
|
5724
5736
|
for (const [scenarioId, scenarioRuns] of byScenario) {
|
|
5725
|
-
const scored = scenarioRuns.map((run) => ({ run, score:
|
|
5737
|
+
const scored = scenarioRuns.map((run) => ({ run, score: runTaskScore(run) })).filter((s) => s.score !== void 0);
|
|
5726
5738
|
if (scored.length === 0) continue;
|
|
5727
|
-
const
|
|
5739
|
+
const scores = scored.map((s) => s.score);
|
|
5728
5740
|
const entry = {
|
|
5729
5741
|
commitSha: opts.commitSha,
|
|
5730
5742
|
timestamp,
|
|
5731
|
-
scores
|
|
5732
|
-
composite: median2(
|
|
5743
|
+
scores,
|
|
5744
|
+
composite: median2(scores),
|
|
5733
5745
|
runIds: scored.map((s) => s.run.runId)
|
|
5734
5746
|
};
|
|
5735
5747
|
const perDimension = aggregatePerDimension(scenarioRuns);
|
|
@@ -6317,20 +6329,20 @@ function checkRule(rule, ordered) {
|
|
|
6317
6329
|
function evaluateTraceContract(contract, spans) {
|
|
6318
6330
|
assertContract(contract);
|
|
6319
6331
|
const ordered = orderSpans(spans);
|
|
6320
|
-
const
|
|
6332
|
+
const scores = {};
|
|
6321
6333
|
const violations = [];
|
|
6322
6334
|
for (const rule of contract.rules) {
|
|
6323
6335
|
const ruleViolations = checkRule(rule, ordered);
|
|
6324
|
-
|
|
6336
|
+
scores[rule.label] = ruleViolations.length === 0 ? 1 : 0;
|
|
6325
6337
|
violations.push(...ruleViolations);
|
|
6326
6338
|
}
|
|
6327
6339
|
const ruleCount = contract.rules.length;
|
|
6328
|
-
const passCount = Object.values(
|
|
6340
|
+
const passCount = Object.values(scores).filter((s) => s === 1).length;
|
|
6329
6341
|
return {
|
|
6330
6342
|
contract: contract.name,
|
|
6331
6343
|
valid: passCount === ruleCount,
|
|
6332
6344
|
score: passCount / ruleCount,
|
|
6333
|
-
scores
|
|
6345
|
+
scores,
|
|
6334
6346
|
violations,
|
|
6335
6347
|
notes: `${passCount}/${ruleCount} rules passed`
|
|
6336
6348
|
};
|
|
@@ -6658,12 +6670,12 @@ function renderMarkdownReport(reports) {
|
|
|
6658
6670
|
async function aggregateRunMetrics(runs, store) {
|
|
6659
6671
|
if (runs.length === 0) return {};
|
|
6660
6672
|
const durations = [];
|
|
6661
|
-
const
|
|
6673
|
+
const scores = [];
|
|
6662
6674
|
const passes = [];
|
|
6663
6675
|
const costs = [];
|
|
6664
6676
|
for (const r of runs) {
|
|
6665
6677
|
if (r.endedAt) durations.push(r.endedAt - r.startedAt);
|
|
6666
|
-
if (r.outcome?.score !== void 0)
|
|
6678
|
+
if (r.outcome?.score !== void 0) scores.push(r.outcome.score);
|
|
6667
6679
|
passes.push(r.outcome?.pass === true ? 1 : 0);
|
|
6668
6680
|
const llm = await llmSpans(store, r.runId);
|
|
6669
6681
|
costs.push(aggregateLlm(llm).costUsd);
|
|
@@ -6672,7 +6684,7 @@ async function aggregateRunMetrics(runs, store) {
|
|
|
6672
6684
|
provisionMs: average(durations),
|
|
6673
6685
|
firstTokenMs: average(durations),
|
|
6674
6686
|
wallMs: average(durations),
|
|
6675
|
-
overallScore: average(
|
|
6687
|
+
overallScore: average(scores),
|
|
6676
6688
|
passRate: average(passes),
|
|
6677
6689
|
costUsd: average(costs)
|
|
6678
6690
|
};
|
|
@@ -6735,7 +6747,7 @@ async function toLangfuseEnvelope(store, runId) {
|
|
|
6735
6747
|
},
|
|
6736
6748
|
metadata: { finishReason: s.finishReason, cachedTokens: s.cachedTokens }
|
|
6737
6749
|
}));
|
|
6738
|
-
const
|
|
6750
|
+
const scores = judges.map((j) => ({
|
|
6739
6751
|
id: j.spanId,
|
|
6740
6752
|
traceId: run.runId,
|
|
6741
6753
|
observationId: j.targetSpanId,
|
|
@@ -6743,7 +6755,7 @@ async function toLangfuseEnvelope(store, runId) {
|
|
|
6743
6755
|
value: j.score,
|
|
6744
6756
|
comment: j.rationale
|
|
6745
6757
|
}));
|
|
6746
|
-
return { traceId: run.runId, generations, scores
|
|
6758
|
+
return { traceId: run.runId, generations, scores };
|
|
6747
6759
|
}
|
|
6748
6760
|
async function toPrometheusText(store) {
|
|
6749
6761
|
const runs = await store.listRuns();
|
|
@@ -6844,12 +6856,12 @@ async function paraphraseRobustness(prompt, mutators, scoreFn, options = {}) {
|
|
|
6844
6856
|
variantScores.push({ mutator: id, score, mutated });
|
|
6845
6857
|
all.push(score);
|
|
6846
6858
|
}
|
|
6847
|
-
const
|
|
6848
|
-
const variance = all.reduce((a, v) => a + (v -
|
|
6859
|
+
const mean6 = all.reduce((a, b) => a + b, 0) / all.length;
|
|
6860
|
+
const variance = all.reduce((a, v) => a + (v - mean6) ** 2, 0) / all.length;
|
|
6849
6861
|
const stdDev = Math.sqrt(variance);
|
|
6850
|
-
const ref = Math.abs(
|
|
6862
|
+
const ref = Math.abs(mean6) > 1e-9 ? Math.abs(mean6) : 1;
|
|
6851
6863
|
const robustness = Math.max(0, 1 - stdDev / ref);
|
|
6852
|
-
return { originalScore, variantScores, meanScore:
|
|
6864
|
+
return { originalScore, variantScores, meanScore: mean6, stdDev, robustness };
|
|
6853
6865
|
}
|
|
6854
6866
|
var lowercaseMutator = (p) => p.toLowerCase();
|
|
6855
6867
|
var sentenceReorderMutator = (p, seed) => {
|
|
@@ -6906,18 +6918,18 @@ async function paraphraseRobustnessScenarios(args) {
|
|
|
6906
6918
|
const deltas = {};
|
|
6907
6919
|
const paraphrasedAll = [];
|
|
6908
6920
|
for (const m of args.mutators) {
|
|
6909
|
-
const
|
|
6921
|
+
const scores = [];
|
|
6910
6922
|
for (let r = 0; r < reps; r++) {
|
|
6911
6923
|
const mutatedTurns = scenario.userTurns.map((t) => m.mutator(t));
|
|
6912
6924
|
const out = await args.runScenario({
|
|
6913
6925
|
id: scenario.id,
|
|
6914
6926
|
userTurns: mutatedTurns
|
|
6915
6927
|
});
|
|
6916
|
-
|
|
6928
|
+
scores.push(out.score);
|
|
6917
6929
|
}
|
|
6918
|
-
const
|
|
6919
|
-
deltas[m.name] =
|
|
6920
|
-
paraphrasedAll.push(...
|
|
6930
|
+
const mean6 = scores.reduce((a, b) => a + b, 0) / scores.length;
|
|
6931
|
+
deltas[m.name] = mean6 - originalScore;
|
|
6932
|
+
paraphrasedAll.push(...scores);
|
|
6921
6933
|
}
|
|
6922
6934
|
const paraphrasedMean = paraphrasedAll.length === 0 ? originalScore : paraphrasedAll.reduce((a, b) => a + b, 0) / paraphrasedAll.length;
|
|
6923
6935
|
perScenario.push({ id: scenario.id, originalScore, paraphrasedMean, deltas });
|
|
@@ -7332,10 +7344,10 @@ async function proposeSynthesisTargets(dataset, traceStore, options = {}) {
|
|
|
7332
7344
|
}
|
|
7333
7345
|
for (const s of scenarios) {
|
|
7334
7346
|
const sRuns = runs.filter((r) => r.scenarioId === s.id);
|
|
7335
|
-
const
|
|
7336
|
-
if (
|
|
7337
|
-
const
|
|
7338
|
-
const variance =
|
|
7347
|
+
const scores = sRuns.map((r) => r.outcome?.score).filter((x) => typeof x === "number");
|
|
7348
|
+
if (scores.length < 3) continue;
|
|
7349
|
+
const mean6 = scores.reduce((a, b) => a + b, 0) / scores.length;
|
|
7350
|
+
const variance = scores.reduce((a, b) => a + (b - mean6) ** 2, 0) / scores.length;
|
|
7339
7351
|
if (variance > varianceThreshold) {
|
|
7340
7352
|
targets.push({
|
|
7341
7353
|
reason: "high-variance",
|
|
@@ -7570,15 +7582,15 @@ async function runSelfPlay(proposer, scorer, targets, options = {}) {
|
|
|
7570
7582
|
const rejected = [];
|
|
7571
7583
|
const surviving = [];
|
|
7572
7584
|
for (const candidate of proposed) {
|
|
7573
|
-
const
|
|
7574
|
-
if (
|
|
7585
|
+
const scores = await scorer.scoreCandidate(candidate, targets);
|
|
7586
|
+
if (scores.length < 2) {
|
|
7575
7587
|
rejected.push({ candidate, reason: "scorer returned <2 results" });
|
|
7576
7588
|
continue;
|
|
7577
7589
|
}
|
|
7578
|
-
const values =
|
|
7590
|
+
const values = scores.map((s) => s.score);
|
|
7579
7591
|
const spread = Math.max(...values) - Math.min(...values);
|
|
7580
7592
|
const maxScore = Math.max(...values);
|
|
7581
|
-
scored.push({ candidate, scores
|
|
7593
|
+
scored.push({ candidate, scores, spread });
|
|
7582
7594
|
if (maxScore < floor) {
|
|
7583
7595
|
rejected.push({
|
|
7584
7596
|
candidate,
|
|
@@ -8406,13 +8418,32 @@ var MultiLayerVerifier = class {
|
|
|
8406
8418
|
) : null;
|
|
8407
8419
|
const layerStart = Date.now();
|
|
8408
8420
|
let result;
|
|
8421
|
+
let rejectOnAbort;
|
|
8422
|
+
const abortPromise = new Promise((_resolve, reject) => {
|
|
8423
|
+
const rejectWithReason = () => {
|
|
8424
|
+
const reason = mergedSignal.reason;
|
|
8425
|
+
reject(reason instanceof Error ? reason : new Error(String(reason ?? "aborted")));
|
|
8426
|
+
};
|
|
8427
|
+
if (mergedSignal.aborted) {
|
|
8428
|
+
rejectWithReason();
|
|
8429
|
+
return;
|
|
8430
|
+
}
|
|
8431
|
+
mergedSignal.addEventListener("abort", rejectWithReason, { once: true });
|
|
8432
|
+
rejectOnAbort = () => mergedSignal.removeEventListener("abort", rejectWithReason);
|
|
8433
|
+
});
|
|
8409
8434
|
try {
|
|
8410
|
-
result = await
|
|
8435
|
+
result = await Promise.race([
|
|
8436
|
+
Promise.resolve(
|
|
8437
|
+
layer.run({ env: opts.env, prior: { ...byName }, signal: mergedSignal })
|
|
8438
|
+
),
|
|
8439
|
+
abortPromise
|
|
8440
|
+
]);
|
|
8411
8441
|
} catch (err) {
|
|
8412
8442
|
const aborted = mergedSignal.aborted;
|
|
8413
8443
|
result = {
|
|
8414
8444
|
layer: layer.name,
|
|
8415
8445
|
status: aborted ? "timeout" : "error",
|
|
8446
|
+
errorSource: layer.errorSource ?? "execution",
|
|
8416
8447
|
durationMs: Date.now() - layerStart,
|
|
8417
8448
|
findings: [
|
|
8418
8449
|
{
|
|
@@ -8424,8 +8455,12 @@ var MultiLayerVerifier = class {
|
|
|
8424
8455
|
reason: err instanceof Error ? err.message : String(err)
|
|
8425
8456
|
};
|
|
8426
8457
|
} finally {
|
|
8458
|
+
rejectOnAbort?.();
|
|
8427
8459
|
if (layerTimer) clearTimeout(layerTimer);
|
|
8428
8460
|
}
|
|
8461
|
+
if (result.status === "error" || result.status === "timeout") {
|
|
8462
|
+
result.errorSource ??= layer.errorSource ?? "execution";
|
|
8463
|
+
}
|
|
8429
8464
|
result.findings = result.findings.map((f) => ({ ...f, layer: f.layer ?? layer.name }));
|
|
8430
8465
|
results.push(result);
|
|
8431
8466
|
byName[layer.name] = result;
|
|
@@ -8452,8 +8487,6 @@ function aggregate(layers, results, startedAt, startedAtMs) {
|
|
|
8452
8487
|
let errorCount = 0;
|
|
8453
8488
|
let scoredWeightSum = 0;
|
|
8454
8489
|
let scoredWeightedTotal = 0;
|
|
8455
|
-
let ranAnyScoredLayer = false;
|
|
8456
|
-
let anyScoredLayerFailed = false;
|
|
8457
8490
|
for (const r of results) {
|
|
8458
8491
|
const weight = weightByName.get(r.layer) ?? 1;
|
|
8459
8492
|
const failContrib = failContribByName.get(r.layer) ?? false;
|
|
@@ -8461,26 +8494,32 @@ function aggregate(layers, results, startedAt, startedAtMs) {
|
|
|
8461
8494
|
else if (r.status === "fail") failCount++;
|
|
8462
8495
|
else if (r.status === "skipped") skippedCount++;
|
|
8463
8496
|
else errorCount++;
|
|
8464
|
-
if (r
|
|
8497
|
+
if (isValidTaskMeasurement(r) && weight > 0) {
|
|
8465
8498
|
if (r.status === "pass") {
|
|
8466
|
-
ranAnyScoredLayer = true;
|
|
8467
8499
|
scoredWeightSum += weight;
|
|
8468
8500
|
scoredWeightedTotal += weight * r.score;
|
|
8469
8501
|
} else if (r.status === "fail") {
|
|
8470
8502
|
if (failContrib) {
|
|
8471
|
-
ranAnyScoredLayer = true;
|
|
8472
8503
|
scoredWeightSum += weight;
|
|
8473
8504
|
scoredWeightedTotal += weight * r.score;
|
|
8474
8505
|
}
|
|
8475
|
-
anyScoredLayerFailed = true;
|
|
8476
8506
|
}
|
|
8477
|
-
} else if (r.status === "fail") {
|
|
8478
|
-
anyScoredLayerFailed = true;
|
|
8479
8507
|
}
|
|
8480
8508
|
}
|
|
8481
8509
|
const finishedAtMs = Date.now();
|
|
8482
|
-
const allPass = ranAnyScoredLayer && !anyScoredLayerFailed && failCount === 0 && errorCount === 0;
|
|
8483
8510
|
const blendedScore = scoredWeightSum > 0 ? scoredWeightedTotal / scoredWeightSum : 0;
|
|
8511
|
+
const resultByName = new Map(results.map((result) => [result.layer, result]));
|
|
8512
|
+
const completeTaskMeasurement = scoredWeightSum > 0 && results.length === layers.length && layers.every((layer) => {
|
|
8513
|
+
const result = resultByName.get(layer.name);
|
|
8514
|
+
if (!result) return false;
|
|
8515
|
+
if ((layer.weight ?? 1) <= 0) return true;
|
|
8516
|
+
if (result.status === "pass") {
|
|
8517
|
+
return result.score === void 0 || isValidTaskMeasurement(result);
|
|
8518
|
+
}
|
|
8519
|
+
return result.status === "fail" && layer.failContributesToScore === true && isValidTaskMeasurement(result);
|
|
8520
|
+
});
|
|
8521
|
+
const taskScore = completeTaskMeasurement && scoredWeightSum > 0 && Number.isFinite(blendedScore) ? blendedScore : void 0;
|
|
8522
|
+
const allPass = taskScore !== void 0 && results.length === layers.length && failCount === 0 && skippedCount === 0 && errorCount === 0;
|
|
8484
8523
|
return {
|
|
8485
8524
|
layers: results,
|
|
8486
8525
|
passCount,
|
|
@@ -8489,13 +8528,17 @@ function aggregate(layers, results, startedAt, startedAtMs) {
|
|
|
8489
8528
|
errorCount,
|
|
8490
8529
|
allPass,
|
|
8491
8530
|
blendedScore,
|
|
8531
|
+
...taskScore === void 0 ? {} : { taskScore },
|
|
8492
8532
|
valid: allPass,
|
|
8493
|
-
score:
|
|
8533
|
+
score: taskScore ?? 0,
|
|
8494
8534
|
durationMs: finishedAtMs - startedAtMs,
|
|
8495
8535
|
startedAt,
|
|
8496
8536
|
finishedAt: new Date(finishedAtMs).toISOString()
|
|
8497
8537
|
};
|
|
8498
8538
|
}
|
|
8539
|
+
function isValidTaskMeasurement(result) {
|
|
8540
|
+
return (result.status === "pass" || result.status === "fail") && typeof result.score === "number" && Number.isFinite(result.score) && result.score >= 0 && result.score <= 1;
|
|
8541
|
+
}
|
|
8499
8542
|
function mergeSignals(a, b) {
|
|
8500
8543
|
if (a.aborted) return a;
|
|
8501
8544
|
if (b.aborted) return b;
|
|
@@ -8797,15 +8840,15 @@ function scoreReferenceReplay(scenarios, options = {}) {
|
|
|
8797
8840
|
const threshold = options.matchThreshold ?? DEFAULT_MATCH_THRESHOLD;
|
|
8798
8841
|
const matchStrategy = options.matchStrategy ?? "reference-order";
|
|
8799
8842
|
const allowedSplits = new Set(options.splits ?? ALL_SPLITS);
|
|
8800
|
-
const
|
|
8843
|
+
const scores = scenarios.filter((scenario) => {
|
|
8801
8844
|
const split = scenario.split ?? "train";
|
|
8802
8845
|
if (split === "holdout" && !options.includeHoldout) return false;
|
|
8803
8846
|
return allowedSplits.has(split);
|
|
8804
8847
|
}).map((scenario) => scoreScenario(scenario, matcher, threshold, matchStrategy));
|
|
8805
8848
|
return {
|
|
8806
|
-
scenarios:
|
|
8807
|
-
aggregate: aggregateScenarioScores(
|
|
8808
|
-
bySplit: aggregateBySplit(
|
|
8849
|
+
scenarios: scores,
|
|
8850
|
+
aggregate: aggregateScenarioScores(scores),
|
|
8851
|
+
bySplit: aggregateBySplit(scores)
|
|
8809
8852
|
};
|
|
8810
8853
|
}
|
|
8811
8854
|
function compareReferenceReplay(baseline, candidate) {
|
|
@@ -9028,20 +9071,20 @@ function buildScenarioScore(scenario, matches2, falsePositives) {
|
|
|
9028
9071
|
matches: matches2
|
|
9029
9072
|
};
|
|
9030
9073
|
}
|
|
9031
|
-
function aggregateBySplit(
|
|
9074
|
+
function aggregateBySplit(scores) {
|
|
9032
9075
|
const out = {};
|
|
9033
9076
|
for (const split of ALL_SPLITS) {
|
|
9034
|
-
const scoped =
|
|
9077
|
+
const scoped = scores.filter((score) => score.split === split);
|
|
9035
9078
|
if (scoped.length > 0) out[split] = aggregateScenarioScores(scoped);
|
|
9036
9079
|
}
|
|
9037
9080
|
return out;
|
|
9038
9081
|
}
|
|
9039
|
-
function aggregateScenarioScores(
|
|
9040
|
-
const matched = sum2(
|
|
9041
|
-
const total = sum2(
|
|
9042
|
-
const falsePositives = sum2(
|
|
9043
|
-
const matchedWeight = sum2(
|
|
9044
|
-
const totalWeight = sum2(
|
|
9082
|
+
function aggregateScenarioScores(scores) {
|
|
9083
|
+
const matched = sum2(scores.map((score) => score.matched));
|
|
9084
|
+
const total = sum2(scores.map((score) => score.total));
|
|
9085
|
+
const falsePositives = sum2(scores.map((score) => score.falsePositives));
|
|
9086
|
+
const matchedWeight = sum2(scores.map((score) => score.matchedWeight));
|
|
9087
|
+
const totalWeight = sum2(scores.map((score) => score.totalWeight));
|
|
9045
9088
|
const precision2 = ratio(matched, matched + falsePositives);
|
|
9046
9089
|
const recall = ratio(matched, total);
|
|
9047
9090
|
return {
|
|
@@ -9305,18 +9348,16 @@ function createDefaultReviewer(options) {
|
|
|
9305
9348
|
|
|
9306
9349
|
// src/description-length-gate.ts
|
|
9307
9350
|
import { gzipSync } from "zlib";
|
|
9308
|
-
function
|
|
9309
|
-
|
|
9310
|
-
const s = o.holdoutScore ?? o.searchScore ?? o.raw?.score;
|
|
9311
|
-
return typeof s === "number" && Number.isFinite(s) ? s : void 0;
|
|
9351
|
+
function runScore2(run) {
|
|
9352
|
+
return runTaskScore(run);
|
|
9312
9353
|
}
|
|
9313
9354
|
function taskKey(run) {
|
|
9314
|
-
return run.scenarioId
|
|
9355
|
+
return run.scenarioId;
|
|
9315
9356
|
}
|
|
9316
9357
|
function perTaskMeanScore(runs) {
|
|
9317
9358
|
const acc = /* @__PURE__ */ new Map();
|
|
9318
9359
|
for (const run of runs) {
|
|
9319
|
-
const s =
|
|
9360
|
+
const s = runScore2(run);
|
|
9320
9361
|
if (s === void 0) continue;
|
|
9321
9362
|
const key = taskKey(run);
|
|
9322
9363
|
const cur = acc.get(key) ?? { sum: 0, n: 0 };
|
|
@@ -9564,55 +9605,82 @@ var HeldOutGate = class {
|
|
|
9564
9605
|
}
|
|
9565
9606
|
this.costPerTaskCeiling = config.costPerTaskCeiling;
|
|
9566
9607
|
}
|
|
9567
|
-
/** Decide whether `candidate` should replace `baseline`.
|
|
9568
|
-
* is by (experimentId, seed)
|
|
9569
|
-
*
|
|
9570
|
-
* a holdout score on both sides are dropped. */
|
|
9608
|
+
/** Decide whether `candidate` should replace `baseline`.
|
|
9609
|
+
* Pairing is by `(experimentId, scenarioId, seed)`.
|
|
9610
|
+
* Missing or duplicate identities throw instead of comparing by position. */
|
|
9571
9611
|
evaluate(candidate, baseline) {
|
|
9572
9612
|
const candidateId = inferCandidateId2(candidate, this.baselineKey);
|
|
9573
9613
|
const baselineId = this.baselineKey;
|
|
9574
|
-
|
|
9575
|
-
const
|
|
9576
|
-
const
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
}
|
|
9614
|
+
assertScenarioIdentities([...candidate, ...baseline]);
|
|
9615
|
+
const candidateSearch = scoredRuns(candidate, "searchScore", "search");
|
|
9616
|
+
const baselineSearch = scoredRuns(baseline, "searchScore", "search");
|
|
9617
|
+
const candidateHoldout = scoredRuns(candidate, "holdoutScore", "holdout");
|
|
9618
|
+
const baselineHoldout = scoredRuns(baseline, "holdoutScore", "holdout");
|
|
9619
|
+
const searchPairing = pairRunRecords(baselineSearch, candidateSearch);
|
|
9620
|
+
const holdoutPairing = pairRunRecords(baselineHoldout, candidateHoldout);
|
|
9621
|
+
const beforeSearch = searchPairing.pairs.map((pair) => pair.baseline.outcome.searchScore);
|
|
9622
|
+
const afterSearch = searchPairing.pairs.map((pair) => pair.treatment.outcome.searchScore);
|
|
9623
|
+
const beforeHoldout = holdoutPairing.pairs.map((pair) => pair.baseline.outcome.holdoutScore);
|
|
9624
|
+
const afterHoldout = holdoutPairing.pairs.map((pair) => pair.treatment.outcome.holdoutScore);
|
|
9586
9625
|
const productiveRuns = beforeHoldout.length;
|
|
9587
|
-
const candidateSearchMean =
|
|
9588
|
-
const candidateHoldoutMean =
|
|
9589
|
-
const baselineSearchMean =
|
|
9590
|
-
const baselineHoldoutMean =
|
|
9591
|
-
const overfitGap =
|
|
9592
|
-
const baselineOverfitGap =
|
|
9593
|
-
const medianCandidateCost =
|
|
9594
|
-
const medianBaselineCost =
|
|
9626
|
+
const candidateSearchMean = meanOrNull(afterSearch);
|
|
9627
|
+
const candidateHoldoutMean = meanOrNull(afterHoldout);
|
|
9628
|
+
const baselineSearchMean = meanOrNull(beforeSearch);
|
|
9629
|
+
const baselineHoldoutMean = meanOrNull(beforeHoldout);
|
|
9630
|
+
const overfitGap = diffOrNull(candidateSearchMean, candidateHoldoutMean);
|
|
9631
|
+
const baselineOverfitGap = diffOrNull(baselineSearchMean, baselineHoldoutMean);
|
|
9632
|
+
const medianCandidateCost = completeCostMedian(candidate);
|
|
9633
|
+
const medianBaselineCost = completeCostMedian(baseline);
|
|
9634
|
+
const commonEvidence = {
|
|
9635
|
+
productiveRuns,
|
|
9636
|
+
unpairedCandidateRuns: holdoutPairing.unpairedTreatment.length,
|
|
9637
|
+
unpairedBaselineRuns: holdoutPairing.unpairedBaseline.length,
|
|
9638
|
+
searchScore: candidateSearchMean,
|
|
9639
|
+
holdoutScore: candidateHoldoutMean,
|
|
9640
|
+
overfitGap,
|
|
9641
|
+
baselineOverfitGap,
|
|
9642
|
+
medianCandidateCost,
|
|
9643
|
+
medianBaselineCost
|
|
9644
|
+
};
|
|
9645
|
+
const missingSplitScores = [
|
|
9646
|
+
candidateSearch.length === 0 ? "candidate search" : null,
|
|
9647
|
+
candidateHoldout.length === 0 ? "candidate holdout" : null,
|
|
9648
|
+
baselineSearch.length === 0 ? "baseline search" : null,
|
|
9649
|
+
baselineHoldout.length === 0 ? "baseline holdout" : null
|
|
9650
|
+
].filter((label) => label !== null);
|
|
9651
|
+
if (missingSplitScores.length > 0) {
|
|
9652
|
+
return {
|
|
9653
|
+
promote: false,
|
|
9654
|
+
candidateId,
|
|
9655
|
+
baselineId,
|
|
9656
|
+
evidence: {
|
|
9657
|
+
...commonEvidence,
|
|
9658
|
+
medianPairedDelta: productiveRuns > 0 ? medianDelta(beforeHoldout, afterHoldout) : null,
|
|
9659
|
+
pairedCI: null,
|
|
9660
|
+
pairedPValue: null
|
|
9661
|
+
},
|
|
9662
|
+
reason: `missing_split_scores: ${missingSplitScores.join(", ")} score evidence is absent`,
|
|
9663
|
+
rejectionCode: "missing_split_scores"
|
|
9664
|
+
};
|
|
9665
|
+
}
|
|
9595
9666
|
if (productiveRuns < this.minProductiveRuns) {
|
|
9596
9667
|
return {
|
|
9597
9668
|
promote: false,
|
|
9598
9669
|
candidateId,
|
|
9599
9670
|
baselineId,
|
|
9600
9671
|
evidence: {
|
|
9601
|
-
|
|
9602
|
-
medianPairedDelta: productiveRuns > 0 ? medianDelta(beforeHoldout, afterHoldout) :
|
|
9603
|
-
pairedCI:
|
|
9604
|
-
pairedPValue:
|
|
9605
|
-
searchScore: candidateSearchMean,
|
|
9606
|
-
holdoutScore: candidateHoldoutMean,
|
|
9607
|
-
overfitGap,
|
|
9608
|
-
baselineOverfitGap,
|
|
9609
|
-
medianCandidateCost,
|
|
9610
|
-
medianBaselineCost
|
|
9672
|
+
...commonEvidence,
|
|
9673
|
+
medianPairedDelta: productiveRuns > 0 ? medianDelta(beforeHoldout, afterHoldout) : null,
|
|
9674
|
+
pairedCI: null,
|
|
9675
|
+
pairedPValue: null
|
|
9611
9676
|
},
|
|
9612
9677
|
reason: `few_runs: ${productiveRuns} paired holdout observation(s) < min ${this.minProductiveRuns}`,
|
|
9613
9678
|
rejectionCode: "few_runs"
|
|
9614
9679
|
};
|
|
9615
9680
|
}
|
|
9681
|
+
if (overfitGap === null || baselineOverfitGap === null) {
|
|
9682
|
+
throw new Error("HeldOutGate: complete split scores did not produce overfit gaps");
|
|
9683
|
+
}
|
|
9616
9684
|
const ci = pairedBootstrap(beforeHoldout, afterHoldout, {
|
|
9617
9685
|
confidence: this.confidence,
|
|
9618
9686
|
resamples: this.resamples,
|
|
@@ -9621,16 +9689,10 @@ var HeldOutGate = class {
|
|
|
9621
9689
|
});
|
|
9622
9690
|
const wilcoxon = wilcoxonSignedRank(beforeHoldout, afterHoldout);
|
|
9623
9691
|
const evidence = {
|
|
9624
|
-
|
|
9692
|
+
...commonEvidence,
|
|
9625
9693
|
medianPairedDelta: ci.median,
|
|
9626
9694
|
pairedCI: { low: ci.low, high: ci.high },
|
|
9627
|
-
pairedPValue: wilcoxon.p
|
|
9628
|
-
searchScore: candidateSearchMean,
|
|
9629
|
-
holdoutScore: candidateHoldoutMean,
|
|
9630
|
-
overfitGap,
|
|
9631
|
-
baselineOverfitGap,
|
|
9632
|
-
medianCandidateCost,
|
|
9633
|
-
medianBaselineCost
|
|
9695
|
+
pairedPValue: wilcoxon.p
|
|
9634
9696
|
};
|
|
9635
9697
|
if (!(ci.low > this.pairedDeltaThreshold)) {
|
|
9636
9698
|
return {
|
|
@@ -9642,7 +9704,7 @@ var HeldOutGate = class {
|
|
|
9642
9704
|
rejectionCode: "negative_delta"
|
|
9643
9705
|
};
|
|
9644
9706
|
}
|
|
9645
|
-
if (
|
|
9707
|
+
if (overfitGap > baselineOverfitGap + this.overfitGapThreshold) {
|
|
9646
9708
|
return {
|
|
9647
9709
|
promote: false,
|
|
9648
9710
|
candidateId,
|
|
@@ -9652,7 +9714,17 @@ var HeldOutGate = class {
|
|
|
9652
9714
|
rejectionCode: "overfit_gap"
|
|
9653
9715
|
};
|
|
9654
9716
|
}
|
|
9655
|
-
if (this.costPerTaskCeiling !== void 0 &&
|
|
9717
|
+
if (this.costPerTaskCeiling !== void 0 && medianCandidateCost === null) {
|
|
9718
|
+
return {
|
|
9719
|
+
promote: false,
|
|
9720
|
+
candidateId,
|
|
9721
|
+
baselineId,
|
|
9722
|
+
evidence,
|
|
9723
|
+
reason: "missing_cost: candidate cost evidence is incomplete",
|
|
9724
|
+
rejectionCode: "missing_cost"
|
|
9725
|
+
};
|
|
9726
|
+
}
|
|
9727
|
+
if (this.costPerTaskCeiling !== void 0 && medianCandidateCost !== null && medianCandidateCost > this.costPerTaskCeiling) {
|
|
9656
9728
|
return {
|
|
9657
9729
|
promote: false,
|
|
9658
9730
|
candidateId,
|
|
@@ -9678,49 +9750,50 @@ function inferCandidateId2(candidate, baselineKey) {
|
|
|
9678
9750
|
}
|
|
9679
9751
|
return candidate[0]?.candidateId ?? "(unknown candidate)";
|
|
9680
9752
|
}
|
|
9681
|
-
function
|
|
9682
|
-
const
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
out.set(pairKey(r), r.outcome.holdoutScore);
|
|
9753
|
+
function assertScenarioIdentities(runs) {
|
|
9754
|
+
for (const run of runs) {
|
|
9755
|
+
if (typeof run.scenarioId !== "string" || run.scenarioId.trim() === "") {
|
|
9756
|
+
throw new Error(`HeldOutGate: run ${run.runId} is missing scenarioId`);
|
|
9757
|
+
}
|
|
9687
9758
|
}
|
|
9688
|
-
return out;
|
|
9689
9759
|
}
|
|
9690
|
-
function
|
|
9691
|
-
return
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
const out = [];
|
|
9695
|
-
for (const r of runs) {
|
|
9696
|
-
if (r.splitTag !== splitFilter) continue;
|
|
9697
|
-
const v = r.outcome[field];
|
|
9698
|
-
if (typeof v === "number" && Number.isFinite(v)) out.push(v);
|
|
9699
|
-
}
|
|
9700
|
-
return out;
|
|
9760
|
+
function scoredRuns(runs, field, splitFilter) {
|
|
9761
|
+
return runs.filter(
|
|
9762
|
+
(run) => run.splitTag === splitFilter && typeof run.outcome[field] === "number" && Number.isFinite(run.outcome[field])
|
|
9763
|
+
);
|
|
9701
9764
|
}
|
|
9702
|
-
function
|
|
9703
|
-
if (xs.length === 0) return
|
|
9765
|
+
function meanOrNull(xs) {
|
|
9766
|
+
if (xs.length === 0) return null;
|
|
9704
9767
|
return xs.reduce((s, x) => s + x, 0) / xs.length;
|
|
9705
9768
|
}
|
|
9706
|
-
function
|
|
9707
|
-
if (
|
|
9769
|
+
function diffOrNull(a, b) {
|
|
9770
|
+
if (a === null || b === null) return null;
|
|
9708
9771
|
return a - b;
|
|
9709
9772
|
}
|
|
9710
9773
|
function medianDelta(before, after) {
|
|
9711
9774
|
const ds = before.map((b, i) => after[i] - b).sort((x, y) => x - y);
|
|
9712
|
-
if (ds.length === 0)
|
|
9775
|
+
if (ds.length === 0) throw new Error("HeldOutGate: median delta requires at least one pair");
|
|
9713
9776
|
const mid = Math.floor(ds.length / 2);
|
|
9714
9777
|
return ds.length % 2 === 0 ? (ds[mid - 1] + ds[mid]) / 2 : ds[mid];
|
|
9715
9778
|
}
|
|
9716
9779
|
function medianFinite(xs) {
|
|
9717
9780
|
const ys = xs.filter((x) => Number.isFinite(x)).sort((x, y) => x - y);
|
|
9718
|
-
if (ys.length === 0) return
|
|
9781
|
+
if (ys.length === 0) return null;
|
|
9719
9782
|
const mid = Math.floor(ys.length / 2);
|
|
9720
9783
|
return ys.length % 2 === 0 ? (ys[mid - 1] + ys[mid]) / 2 : ys[mid];
|
|
9721
9784
|
}
|
|
9785
|
+
function completeCostMedian(runs) {
|
|
9786
|
+
if (runs.length === 0) return null;
|
|
9787
|
+
const costs = [];
|
|
9788
|
+
for (const run of runs) {
|
|
9789
|
+
const provenance = run.costProvenance;
|
|
9790
|
+
if (provenance.kind === "uncaptured") return null;
|
|
9791
|
+
costs.push(provenance.usd);
|
|
9792
|
+
}
|
|
9793
|
+
return medianFinite(costs);
|
|
9794
|
+
}
|
|
9722
9795
|
function fmt(x) {
|
|
9723
|
-
if (
|
|
9796
|
+
if (x === null) return "n/a";
|
|
9724
9797
|
return x.toFixed(4);
|
|
9725
9798
|
}
|
|
9726
9799
|
|
|
@@ -9739,9 +9812,9 @@ function passOrthogonality(input) {
|
|
|
9739
9812
|
sims.push(cosineSimilarity(vectors[i], vectors[j]));
|
|
9740
9813
|
}
|
|
9741
9814
|
}
|
|
9742
|
-
const
|
|
9815
|
+
const mean6 = sims.length === 0 ? 0 : sims.reduce((a, b) => a + b, 0) / sims.length;
|
|
9743
9816
|
return {
|
|
9744
|
-
orthogonality: Math.max(0, Math.min(1, 1 -
|
|
9817
|
+
orthogonality: Math.max(0, Math.min(1, 1 - mean6)),
|
|
9745
9818
|
passCount: passes.length,
|
|
9746
9819
|
similarities: sims
|
|
9747
9820
|
};
|
|
@@ -10255,17 +10328,17 @@ function traceJudge(judge, judgeName, opts) {
|
|
|
10255
10328
|
}
|
|
10256
10329
|
});
|
|
10257
10330
|
try {
|
|
10258
|
-
const
|
|
10259
|
-
const composite =
|
|
10331
|
+
const scores = await judge(tc, input);
|
|
10332
|
+
const composite = scores.length > 0 ? scores.reduce((sum4, s) => sum4 + s.score, 0) / scores.length : 0;
|
|
10260
10333
|
await span.end({
|
|
10261
10334
|
attributes: {
|
|
10262
10335
|
"judge.name": judgeName,
|
|
10263
10336
|
"judge.composite_score": composite,
|
|
10264
|
-
"judge.dimension_count":
|
|
10337
|
+
"judge.dimension_count": scores.length,
|
|
10265
10338
|
"eval.phase": "judge"
|
|
10266
10339
|
}
|
|
10267
10340
|
});
|
|
10268
|
-
return
|
|
10341
|
+
return scores;
|
|
10269
10342
|
} catch (err) {
|
|
10270
10343
|
await span.fail(err instanceof Error ? err : String(err));
|
|
10271
10344
|
throw err;
|
|
@@ -10294,8 +10367,8 @@ function traceJudgeEnsemble(judges, judgeNames, opts) {
|
|
|
10294
10367
|
parentSpanId: ensembleSpan.span.spanId
|
|
10295
10368
|
});
|
|
10296
10369
|
try {
|
|
10297
|
-
const
|
|
10298
|
-
allScores.push(...
|
|
10370
|
+
const scores = await tracedFn(tc, input);
|
|
10371
|
+
allScores.push(...scores);
|
|
10299
10372
|
} catch (err) {
|
|
10300
10373
|
if (!(err instanceof JudgeParseError)) throw err;
|
|
10301
10374
|
failedJudges++;
|
|
@@ -10556,10 +10629,16 @@ function splitOf(record, opts) {
|
|
|
10556
10629
|
return "practice";
|
|
10557
10630
|
}
|
|
10558
10631
|
function scoreOf(record) {
|
|
10559
|
-
const score = record
|
|
10560
|
-
if (
|
|
10561
|
-
|
|
10562
|
-
|
|
10632
|
+
const score = runTaskScore(record);
|
|
10633
|
+
if (score !== void 0) return clamp014(score);
|
|
10634
|
+
if ((record.outcome.judgeScores?.failedJudges?.length ?? 0) > 0 || (record.outcome.raw.judge_error_count ?? 0) > 0) {
|
|
10635
|
+
throw new ValidationError(
|
|
10636
|
+
`Run ${record.runId} has incomplete judge evidence; product benchmark rows require a complete task score`
|
|
10637
|
+
);
|
|
10638
|
+
}
|
|
10639
|
+
throw new ValidationError(
|
|
10640
|
+
`Run ${record.runId} has no task score; product benchmark rows require an explicit score`
|
|
10641
|
+
);
|
|
10563
10642
|
}
|
|
10564
10643
|
function rawPassOf(record) {
|
|
10565
10644
|
const rawPass = record.outcome.raw.pass;
|
|
@@ -10701,13 +10780,19 @@ function runRecordToProductBenchmarkRecord(record, runDir, artifactRoot, artifac
|
|
|
10701
10780
|
const outputTokens = record.tokenUsage.output;
|
|
10702
10781
|
const toolCallCount = toolCallsOf(record, runDir, opts);
|
|
10703
10782
|
const dimensions = numericDimensions(record);
|
|
10783
|
+
if (record.costUsd === null) {
|
|
10784
|
+
throw new ValidationError(
|
|
10785
|
+
`run '${record.runId}' has no USD cost; product benchmark exports require priced runs`
|
|
10786
|
+
);
|
|
10787
|
+
}
|
|
10788
|
+
const costUsd = record.costUsd;
|
|
10704
10789
|
if (!("tool_calls" in dimensions)) dimensions.tool_calls = toolCallCount;
|
|
10705
10790
|
const product = {
|
|
10706
10791
|
schemaVersion: 1,
|
|
10707
10792
|
projectId: opts.projectId,
|
|
10708
10793
|
benchmarkId: opts.benchmarkId,
|
|
10709
10794
|
runId: record.runId,
|
|
10710
|
-
scenarioId: record.scenarioId
|
|
10795
|
+
scenarioId: record.scenarioId,
|
|
10711
10796
|
split: splitOf(record, opts),
|
|
10712
10797
|
armId,
|
|
10713
10798
|
rep: Number(record.seed ?? 0) + 1,
|
|
@@ -10729,7 +10814,7 @@ function runRecordToProductBenchmarkRecord(record, runDir, artifactRoot, artifac
|
|
|
10729
10814
|
usage: {
|
|
10730
10815
|
inputTokens,
|
|
10731
10816
|
outputTokens,
|
|
10732
|
-
costUsd
|
|
10817
|
+
costUsd,
|
|
10733
10818
|
// Rounded: the bundle contract requires integer milliseconds.
|
|
10734
10819
|
wallMs: Math.round(record.wallMs),
|
|
10735
10820
|
toolCalls: toolCallCount
|
|
@@ -10739,7 +10824,7 @@ function runRecordToProductBenchmarkRecord(record, runDir, artifactRoot, artifac
|
|
|
10739
10824
|
rawCapture: existsArtifact(artifactRoot, artifacts.raws),
|
|
10740
10825
|
traceCapture: existsArtifact(artifactRoot, artifacts.traces),
|
|
10741
10826
|
noStubRows: inputTokens + outputTokens > 0,
|
|
10742
|
-
priced:
|
|
10827
|
+
priced: costUsd > 0,
|
|
10743
10828
|
profileMaterialized: Boolean(record.agentProfile?.cellId)
|
|
10744
10829
|
},
|
|
10745
10830
|
artifacts
|
|
@@ -11379,7 +11464,6 @@ export {
|
|
|
11379
11464
|
REFERENCE_EQUIVALENCE_INPUT_LIMITS,
|
|
11380
11465
|
REFERENCE_EQUIVALENCE_JUDGE_VERSION,
|
|
11381
11466
|
RESEARCH_REPORT_HARD_PAIR_FLOOR,
|
|
11382
|
-
ROLLOUT_FORMAT,
|
|
11383
11467
|
ROLLOUT_SCHEMA,
|
|
11384
11468
|
RUN_COST_ATTR_KEYS,
|
|
11385
11469
|
ReplayCache,
|
|
@@ -11498,6 +11582,7 @@ export {
|
|
|
11498
11582
|
checkTraceContracts,
|
|
11499
11583
|
clamp01,
|
|
11500
11584
|
classifyFailure,
|
|
11585
|
+
classifyOtlpSpanRole,
|
|
11501
11586
|
classifyTreatment,
|
|
11502
11587
|
claudeCodeSupervisorRunReader,
|
|
11503
11588
|
cliffsDelta,
|
|
@@ -11661,6 +11746,7 @@ export {
|
|
|
11661
11746
|
isLlmSpan,
|
|
11662
11747
|
isModelPriced,
|
|
11663
11748
|
isOtelConfigured,
|
|
11749
|
+
isOtlpModelCall,
|
|
11664
11750
|
isRetrievalSpan,
|
|
11665
11751
|
isRolloutLine,
|
|
11666
11752
|
isRunRecord,
|
|
@@ -11719,7 +11805,9 @@ export {
|
|
|
11719
11805
|
otlpToRunRecords,
|
|
11720
11806
|
otlpToTraceRunRecords,
|
|
11721
11807
|
pairArms,
|
|
11808
|
+
pairRunRecords,
|
|
11722
11809
|
pairedBootstrap,
|
|
11810
|
+
pairedCohensDz,
|
|
11723
11811
|
pairedEvalueSequence,
|
|
11724
11812
|
pairedMde,
|
|
11725
11813
|
pairedRiskDifference,
|
|
@@ -11788,10 +11876,10 @@ export {
|
|
|
11788
11876
|
replayScorerOverCorpus,
|
|
11789
11877
|
replayTraceThroughJudge,
|
|
11790
11878
|
requireAgentProfileCell,
|
|
11879
|
+
requiredPairedSampleSize,
|
|
11791
11880
|
requiredSampleSize,
|
|
11792
11881
|
researchReport,
|
|
11793
11882
|
resolveModelPricing,
|
|
11794
|
-
resolveRunCostProvenance,
|
|
11795
11883
|
resolveSeat,
|
|
11796
11884
|
rolloutReward,
|
|
11797
11885
|
rollupSupervisorRuns,
|
|
@@ -11822,6 +11910,7 @@ export {
|
|
|
11822
11910
|
runScore,
|
|
11823
11911
|
runSelfPlay,
|
|
11824
11912
|
runSemanticConceptJudge,
|
|
11913
|
+
runTaskScore,
|
|
11825
11914
|
runTestGradedScenario,
|
|
11826
11915
|
runsForScenario,
|
|
11827
11916
|
scalarScore,
|