skillfit 0.10.0 → 0.11.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/README.md +27 -7
- package/README.zh-CN.md +27 -7
- package/benches/README.md +2 -2
- package/dist/cli.js +146 -36
- package/dist/cli.test.js +94 -0
- package/dist/commands/bench-calibration.js +197 -0
- package/dist/commands/bench-calibration.test.js +237 -0
- package/dist/commands/bench-check-json.test.js +24 -3
- package/dist/commands/bench.js +69 -141
- package/dist/commands/calibration-cli.test.js +145 -0
- package/dist/commands/eval-agent-preflight.test.js +245 -0
- package/dist/commands/eval-cli.js +31 -0
- package/dist/commands/eval-component.js +59 -28
- package/dist/commands/eval-export-modes.test.js +350 -0
- package/dist/commands/eval-export.js +44 -10
- package/dist/commands/eval-export.test.js +165 -8
- package/dist/commands/eval-interruption.test.js +238 -0
- package/dist/commands/eval-plan.js +37 -0
- package/dist/commands/eval-preflight.js +61 -0
- package/dist/commands/eval-preflight.test.js +382 -0
- package/dist/commands/eval-report.js +60 -14
- package/dist/commands/eval-report.test.js +2 -2
- package/dist/commands/eval-single-arm-replay.js +21 -0
- package/dist/commands/eval-single-arm-report.js +223 -0
- package/dist/commands/eval.js +184 -112
- package/dist/commands/evaluation-report.js +5 -0
- package/dist/commands/evaluation-report.test.js +243 -0
- package/dist/commands/replay-cancellation.test.js +105 -0
- package/dist/commands/workflow-entrypoints.test.js +137 -0
- package/dist/harness/agent-preflight.js +180 -0
- package/dist/harness/bench.js +2 -1
- package/dist/harness/command.js +49 -0
- package/dist/harness/eval-audit.js +164 -17
- package/dist/harness/eval-budget.js +46 -2
- package/dist/harness/eval-budget.test.js +30 -3
- package/dist/harness/eval-component.test.js +169 -6
- package/dist/harness/eval-contract.js +11 -5
- package/dist/harness/executors/api.js +14 -4
- package/dist/harness/executors/api.test.js +61 -0
- package/dist/harness/executors/cli.js +24 -3
- package/dist/harness/experiment-session.js +77 -18
- package/dist/harness/experiment-session.test.js +51 -1
- package/dist/harness/input-snapshot.js +150 -0
- package/dist/harness/interruption.js +48 -0
- package/dist/harness/interruption.test.js +31 -0
- package/dist/harness/invocation-costs.js +72 -0
- package/dist/harness/judge-accounting.test.js +216 -0
- package/dist/harness/judge-audit.js +56 -0
- package/dist/harness/judge.js +86 -21
- package/dist/harness/replay-package.js +71 -5
- package/dist/harness/runner.js +92 -44
- package/dist/harness/runner.test.js +23 -0
- package/dist/harness/single-arm-audit.js +436 -0
- package/dist/harness/trigger.js +41 -7
- package/dist/harness/trigger.test.js +12 -0
- package/dist/harness/verifier-error.js +65 -0
- package/dist/harness/verifier.test.js +128 -0
- package/docs/bench-authoring.md +34 -9
- package/docs/bench-check-json.md +36 -6
- package/docs/eval-agent-preflight.md +101 -0
- package/docs/eval-case-preflight.md +115 -0
- package/docs/eval-component.md +65 -9
- package/docs/eval-costs.md +53 -0
- package/docs/eval-planning.md +153 -0
- package/docs/evaluation-input-snapshots.md +125 -0
- package/docs/evaluation-interruption.md +101 -0
- package/docs/evaluation-reports.md +143 -0
- package/docs/experiment-workflow.md +16 -2
- package/docs/first-real-eval.md +55 -5
- package/docs/growth-roadmap-2026-10.md +48 -11
- package/docs/metrics.md +71 -3
- package/docs/plans/2026-10-16-case-workflow-and-release.md +19 -0
- package/docs/plans/2026-10-17-workflow-foundations.md +64 -0
- package/docs/releases/0.10.0-ci-registry-install.json +140 -0
- package/docs/releases/0.10.0-feature-smoke.json +22 -0
- package/docs/releases/0.10.0-feature-smoke.mjs +62 -0
- package/docs/releases/0.10.0-signatures.txt +7 -0
- package/docs/releases/0.10.0-verification.json +76 -0
- package/docs/releases/0.10.0.md +44 -8
- package/docs/releases/0.10.1-ci-registry-install.json +70 -0
- package/docs/releases/0.10.1-feature-smoke.json +28 -0
- package/docs/releases/0.10.1-feature-smoke.mjs +95 -0
- package/docs/releases/0.10.1-local-registry-install.json +60 -0
- package/docs/releases/0.10.1-registry-metadata.json +33 -0
- package/docs/releases/0.10.1-signatures.txt +7 -0
- package/docs/releases/0.10.1-verification.json +90 -0
- package/docs/releases/0.10.1.md +71 -0
- package/docs/releases/0.11.0-feature-smoke.mjs +224 -0
- package/docs/releases/0.11.0.md +47 -0
- package/docs/replay-packages.md +52 -11
- package/docs/schemas/agent-preflight.schema.json +31 -0
- package/docs/schemas/calibration-plan.schema.json +22 -0
- package/docs/schemas/calibration-result.schema.json +17 -0
- package/docs/schemas/eval-preflight.schema.json +57 -0
- package/docs/schemas/eval-request.schema.json +1 -1
- package/docs/schemas/eval-result.schema.json +14 -1
- package/docs/schemas/invocation-costs.schema.json +31 -0
- package/docs/schemas/judge-call.schema.json +22 -0
- package/docs/schemas/single-arm-report.schema.json +20 -0
- package/docs/schemas/verifier-error.schema.json +11 -0
- package/docs/sharing-results.md +8 -2
- package/docs/verifier-contract.md +99 -0
- package/package.json +1 -1
- package/skills/skillfit/SKILL.md +41 -8
package/dist/harness/runner.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import {
|
|
2
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { dirname, join, resolve } from 'node:path';
|
|
4
4
|
import { MOCK_MARKER_FILE, RUN_GROUP_PATTERN } from './constants.js';
|
|
5
5
|
import { assertInstalledSkillFixtures, assertSkillRevisionTargets, installSkillResources, installedSkillDestination } from './installed-skill.js';
|
|
6
6
|
import { collectInstalledSkillFingerprint } from './bundle.js';
|
|
7
|
-
import { judgePair } from './judge.js';
|
|
7
|
+
import { JudgePairFailure, judgePair } from './judge.js';
|
|
8
8
|
import { killTree, treeSpawnOptions } from './kill-tree.js';
|
|
9
|
+
import { evaluationSignal, throwIfEvaluationInterrupted } from './interruption.js';
|
|
9
10
|
import { assertInputModeSupported, buildTaskPrompt, snapshotRepoFiles } from './prompt.js';
|
|
10
11
|
import { buildWarnings, verdictFor, } from './report.js';
|
|
11
12
|
import { mcnemarExactP, pairedDeltaBootstrapCI, pairedScoreBootstrapCI } from './stats.js';
|
|
@@ -17,7 +18,10 @@ import { ExecutorFailure } from './types.js';
|
|
|
17
18
|
import { summarizeCosts } from './costs.js';
|
|
18
19
|
import { executionClock } from './execution-timing.js';
|
|
19
20
|
import { verdictFromOutput } from './verifier-summary.js';
|
|
20
|
-
import {
|
|
21
|
+
import { createSpendingBudgetRecorder, parseSpendingBudget } from './eval-budget.js';
|
|
22
|
+
import { summarizeInvocationCosts } from './invocation-costs.js';
|
|
23
|
+
import { parseCommand } from './command.js';
|
|
24
|
+
import { verifierRuntimeError } from './verifier-error.js';
|
|
21
25
|
function applyOverlay(overlayDir, runDir) {
|
|
22
26
|
for (const rel of listFilesRecursive(overlayDir)) {
|
|
23
27
|
const destination = join(runDir, rel);
|
|
@@ -28,6 +32,9 @@ function applyOverlay(overlayDir, runDir) {
|
|
|
28
32
|
const VERIFIER_TIMEOUT_MS = 2 * 60 * 1000;
|
|
29
33
|
const MAX_PROCESS_OUTPUT_BYTES = 8 * 1024 * 1024;
|
|
30
34
|
function runProcess(command, args, cwd, timeoutMs) {
|
|
35
|
+
const signal = evaluationSignal();
|
|
36
|
+
if (signal?.aborted)
|
|
37
|
+
return Promise.resolve({ exitCode: null, output: '', error: signal.reason.message });
|
|
31
38
|
return new Promise((resolvePromise) => {
|
|
32
39
|
let child;
|
|
33
40
|
try {
|
|
@@ -43,15 +50,47 @@ function runProcess(command, args, cwd, timeoutMs) {
|
|
|
43
50
|
let bytes = 0;
|
|
44
51
|
let timedOut = false;
|
|
45
52
|
let overflow = false;
|
|
53
|
+
let stopping = false;
|
|
54
|
+
let settled = false;
|
|
55
|
+
let drainTimer;
|
|
56
|
+
const finish = (result) => {
|
|
57
|
+
if (settled)
|
|
58
|
+
return;
|
|
59
|
+
settled = true;
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
clearTimeout(drainTimer);
|
|
62
|
+
signal?.removeEventListener('abort', onAbort);
|
|
63
|
+
resolvePromise(result);
|
|
64
|
+
};
|
|
65
|
+
const result = (code) => ({
|
|
66
|
+
exitCode: signal?.aborted || timedOut || overflow ? null : code,
|
|
67
|
+
output: timedOut ? `${output}\n[timed out after ${timeoutMs}ms]` : output,
|
|
68
|
+
error: signal?.aborted ? signal.reason.message : overflow
|
|
69
|
+
? `output exceeded ${MAX_PROCESS_OUTPUT_BYTES} bytes` : timedOut ? `timed out after ${timeoutMs}ms` : null,
|
|
70
|
+
});
|
|
71
|
+
const stop = () => {
|
|
72
|
+
if (stopping || settled)
|
|
73
|
+
return;
|
|
74
|
+
stopping = true;
|
|
75
|
+
killTree(child);
|
|
76
|
+
drainTimer = setTimeout(() => {
|
|
77
|
+
child.stdin?.destroy();
|
|
78
|
+
child.stdout.destroy();
|
|
79
|
+
child.stderr.destroy();
|
|
80
|
+
child.unref();
|
|
81
|
+
finish(result(null));
|
|
82
|
+
}, 2000);
|
|
83
|
+
};
|
|
84
|
+
const onAbort = () => stop();
|
|
46
85
|
const timer = setTimeout(() => {
|
|
47
86
|
timedOut = true;
|
|
48
|
-
|
|
87
|
+
stop();
|
|
49
88
|
}, timeoutMs);
|
|
50
89
|
const take = (chunk) => {
|
|
51
90
|
bytes += chunk.length;
|
|
52
91
|
if (bytes > MAX_PROCESS_OUTPUT_BYTES) {
|
|
53
92
|
overflow = true;
|
|
54
|
-
|
|
93
|
+
stop();
|
|
55
94
|
return;
|
|
56
95
|
}
|
|
57
96
|
output += chunk.toString('utf8');
|
|
@@ -63,18 +102,14 @@ function runProcess(command, args, cwd, timeoutMs) {
|
|
|
63
102
|
child.stdin?.on('error', () => { });
|
|
64
103
|
child.stdin?.end();
|
|
65
104
|
child.on('error', (error) => {
|
|
66
|
-
|
|
67
|
-
resolvePromise({ exitCode: null, output, error: error.message });
|
|
105
|
+
finish({ exitCode: null, output, error: error.message });
|
|
68
106
|
});
|
|
69
107
|
child.on('close', (code) => {
|
|
70
|
-
|
|
71
|
-
const limited = overflow ? `output exceeded ${MAX_PROCESS_OUTPUT_BYTES} bytes` : null;
|
|
72
|
-
resolvePromise({
|
|
73
|
-
exitCode: timedOut || overflow ? null : code,
|
|
74
|
-
output: timedOut ? `${output}\n[timed out after ${timeoutMs}ms]` : output,
|
|
75
|
-
error: limited ?? (timedOut ? `timed out after ${timeoutMs}ms` : null),
|
|
76
|
-
});
|
|
108
|
+
finish(result(code));
|
|
77
109
|
});
|
|
110
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
111
|
+
if (signal?.aborted)
|
|
112
|
+
onAbort();
|
|
78
113
|
});
|
|
79
114
|
}
|
|
80
115
|
export async function gitInit(dir) {
|
|
@@ -118,6 +153,7 @@ export async function engagementError(output, verifierKind, runDir, gitInitializ
|
|
|
118
153
|
return ENGAGEMENT_ERROR;
|
|
119
154
|
}
|
|
120
155
|
export async function runTrial(plan, taskId, condition, trial) {
|
|
156
|
+
throwIfEvaluationInterrupted();
|
|
121
157
|
const { bench, executor } = plan;
|
|
122
158
|
const target = condition === 'baseline' && plan.baselineTarget ? plan.baselineTarget : plan.target;
|
|
123
159
|
if (plan.baselineTarget) {
|
|
@@ -165,6 +201,7 @@ export async function runTrial(plan, taskId, condition, trial) {
|
|
|
165
201
|
installNativeDiffTool(runDir);
|
|
166
202
|
}
|
|
167
203
|
const gitInitialized = await gitInit(runDir);
|
|
204
|
+
throwIfEvaluationInterrupted();
|
|
168
205
|
const taskPromptText = readFileSync(join(bench.dir, task.prompt), 'utf8');
|
|
169
206
|
const prompt = buildTaskPrompt(taskPromptText, snapshot, condition === 'treatment' && !plan.skillInstallDir ? target.payload : null,
|
|
170
207
|
// Workspace configuration experiments must let the agent use its configured tools and inspect
|
|
@@ -231,7 +268,7 @@ export async function runTrial(plan, taskId, condition, trial) {
|
|
|
231
268
|
const verifier = await runVerifier(bench.dir, task.verifier, runDir);
|
|
232
269
|
verifierExitCode = verifier.exitCode;
|
|
233
270
|
writeFileSync(join(runDir, '_verifier.txt'), verifierLogFor(verifier), 'utf8');
|
|
234
|
-
if (verifier.exitCode === null) {
|
|
271
|
+
if (verifier.error !== null || verifier.exitCode === null) {
|
|
235
272
|
error = verifierFailure('verifier', task.verifier, verifier.error);
|
|
236
273
|
}
|
|
237
274
|
else {
|
|
@@ -288,12 +325,15 @@ export async function runTrial(plan, taskId, condition, trial) {
|
|
|
288
325
|
return record;
|
|
289
326
|
}
|
|
290
327
|
export async function runVerifier(benchDir, command, runDir) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return { exitCode: null, output: '', error: 'empty verifier command' };
|
|
328
|
+
let tokens;
|
|
329
|
+
try {
|
|
330
|
+
tokens = parseCommand(command);
|
|
295
331
|
}
|
|
296
|
-
|
|
332
|
+
catch (error) {
|
|
333
|
+
return { exitCode: null, output: '', error: `VERIFIER_COMMAND_ERROR: ${error.message}` };
|
|
334
|
+
}
|
|
335
|
+
const result = await runProcess(tokens[0], [...tokens.slice(1), runDir], benchDir, VERIFIER_TIMEOUT_MS);
|
|
336
|
+
return { ...result, error: result.error ?? verifierRuntimeError(result.output, result.exitCode, benchDir, runDir) };
|
|
297
337
|
}
|
|
298
338
|
export function verifierLogFor(result) {
|
|
299
339
|
return result.error ? `${result.output}\n[${result.error}]` : result.output;
|
|
@@ -306,6 +346,8 @@ const SPAWN_FAILURE = /ENOENT|EINVAL|EACCES|EPERM/i;
|
|
|
306
346
|
*/
|
|
307
347
|
export function verifierFailure(label, command, reason) {
|
|
308
348
|
const why = reason ?? 'no exit code';
|
|
349
|
+
if (why.startsWith('VERIFIER_'))
|
|
350
|
+
return `${label} failed (${why}): ${command}`;
|
|
309
351
|
if (SPAWN_FAILURE.test(why)) {
|
|
310
352
|
return `${label} could not be started (${why}): ${command} — it is spawned without a shell, so the first token must be an executable the OS can start directly ("node verifiers/x.mjs"); to grade with a shell command, wrap it via "bench add --freeze --verifier-cmd"`;
|
|
311
353
|
}
|
|
@@ -329,7 +371,7 @@ function sumTokens(records) {
|
|
|
329
371
|
* knob reports `sampling: null`, which is a statement about the surface — not an omission that a
|
|
330
372
|
* reader would have to guess at.
|
|
331
373
|
*/
|
|
332
|
-
function withSampling(descriptor) {
|
|
374
|
+
export function withSampling(descriptor) {
|
|
333
375
|
return { ...descriptor, sampling: descriptor.sampling ?? null };
|
|
334
376
|
}
|
|
335
377
|
function countErrors(records) {
|
|
@@ -396,7 +438,7 @@ function tokenDelta(baseline, treatment) {
|
|
|
396
438
|
return null;
|
|
397
439
|
return { input: treatment.input - baseline.input, output: treatment.output - baseline.output };
|
|
398
440
|
}
|
|
399
|
-
function summarizeJudge(judgeResults) {
|
|
441
|
+
export function summarizeJudge(judgeResults) {
|
|
400
442
|
if (judgeResults.length === 0)
|
|
401
443
|
return null;
|
|
402
444
|
const consistent = judgeResults.filter((r) => r.consistent);
|
|
@@ -413,7 +455,7 @@ function summarizeJudge(judgeResults) {
|
|
|
413
455
|
treatmentMean: mean(consistent.map((r) => r.treatmentScore)),
|
|
414
456
|
};
|
|
415
457
|
}
|
|
416
|
-
async function judgeTaskTrials(plan, taskId, outcomes) {
|
|
458
|
+
async function judgeTaskTrials(plan, taskId, outcomes, allJudgeCalls, budget) {
|
|
417
459
|
const judge = plan.judge;
|
|
418
460
|
if (!judge)
|
|
419
461
|
return [];
|
|
@@ -439,12 +481,27 @@ async function judgeTaskTrials(plan, taskId, outcomes) {
|
|
|
439
481
|
baselineOutput: baseline.output,
|
|
440
482
|
treatmentOutput: treatment.output,
|
|
441
483
|
seed,
|
|
484
|
+
taskId: task.id,
|
|
485
|
+
trial,
|
|
486
|
+
clock: plan.clock,
|
|
487
|
+
beforeCall: callIndex => budget.before({ role: 'judge', taskId: task.id, trial, callIndex }),
|
|
488
|
+
onCall: receipt => {
|
|
489
|
+
const path = join(taskDir, `judge-trial-${trial}`);
|
|
490
|
+
mkdirSync(path, { recursive: true });
|
|
491
|
+
writeFileSync(join(path, `call-${receipt.callIndex}.json`), JSON.stringify(receipt, null, 2) + '\n', { flag: 'wx' });
|
|
492
|
+
allJudgeCalls.push(receipt);
|
|
493
|
+
budget.after({ role: 'judge', taskId: task.id, trial, callIndex: receipt.callIndex }, receipt);
|
|
494
|
+
},
|
|
442
495
|
});
|
|
443
496
|
results.push(result);
|
|
444
497
|
writeFileSync(join(taskDir, `judge-trial-${trial}.json`), `${JSON.stringify({ trial, seed, ...result }, null, 2)}\n`, 'utf8');
|
|
445
498
|
}
|
|
446
499
|
catch (error) {
|
|
500
|
+
writeFileSync(join(taskDir, `judge-trial-${trial}-error.json`), JSON.stringify({ schemaVersion: 1, trial, seed,
|
|
501
|
+
error: error.message, calls: error instanceof JudgePairFailure ? error.calls : [], automaticRetry: false }, null, 2) + '\n', { flag: 'wx' });
|
|
502
|
+
throwIfEvaluationInterrupted();
|
|
447
503
|
plan.log?.(`Judge failed for ${task.id} trial ${trial}: ${error.message}`);
|
|
504
|
+
throw error;
|
|
448
505
|
}
|
|
449
506
|
}
|
|
450
507
|
return results;
|
|
@@ -568,8 +625,6 @@ function summarizeTask(taskId, outcomes, survivors, judgeResults, readObservatio
|
|
|
568
625
|
}
|
|
569
626
|
export async function runExperiment(plan) {
|
|
570
627
|
const budget = plan.spendingBudget === undefined ? undefined : parseSpendingBudget(plan.spendingBudget);
|
|
571
|
-
if (budget && plan.judge)
|
|
572
|
-
throw new Error('spendingBudget does not cover judge calls.');
|
|
573
628
|
assertInputModeSupported(plan.inputMode ?? 'snapshot', plan.executor);
|
|
574
629
|
const pairOrder = plan.pairOrder ?? 'baseline-first';
|
|
575
630
|
if (pairOrder !== 'baseline-first' && pairOrder !== 'balanced')
|
|
@@ -593,9 +648,10 @@ export async function runExperiment(plan) {
|
|
|
593
648
|
throw new Error(`trials must be an integer between 1 and 20, got ${plan.trials}`);
|
|
594
649
|
}
|
|
595
650
|
const groupDir = join(plan.runsRoot, plan.runGroup);
|
|
596
|
-
if (existsSync(groupDir)
|
|
597
|
-
|
|
598
|
-
|
|
651
|
+
if (existsSync(groupDir)) {
|
|
652
|
+
if (plan.session?.groupDir !== resolve(groupDir))
|
|
653
|
+
throw new Error(`Run group directory already exists: ${groupDir}`);
|
|
654
|
+
plan.session.assertPrepared();
|
|
599
655
|
}
|
|
600
656
|
mkdirSync(groupDir, { recursive: true });
|
|
601
657
|
if (plan.skillInstallDir)
|
|
@@ -603,14 +659,8 @@ export async function runExperiment(plan) {
|
|
|
603
659
|
const taskSummaries = [];
|
|
604
660
|
const allOutcomes = { baseline: [], treatment: [] };
|
|
605
661
|
const allSurvivors = { baseline: [], treatment: [] };
|
|
606
|
-
const
|
|
607
|
-
const
|
|
608
|
-
if (!budget)
|
|
609
|
-
return null;
|
|
610
|
-
const state = spendingBudgetState(budget, budgetObservations);
|
|
611
|
-
appendFileSync(join(groupDir, '_budget.jsonl'), JSON.stringify({ phase, taskId, condition, trial, state }) + '\n', 'utf8');
|
|
612
|
-
return state;
|
|
613
|
-
};
|
|
662
|
+
const budgetRecorder = createSpendingBudgetRecorder({ budget, groupDir });
|
|
663
|
+
const allJudgeCalls = [];
|
|
614
664
|
for (const [taskIndex, task] of plan.bench.tasks.entries()) {
|
|
615
665
|
const outcomes = { baseline: [], treatment: [] };
|
|
616
666
|
// Interleaved: the trial loop is outermost so the two arms of a pair run adjacently. Running
|
|
@@ -618,25 +668,22 @@ export async function runExperiment(plan) {
|
|
|
618
668
|
// provider drift or rate-limit degradation would land entirely on one arm.
|
|
619
669
|
for (let trial = 1; trial <= plan.trials; trial++) {
|
|
620
670
|
for (const condition of pairConditions(pairOrder, taskIndex, trial)) {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
assertSpendingCanContinue(before);
|
|
671
|
+
throwIfEvaluationInterrupted();
|
|
672
|
+
budgetRecorder.before({ taskId: task.id, condition, trial });
|
|
624
673
|
plan.log?.(`Running ${task.id} / ${condition} / trial ${trial}…`);
|
|
625
674
|
const outcome = await runTrial(plan, task.id, condition, trial);
|
|
626
675
|
outcomes[condition].push(outcome);
|
|
627
676
|
allOutcomes[condition].push(outcome);
|
|
628
|
-
|
|
629
|
-
|
|
677
|
+
budgetRecorder.after({ taskId: task.id, condition, trial }, outcome);
|
|
678
|
+
throwIfEvaluationInterrupted();
|
|
630
679
|
// A reached line prevents the next call; incomplete or failed evidence stops even
|
|
631
680
|
// after the final scheduled call. One in-flight invocation may cross a stop line.
|
|
632
|
-
if (after && (after.incomplete.length || after.reason === 'EXECUTION_FAILED'))
|
|
633
|
-
assertSpendingCanContinue(after);
|
|
634
681
|
}
|
|
635
682
|
}
|
|
636
683
|
const survivors = pairedSurvivors(outcomes);
|
|
637
684
|
allSurvivors.baseline.push(...survivors.baseline);
|
|
638
685
|
allSurvivors.treatment.push(...survivors.treatment);
|
|
639
|
-
const judgeResults = await judgeTaskTrials(plan, task.id, outcomes);
|
|
686
|
+
const judgeResults = await judgeTaskTrials(plan, task.id, outcomes, allJudgeCalls, budgetRecorder);
|
|
640
687
|
taskSummaries.push(summarizeTask(task.id, outcomes, survivors, judgeResults, !!plan.skillInstallDir));
|
|
641
688
|
}
|
|
642
689
|
const overallBaseline = statsFor(allSurvivors.baseline, countErrors(allOutcomes.baseline), !!plan.skillInstallDir);
|
|
@@ -654,6 +701,7 @@ export async function runExperiment(plan) {
|
|
|
654
701
|
plan.session?.settle();
|
|
655
702
|
const manifestWithoutWarnings = {
|
|
656
703
|
schemaVersion: 4,
|
|
704
|
+
invocationCosts: summarizeInvocationCosts([...allOutcomes.baseline, ...allOutcomes.treatment], allJudgeCalls, !!plan.judge),
|
|
657
705
|
...(plan.component ? { component: plan.component } : {}),
|
|
658
706
|
...(plan.session ? { experiment: plan.session.summary() } : {}),
|
|
659
707
|
inputMode: plan.inputMode ?? 'snapshot',
|
|
@@ -513,6 +513,29 @@ test('runExperiment excludes a trial whose verifier could not be spawned', async
|
|
|
513
513
|
assert.match(result.error ?? '', /verifier could not be started/);
|
|
514
514
|
assert.match(result.error ?? '', /spawned without a shell/);
|
|
515
515
|
});
|
|
516
|
+
test('a grader exception excludes its pair while normal graded failures and all invocation costs survive', async (t) => {
|
|
517
|
+
const root = tmp(t, 'skillfit-grader-errors-');
|
|
518
|
+
mkdirSync(join(root, 'fixture'));
|
|
519
|
+
writeFileSync(join(root, 'fixture/input.txt'), 'input');
|
|
520
|
+
writeFileSync(join(root, 'prompt.md'), 'Return an answer.');
|
|
521
|
+
writeFileSync(join(root, 'verifier.mjs'), "import{readFileSync}from'node:fs';import{join}from'node:path';const text=readFileSync(join(process.argv[2],'_output.md'),'utf8');if(text==='crash')throw new Error('grader unavailable');console.log(JSON.stringify({passed:false}));process.exit(1);");
|
|
522
|
+
writeFileSync(join(root, 'bench.json'), JSON.stringify({ schemaVersion: 1, tasks: [{ id: 't', fixture: 'fixture', prompt: 'prompt.md', verifier: 'node verifier.mjs' }] }));
|
|
523
|
+
let calls = 0;
|
|
524
|
+
const executor = { describe: () => ({ kind: 'mock', model: 'offline-grader-pairs' }), run: async () => ({ output: ++calls === 1 ? 'crash' : 'normal failure', tokens: { input: 10, cachedInput: 4, output: 2 } }) };
|
|
525
|
+
const manifest = await runExperiment({ bench: loadBench(root), target: collectSkillBundle(makeSkill(t)), executor,
|
|
526
|
+
trials: 2, runsRoot: join(root, 'runs'), runGroup: 'grade' });
|
|
527
|
+
const task = manifest.tasks[0];
|
|
528
|
+
assert.equal(calls, 4);
|
|
529
|
+
assert.equal(task.conditions.baseline.errors, 1);
|
|
530
|
+
assert.equal(task.conditions.treatment.errors, 0);
|
|
531
|
+
assert.deepEqual(task.outcomes, { baseline: [false], treatment: [false] });
|
|
532
|
+
assert.equal(manifest.overall.costs.attempts.baseline.metrics.input.knownTotal, 20);
|
|
533
|
+
assert.equal(manifest.overall.costs.attempts.treatment.metrics.input.knownTotal, 20);
|
|
534
|
+
assert.equal(manifest.overall.costs.paired.baseline.metrics.input.knownTotal, 10);
|
|
535
|
+
const receipt = JSON.parse(readFileSync(join(root, 'runs/grade/t/baseline/trial-1/_result.json'), 'utf8'));
|
|
536
|
+
assert.equal(receipt.verifierExitCode, 1);
|
|
537
|
+
assert.match(receipt.error, /VERIFIER_RUNTIME_ERROR/);
|
|
538
|
+
});
|
|
516
539
|
test('runExperiment interleaves conditions within each trial and records sampling', async (t) => {
|
|
517
540
|
const runsRoot = tmp(t, 'skillfit-runs-order-');
|
|
518
541
|
const inner = new MockExecutor();
|