skillfit 0.10.1 → 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 +18 -6
- package/README.zh-CN.md +18 -6
- package/benches/README.md +2 -2
- package/dist/cli.js +132 -28
- 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 +63 -143
- 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 +52 -28
- package/dist/commands/eval-export-modes.test.js +350 -0
- package/dist/commands/eval-export.js +12 -4
- package/dist/commands/eval-plan.js +37 -0
- package/dist/commands/eval-preflight.test.js +144 -1
- package/dist/commands/eval-report.js +18 -3
- 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 +106 -56
- 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 +161 -16
- package/dist/harness/eval-budget.js +46 -2
- package/dist/harness/eval-budget.test.js +26 -1
- package/dist/harness/eval-component.test.js +163 -0
- package/dist/harness/eval-contract.js +11 -5
- package/dist/harness/executors/api.js +4 -3
- package/dist/harness/executors/api.test.js +18 -0
- package/dist/harness/experiment-session.js +18 -10
- package/dist/harness/experiment-session.test.js +8 -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 +40 -30
- package/dist/harness/runner.test.js +23 -0
- package/dist/harness/single-arm-audit.js +436 -0
- package/dist/harness/trigger.js +21 -3
- 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 +28 -5
- package/docs/eval-agent-preflight.md +101 -0
- package/docs/eval-case-preflight.md +5 -0
- package/docs/eval-component.md +38 -10
- package/docs/eval-costs.md +44 -0
- package/docs/eval-planning.md +153 -0
- package/docs/evaluation-input-snapshots.md +2 -1
- package/docs/evaluation-interruption.md +22 -10
- package/docs/evaluation-reports.md +97 -3
- package/docs/experiment-workflow.md +7 -0
- package/docs/first-real-eval.md +50 -3
- package/docs/growth-roadmap-2026-10.md +41 -9
- package/docs/metrics.md +40 -3
- package/docs/plans/2026-10-17-workflow-foundations.md +64 -0
- 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-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 +37 -4
- 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 +38 -6
- 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-request.schema.json +1 -1
- package/docs/schemas/eval-result.schema.json +3 -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 +3 -0
- package/docs/verifier-contract.md +99 -0
- package/package.json +1 -1
- package/skills/skillfit/SKILL.md +41 -8
package/dist/commands/eval.js
CHANGED
|
@@ -6,22 +6,24 @@ import { getAgent } from '../agents.js';
|
|
|
6
6
|
import { loadBench, selectBenchTasks } from '../harness/bench.js';
|
|
7
7
|
import { RUN_GROUP_PATTERN } from '../harness/constants.js';
|
|
8
8
|
import { ExperimentSession, validateCallBudget } from '../harness/experiment-session.js';
|
|
9
|
-
import { ApiExecutor } from '../harness/executors/api.js';
|
|
10
|
-
import { CliExecutor
|
|
9
|
+
import { ApiExecutor, DEFAULT_API_TIMEOUT_MS } from '../harness/executors/api.js';
|
|
10
|
+
import { CliExecutor } from '../harness/executors/cli.js';
|
|
11
11
|
import { listFilesRecursive } from '../harness/hash.js';
|
|
12
12
|
import { assertNativeDiffFixtures, nativeDiffDescriptor } from '../harness/native-diff.js';
|
|
13
13
|
import { assertInstalledSkillFixtures, assertSkillRevisionTargets, collectInstalledSkillTarget } from '../harness/installed-skill.js';
|
|
14
14
|
import { assertInputModeSupported } from '../harness/prompt.js';
|
|
15
15
|
import { CONCLUSIVE_TASKS, CONCLUSIVE_TRIALS, renderSummary } from '../harness/report.js';
|
|
16
|
-
import { runExperiment } from '../harness/runner.js';
|
|
16
|
+
import { runExperiment, withSampling } from '../harness/runner.js';
|
|
17
17
|
import { collectInstalledSkillFingerprint } from '../harness/bundle.js';
|
|
18
18
|
import { installedUserSkills } from '../harness/receipts.js';
|
|
19
19
|
import { collectEvaluationTarget } from '../harness/target.js';
|
|
20
20
|
import { renderTriggerSummary, runTriggerExperiment, } from '../harness/trigger.js';
|
|
21
|
+
import { parseExecutorTimeoutSeconds, parsePairOrder } from '../harness/eval-contract.js';
|
|
21
22
|
import { parseSpendingBudget } from '../harness/eval-budget.js';
|
|
22
23
|
import { withEvaluationInterrupts, throwIfEvaluationInterrupted } from '../harness/interruption.js';
|
|
23
24
|
import { CASE_PREFLIGHT_POLICY, checkEvalCases } from './eval-preflight.js';
|
|
24
25
|
import { INPUT_SNAPSHOT_POLICY } from '../harness/input-snapshot.js';
|
|
26
|
+
import { inspectAgentEnvironment, assertAgentEnvironment, assertAgentEnvironmentUnchanged, renderAgentEnvironment } from '../harness/agent-preflight.js';
|
|
25
27
|
export const DEFAULT_EVAL_TRIALS = 5;
|
|
26
28
|
function bundledBenchesRoot() {
|
|
27
29
|
return fileURLToPath(new URL('../../benches', import.meta.url));
|
|
@@ -62,7 +64,7 @@ function resolveExecutor(agent, target, installed = false, executorTimeoutSecond
|
|
|
62
64
|
...(installed && definition.headless.streamJson ? { triggerSkillName: target.name } : {}),
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
|
-
return ApiExecutor.fromEnv();
|
|
67
|
+
return ApiExecutor.fromEnv(process.env, executorTimeoutSeconds === undefined ? {} : { timeoutMs: executorTimeoutSeconds * 1000 });
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
70
|
* An API executor has no filesystem access, so it cannot satisfy a `verifierKind: "command"` task.
|
|
@@ -84,23 +86,19 @@ function assertExecutorSupportsBench(executor, bench) {
|
|
|
84
86
|
'would be written and both arms would score 0. Use --agent <id> for a CLI executor that works in the run ' +
|
|
85
87
|
'directory, or re-grade those tasks as verifierKind "output".');
|
|
86
88
|
}
|
|
87
|
-
function resolveJudge(judgeAgent) {
|
|
89
|
+
function resolveJudge(judgeAgent, timeoutSeconds) {
|
|
88
90
|
const flag = process.env['SKILLFIT_JUDGE'];
|
|
89
91
|
if (!judgeAgent && (!flag || flag === '0' || flag === 'false'))
|
|
90
92
|
return null;
|
|
91
93
|
if (judgeAgent) {
|
|
92
|
-
return CliExecutor.forAgent(judgeAgent);
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
return new ApiExecutor({
|
|
96
|
-
apiKey: process.env['SKILLFIT_JUDGE_API_KEY'] ?? process.env['SKILLFIT_API_KEY'] ?? process.env['OPENAI_API_KEY'],
|
|
97
|
-
model: process.env['SKILLFIT_JUDGE_MODEL'] ?? process.env['SKILLFIT_API_MODEL'],
|
|
98
|
-
baseUrl: process.env['SKILLFIT_JUDGE_BASE_URL'] ?? process.env['SKILLFIT_API_BASE_URL'],
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
return null;
|
|
94
|
+
return CliExecutor.forAgent(judgeAgent, timeoutSeconds === undefined ? {} : { timeoutMs: timeoutSeconds * 1000 });
|
|
103
95
|
}
|
|
96
|
+
return new ApiExecutor({
|
|
97
|
+
apiKey: process.env['SKILLFIT_JUDGE_API_KEY'] ?? process.env['SKILLFIT_API_KEY'] ?? process.env['OPENAI_API_KEY'],
|
|
98
|
+
model: process.env['SKILLFIT_JUDGE_MODEL'] ?? process.env['SKILLFIT_API_MODEL'],
|
|
99
|
+
baseUrl: process.env['SKILLFIT_JUDGE_BASE_URL'] ?? process.env['SKILLFIT_API_BASE_URL'],
|
|
100
|
+
...(timeoutSeconds === undefined ? {} : { timeoutMs: timeoutSeconds * 1000 }),
|
|
101
|
+
});
|
|
104
102
|
}
|
|
105
103
|
function defaultRunGroup(now = new Date()) {
|
|
106
104
|
const pad2 = (value) => String(value).padStart(2, '0');
|
|
@@ -108,6 +106,15 @@ function defaultRunGroup(now = new Date()) {
|
|
|
108
106
|
const time = `${pad2(now.getHours())}${pad2(now.getMinutes())}${pad2(now.getSeconds())}`;
|
|
109
107
|
return `eval-${date}-${time}`;
|
|
110
108
|
}
|
|
109
|
+
function inspectEvalAgent(options, target, executor, judge, capabilityError, resolutionError, judgeError) {
|
|
110
|
+
const roles = [{ role: 'agent', definition: options.agent ? getAgent(options.agent) : undefined,
|
|
111
|
+
executor: executor?.describe() ?? null, injected: options.executor !== undefined, resolutionError }];
|
|
112
|
+
if (judge || judgeError)
|
|
113
|
+
roles.push({ role: 'judge', definition: options.judgeAgent ? getAgent(options.judgeAgent) : undefined,
|
|
114
|
+
executor: judge?.describe() ?? null, injected: options.judgeExecutor != null, resolutionError: judgeError });
|
|
115
|
+
return inspectAgentEnvironment({ roles, mode: options.mode ?? 'inject', target, capabilityError,
|
|
116
|
+
homeDir: options.sessionOptions?.homeDir, env: options.sessionOptions?.env });
|
|
117
|
+
}
|
|
111
118
|
function sessionFor(options, bench, target, trials, runsRoot, runGroup, armNames, plannedCalls, details, baselineTarget) {
|
|
112
119
|
if (!RUN_GROUP_PATTERN.test(runGroup))
|
|
113
120
|
throw new Error(`Invalid run group: ${runGroup}`);
|
|
@@ -144,6 +151,8 @@ function renderPlan(bench, target, executor, judge, trials, runsRoot, runGroup,
|
|
|
144
151
|
lines.push(`Baseline : ${baselineTarget.name} (${baselineTarget.files.length} files, bundle sha256 ${baselineTarget.sha256.slice(0, 12)}…)`);
|
|
145
152
|
lines.push('Compare : previous Skill in baseline vs target Skill in treatment; measures revision effects, not benefit over no Skill');
|
|
146
153
|
}
|
|
154
|
+
else if (inputMode === 'workspace' && target.kind === 'skill')
|
|
155
|
+
lines.push('Baseline : no Skill installed by the harness (inherited configuration still applies)');
|
|
147
156
|
if (target.kind !== 'skill') {
|
|
148
157
|
lines.push(' applied as project files; treatment material is never injected into the prompt');
|
|
149
158
|
}
|
|
@@ -205,17 +214,21 @@ function renderTriggerPlan(bench, skill, executor, trials, runsRoot, runGroup, i
|
|
|
205
214
|
return lines.join('\n');
|
|
206
215
|
}
|
|
207
216
|
async function runEvalTrigger(options, bench, skill, trials, log) {
|
|
217
|
+
if (options.judgeAgent || options.judgeExecutor)
|
|
218
|
+
throw new Error('Trigger evaluation does not use a judge.');
|
|
219
|
+
const executorTimeoutSeconds = parseExecutorTimeoutSeconds(options.executorTimeoutSeconds);
|
|
220
|
+
const spendingBudget = options.spendingBudget === undefined ? undefined : parseSpendingBudget(options.spendingBudget);
|
|
208
221
|
let executor = options.executor ?? null;
|
|
222
|
+
let resolutionError;
|
|
209
223
|
if (!executor) {
|
|
210
224
|
if (!options.agent) {
|
|
211
225
|
throw new Error('trigger mode requires --agent (a CLI executor with trigger detection); API executors cannot measure skill triggering.');
|
|
212
226
|
}
|
|
213
227
|
try {
|
|
214
|
-
executor = CliExecutor.forAgent(options.agent, { triggerSkillName: skill.name });
|
|
228
|
+
executor = CliExecutor.forAgent(options.agent, { triggerSkillName: skill.name, timeoutMs: executorTimeoutSeconds * 1000 });
|
|
215
229
|
}
|
|
216
230
|
catch (error) {
|
|
217
|
-
|
|
218
|
-
throw error;
|
|
231
|
+
resolutionError = error.message;
|
|
219
232
|
log(`Note: ${error.message}`);
|
|
220
233
|
}
|
|
221
234
|
}
|
|
@@ -225,6 +238,8 @@ async function runEvalTrigger(options, bench, skill, trials, log) {
|
|
|
225
238
|
const runGroup = options.runGroup ?? defaultRunGroup();
|
|
226
239
|
const plannedCalls = bench.tasks.filter(task => task.shouldTrigger !== undefined).length * trials;
|
|
227
240
|
const maxCalls = validateCallBudget(plannedCalls, options.maxCalls);
|
|
241
|
+
const inspect = () => inspectEvalAgent(options, skill, executor, null, undefined, resolutionError);
|
|
242
|
+
const agentPreflight = inspect();
|
|
228
243
|
if (!RUN_GROUP_PATTERN.test(runGroup))
|
|
229
244
|
throw new Error(`Invalid run group: ${runGroup}`);
|
|
230
245
|
const competitors = options.competeInstalled && options.agent
|
|
@@ -236,13 +251,28 @@ async function runEvalTrigger(options, bench, skill, trials, log) {
|
|
|
236
251
|
const competeLine = competitors.length === 0
|
|
237
252
|
? 'Compete : alone (recall is an upper bound)'
|
|
238
253
|
: `Compete : ${competitors.map((entry) => entry.name).join(', ')}`;
|
|
254
|
+
const installedFingerprint = collectInstalledSkillFingerprint(skill.sourceDir);
|
|
255
|
+
const competition = { mode: competitors.length ? 'installed' : 'alone', skills: competitors };
|
|
256
|
+
options.onPlan?.({ mode: 'trigger', target: { kind: 'skill', name: skill.name, sourceDir: skill.sourceDir,
|
|
257
|
+
sha256: skill.sha256, files: skill.files }, baseline: null,
|
|
258
|
+
bench: { name: bench.name, dir: bench.dir, sha256: bench.contentSha256, taskIds: bench.tasks.map(task => task.id) },
|
|
259
|
+
executor: executor?.describe() ?? null, judge: null, inputMode: 'workspace', installDir: installDir ?? null,
|
|
260
|
+
trials, plannedCalls, maxCalls, outputDir: join(runsRoot, runGroup),
|
|
261
|
+
agentPreflight, casePreflight: { ...CASE_PREFLIGHT_POLICY, status: 'pending' }, inputSnapshot: { ...INPUT_SNAPSHOT_POLICY },
|
|
262
|
+
executorTimeoutSeconds, ...(spendingBudget ? { spendingBudget } : {}),
|
|
263
|
+
installedFingerprint: { sha256: installedFingerprint.sha256, files: installedFingerprint.files }, competition, detection });
|
|
239
264
|
if (options.dryRun) {
|
|
240
265
|
log(renderTriggerPlan(bench, skill, executor, trials, runsRoot, runGroup, installDir));
|
|
266
|
+
log(renderAgentEnvironment(agentPreflight));
|
|
241
267
|
log('Case preflight: pending; required before execution. Dry run does not execute verifiers or oracles.');
|
|
242
268
|
log(competeLine);
|
|
243
269
|
log(`Calls : ${plannedCalls} planned; ceiling ${maxCalls} (agent calls only)`);
|
|
270
|
+
log(`Agent deadline: ${executorTimeoutSeconds}s per invocation`);
|
|
271
|
+
if (spendingBudget)
|
|
272
|
+
log(`Spending stop lines: ${JSON.stringify(spendingBudget)}; checked between calls, in-flight overshoot remains possible`);
|
|
244
273
|
return null;
|
|
245
274
|
}
|
|
275
|
+
assertAgentEnvironment(agentPreflight);
|
|
246
276
|
if (!executor) {
|
|
247
277
|
throw new Error('No executor available for trigger mode; pass --agent.');
|
|
248
278
|
}
|
|
@@ -254,10 +284,19 @@ async function runEvalTrigger(options, bench, skill, trials, log) {
|
|
|
254
284
|
throw new Error(`Run group directory already exists: ${join(runsRoot, runGroup)}`);
|
|
255
285
|
const eligible = { ...bench, tasks: bench.tasks.filter(t => t.shouldTrigger !== undefined) };
|
|
256
286
|
const casePreflight = await checkEvalCases(eligible, [skill], false, log);
|
|
287
|
+
assertAgentEnvironmentUnchanged(agentPreflight, inspect());
|
|
288
|
+
if (collectInstalledSkillFingerprint(skill.sourceDir).sha256 !== installedFingerprint.sha256 ||
|
|
289
|
+
competitors.some(entry => collectInstalledSkillFingerprint(entry.sourceDir).sha256 !== entry.sha256)) {
|
|
290
|
+
throw new Error('Installed Skill resources changed during case preflight; create a fresh plan. No calls started.');
|
|
291
|
+
}
|
|
257
292
|
throwIfEvaluationInterrupted();
|
|
258
293
|
log(renderTriggerPlan(bench, skill, executor, trials, runsRoot, runGroup, installDir).replace(' (dry run)', '').replace(' (not created)', '').replace('Dry run — nothing was written.', `Calls : ${plannedCalls} planned; ceiling ${maxCalls}`));
|
|
259
294
|
log(competeLine);
|
|
260
|
-
|
|
295
|
+
log(renderAgentEnvironment(agentPreflight));
|
|
296
|
+
const session = sessionFor(options, bench, skill, trials, runsRoot, runGroup, ['installed'], plannedCalls, { mode: 'trigger', trials, executor: executor.describe(), casePreflight, agentPreflight,
|
|
297
|
+
skillInstallDir: installDir, executorTimeoutSeconds, competition, detection,
|
|
298
|
+
...(options.reviewedPlan ? { reviewedPlan: options.reviewedPlan } : {}),
|
|
299
|
+
...(spendingBudget ? { spendingBudget } : {}) });
|
|
261
300
|
let manifest;
|
|
262
301
|
try {
|
|
263
302
|
manifest = await runTriggerExperiment({
|
|
@@ -271,6 +310,7 @@ async function runEvalTrigger(options, bench, skill, trials, log) {
|
|
|
271
310
|
skillInstallDir: installDir,
|
|
272
311
|
competitors,
|
|
273
312
|
detection,
|
|
313
|
+
...(spendingBudget ? { spendingBudget } : {}),
|
|
274
314
|
log,
|
|
275
315
|
});
|
|
276
316
|
throwIfEvaluationInterrupted();
|
|
@@ -285,14 +325,8 @@ async function runEvalTrigger(options, bench, skill, trials, log) {
|
|
|
285
325
|
});
|
|
286
326
|
}
|
|
287
327
|
export async function runEval(options) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const executorTimeoutSeconds = options.executorTimeoutSeconds ?? DEFAULT_CLI_TIMEOUT_MS / 1000;
|
|
291
|
-
if (!Number.isSafeInteger(executorTimeoutSeconds) || executorTimeoutSeconds < 1 || executorTimeoutSeconds > 3600) {
|
|
292
|
-
throw new Error('executorTimeoutSeconds must be an integer between 1 and 3600.');
|
|
293
|
-
}
|
|
294
|
-
if (options.executorTimeoutSeconds !== undefined && !options.agent && !options.executor)
|
|
295
|
-
throw new Error('executorTimeoutSeconds requires a CLI agent.');
|
|
328
|
+
const executorTimeoutSeconds = parseExecutorTimeoutSeconds(options.executorTimeoutSeconds ??
|
|
329
|
+
(!options.agent && !options.executor ? DEFAULT_API_TIMEOUT_MS / 1000 : undefined));
|
|
296
330
|
const log = options.log ?? ((msg) => console.log(msg));
|
|
297
331
|
const installed = options.mode === 'installed';
|
|
298
332
|
if (options.baselineSkillPath !== undefined && !installed) {
|
|
@@ -303,9 +337,6 @@ export async function runEval(options) {
|
|
|
303
337
|
}
|
|
304
338
|
const inputMode = options.inputMode ?? (installed ? 'workspace' : 'snapshot');
|
|
305
339
|
assertInputModeSupported(inputMode, null);
|
|
306
|
-
if (inputMode === 'workspace' && !options.agent && !options.executor) {
|
|
307
|
-
throw new Error('workspace input requires --agent <id> for a CLI executor; API keys do not provide filesystem access.');
|
|
308
|
-
}
|
|
309
340
|
if (options.mode === 'trigger' && options.inputMode !== undefined) {
|
|
310
341
|
throw new Error('--input applies only to paired modes; trigger mode already presents files on disk.');
|
|
311
342
|
}
|
|
@@ -341,8 +372,6 @@ export async function runEval(options) {
|
|
|
341
372
|
assertNativeDiffFixtures(bench);
|
|
342
373
|
}
|
|
343
374
|
if ((options.mode ?? 'inject') === 'trigger') {
|
|
344
|
-
if (options.executorTimeoutSeconds !== undefined)
|
|
345
|
-
throw new Error('executorTimeoutSeconds is only available for paired experiments.');
|
|
346
375
|
if (options.pairOrder !== undefined)
|
|
347
376
|
throw new Error('pairOrder is only available for paired experiments.');
|
|
348
377
|
if (target.kind !== 'skill') {
|
|
@@ -350,9 +379,6 @@ export async function runEval(options) {
|
|
|
350
379
|
}
|
|
351
380
|
return runEvalTrigger(options, bench, target, trials, log);
|
|
352
381
|
}
|
|
353
|
-
if (target.kind !== 'skill' && !options.agent && !options.executor) {
|
|
354
|
-
throw new Error(`${target.kind} experiments require --agent because API executors do not load project configuration files.`);
|
|
355
|
-
}
|
|
356
382
|
if (target.kind !== 'skill' && options.agent) {
|
|
357
383
|
const agent = getAgent(options.agent);
|
|
358
384
|
const expected = (target.kind === 'mcp' ? agent.mcp.projectFiles : agent.rules.projectFiles)
|
|
@@ -372,23 +398,43 @@ export async function runEval(options) {
|
|
|
372
398
|
}
|
|
373
399
|
}
|
|
374
400
|
let executor = null;
|
|
401
|
+
let resolutionError;
|
|
375
402
|
try {
|
|
376
|
-
executor = options.executor ?? resolveExecutor(options.agent, target, installed,
|
|
403
|
+
executor = options.executor ?? resolveExecutor(options.agent, target, installed, executorTimeoutSeconds);
|
|
377
404
|
}
|
|
378
405
|
catch (error) {
|
|
379
|
-
|
|
380
|
-
throw error;
|
|
406
|
+
resolutionError = error.message;
|
|
381
407
|
log(`Note: ${error.message}`);
|
|
382
408
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
409
|
+
let capabilityError;
|
|
410
|
+
try {
|
|
411
|
+
if (inputMode === 'workspace' && !options.agent && !options.executor) {
|
|
412
|
+
throw new Error('workspace input requires --agent <id> for a CLI executor; API keys do not provide filesystem access.');
|
|
413
|
+
}
|
|
414
|
+
if (target.kind !== 'skill' && !options.agent && !options.executor) {
|
|
415
|
+
throw new Error(`${target.kind} experiments require --agent because API executors do not load project configuration files.`);
|
|
416
|
+
}
|
|
417
|
+
assertExecutorSupportsBench(executor, bench);
|
|
418
|
+
assertInputModeSupported(inputMode, executor);
|
|
419
|
+
if (target.kind !== 'skill' && executor?.describe().kind === 'api') {
|
|
420
|
+
throw new Error(`${target.kind} experiments require a CLI executor; API executors cannot load project configuration files.`);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
capabilityError = error.message;
|
|
425
|
+
}
|
|
426
|
+
let judge = null, judgeError;
|
|
427
|
+
try {
|
|
428
|
+
judge = options.judgeExecutor !== undefined ? options.judgeExecutor : resolveJudge(options.judgeAgent, executorTimeoutSeconds);
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
judgeError = error.message;
|
|
387
432
|
}
|
|
388
|
-
const
|
|
433
|
+
const inspect = () => inspectEvalAgent(options, target, executor, judge, capabilityError, resolutionError, judgeError);
|
|
434
|
+
const agentPreflight = inspect();
|
|
435
|
+
if (capabilityError)
|
|
436
|
+
assertAgentEnvironment(agentPreflight);
|
|
389
437
|
const spendingBudget = options.spendingBudget === undefined ? undefined : parseSpendingBudget(options.spendingBudget);
|
|
390
|
-
if (spendingBudget && judge)
|
|
391
|
-
throw new Error('spendingBudget requires a paired evaluation without a judge; judge usage is not covered.');
|
|
392
438
|
if (options.judgeAgent && options.judgeAgent === options.agent) {
|
|
393
439
|
log('Warning: judge and executor are the same agent — self-preference bias risk (docs/metrics.md L4).');
|
|
394
440
|
}
|
|
@@ -396,32 +442,32 @@ export async function runEval(options) {
|
|
|
396
442
|
const runGroup = options.runGroup ?? defaultRunGroup();
|
|
397
443
|
const plannedCalls = bench.tasks.length * trials * (judge ? 4 : 2);
|
|
398
444
|
const maxCalls = validateCallBudget(plannedCalls, options.maxCalls);
|
|
399
|
-
const pairOrder = options.pairOrder
|
|
400
|
-
if (pairOrder !== 'baseline-first' && pairOrder !== 'balanced')
|
|
401
|
-
throw new Error('pairOrder must be baseline-first or balanced.');
|
|
445
|
+
const pairOrder = parsePairOrder(options.pairOrder);
|
|
402
446
|
if (!RUN_GROUP_PATTERN.test(runGroup))
|
|
403
447
|
throw new Error(`Invalid run group: ${runGroup}`);
|
|
404
448
|
options.onPlan?.({
|
|
449
|
+
mode: installed ? 'installed' : 'inject',
|
|
450
|
+
agentPreflight,
|
|
405
451
|
casePreflight: { ...CASE_PREFLIGHT_POLICY, status: 'pending' },
|
|
406
452
|
inputSnapshot: { ...INPUT_SNAPSHOT_POLICY },
|
|
407
|
-
target: { name: target.name, sourceDir: target.sourceDir, sha256: target.sha256, files: target.files },
|
|
453
|
+
target: { kind: target.kind, name: target.name, sourceDir: target.sourceDir, sha256: target.sha256, files: target.files },
|
|
408
454
|
baseline: baselineTarget ? { name: baselineTarget.name, sourceDir: baselineTarget.sourceDir, sha256: baselineTarget.sha256, files: baselineTarget.files } : null,
|
|
409
455
|
bench: { name: bench.name, dir: bench.dir, sha256: bench.contentSha256, taskIds: bench.tasks.map(t => t.id) },
|
|
410
|
-
executor: executor
|
|
456
|
+
executor: executor ? withSampling(executor.describe()) : null, judge: judge ? withSampling(judge.describe()) : null, inputMode,
|
|
411
457
|
installDir: skillInstallDir ?? null, trials, plannedCalls, maxCalls, pairOrder,
|
|
412
458
|
...(spendingBudget ? { spendingBudget } : {}),
|
|
413
459
|
...(installed ? { nativeDiffTool: nativeDiffDescriptor() } : {}),
|
|
414
|
-
|
|
460
|
+
executorTimeoutSeconds, outputDir: join(runsRoot, runGroup),
|
|
415
461
|
});
|
|
416
462
|
if (options.dryRun) {
|
|
417
463
|
log(renderPlan(bench, target, executor, judge, trials, runsRoot, runGroup, inputMode, baselineTarget));
|
|
464
|
+
log(renderAgentEnvironment(agentPreflight));
|
|
418
465
|
log('Case preflight: pending; required before execution. Dry run does not execute verifiers or oracles.');
|
|
419
466
|
log(`Calls : ${plannedCalls} planned; ceiling ${maxCalls} (includes both judge orders when enabled)`);
|
|
420
467
|
log(`Pair order: ${pairOrder}; arms remain adjacent`);
|
|
421
468
|
if (spendingBudget)
|
|
422
469
|
log(`Spending stop lines: ${JSON.stringify(spendingBudget)}; checked between calls, in-flight overshoot remains possible`);
|
|
423
|
-
|
|
424
|
-
log(`Agent deadline: ${executorTimeoutSeconds}s per invocation in both arms`);
|
|
470
|
+
log(`Agent deadline: ${executorTimeoutSeconds}s per invocation in both arms`);
|
|
425
471
|
if (skillInstallDir) {
|
|
426
472
|
log('Tool : native untracked-file diff helper in both arms (version 1; environment correction)');
|
|
427
473
|
log('Delivery : complete Skill resources installed ' + (baselineTarget ? 'in both conditions' : 'only in treatment') + ' at ' + skillInstallDir + '/' + target.name);
|
|
@@ -429,6 +475,7 @@ export async function runEval(options) {
|
|
|
429
475
|
}
|
|
430
476
|
return null;
|
|
431
477
|
}
|
|
478
|
+
assertAgentEnvironment(agentPreflight);
|
|
432
479
|
if (!executor) {
|
|
433
480
|
throw new Error('No executor available; pass --agent or set SKILLFIT_API_KEY.');
|
|
434
481
|
}
|
|
@@ -436,12 +483,15 @@ export async function runEval(options) {
|
|
|
436
483
|
if (existsSync(join(runsRoot, runGroup)))
|
|
437
484
|
throw new Error(`Run group directory already exists: ${join(runsRoot, runGroup)}`);
|
|
438
485
|
const casePreflight = await checkEvalCases(bench, [target, ...(baselineTarget ? [baselineTarget] : [])], installed, log);
|
|
486
|
+
assertAgentEnvironmentUnchanged(agentPreflight, inspect());
|
|
439
487
|
throwIfEvaluationInterrupted();
|
|
440
488
|
log(renderPlan(bench, target, executor, judge, trials, runsRoot, runGroup, inputMode, baselineTarget).replace(' (dry run)', '').replace(' (not created)', '').replace('Dry run — nothing was written.', `Calls : ${plannedCalls} planned; ceiling ${maxCalls}`));
|
|
441
|
-
|
|
489
|
+
log(renderAgentEnvironment(agentPreflight));
|
|
490
|
+
const session = sessionFor(options, bench, target, trials, runsRoot, runGroup, ['baseline', 'treatment'], plannedCalls, { mode: installed ? 'installed' : 'inject', inputMode, trials, pairOrder, casePreflight, agentPreflight,
|
|
491
|
+
...(options.reviewedPlan ? { reviewedPlan: options.reviewedPlan } : {}),
|
|
442
492
|
...(spendingBudget ? { spendingBudget } : {}),
|
|
443
493
|
...(installed ? { nativeDiffTool: nativeDiffDescriptor() } : {}),
|
|
444
|
-
|
|
494
|
+
executorTimeoutSeconds, executor: executor.describe(), judge: judge?.describe() ?? null,
|
|
445
495
|
...(options.component ? { component: options.component } : {}),
|
|
446
496
|
...(baselineTarget ? { baselineTarget: { name: baselineTarget.name, sourceDir: baselineTarget.sourceDir, bundleSha256: baselineTarget.sha256, files: baselineTarget.files } } : {}) }, baselineTarget);
|
|
447
497
|
let manifest;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { basename, dirname, join } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { test } from 'node:test';
|
|
8
|
+
import { runBenchCheck, runBenchInit } from './bench.js';
|
|
9
|
+
import { runEval } from './eval.js';
|
|
10
|
+
import { readEvaluationReport } from './evaluation-report.js';
|
|
11
|
+
import { runEvalReport } from './eval-report.js';
|
|
12
|
+
import { exportEvaluation } from './eval-export.js';
|
|
13
|
+
import { ExperimentSession } from '../harness/experiment-session.js';
|
|
14
|
+
import { collectEvaluationTarget } from '../harness/target.js';
|
|
15
|
+
import { loadBench } from '../harness/bench.js';
|
|
16
|
+
import { ExecutorFailure } from '../harness/types.js';
|
|
17
|
+
const CLI = fileURLToPath(new URL('../cli.js', import.meta.url));
|
|
18
|
+
async function fixture(t, ids) {
|
|
19
|
+
const root = mkdtempSync(join(tmpdir(), 'skillfit-report-modes-'));
|
|
20
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
21
|
+
const bench = join(root, 'bench'), skill = join(root, 'skill'), runsRoot = join(root, 'runs');
|
|
22
|
+
await runBenchInit({ dir: bench, yes: true, log: () => { } });
|
|
23
|
+
const path = join(bench, 'bench.json'), body = JSON.parse(readFileSync(path, 'utf8')), original = body.tasks[0];
|
|
24
|
+
body.tasks = ids.map(id => {
|
|
25
|
+
const prompt = `prompts/${id}.md`;
|
|
26
|
+
writeFileSync(join(bench, prompt), `CASE ${id}\nReply with skillfit-ok.\n`);
|
|
27
|
+
return { ...original, id, prompt, promptTrigger: prompt, shouldTrigger: !id.startsWith('neg'),
|
|
28
|
+
...(id === 'pos-fired' ? { triggerClass: 'explicit' } : id === 'pos-missed' ? { triggerClass: 'implicit' } : id === 'pos-unknown' ? { triggerClass: 'contextual' } : {}) };
|
|
29
|
+
});
|
|
30
|
+
writeFileSync(path, JSON.stringify(body));
|
|
31
|
+
mkdirSync(skill);
|
|
32
|
+
writeFileSync(join(skill, 'SKILL.md'), '# Synthetic mode-report test\n');
|
|
33
|
+
let calls = 0;
|
|
34
|
+
const perTask = new Map();
|
|
35
|
+
const executor = { describe: () => ({ kind: 'stub', model: 'offline-report-fixture' }), run: async (_prompt, workdir) => {
|
|
36
|
+
calls++;
|
|
37
|
+
const id = basename(dirname(dirname(workdir))), nth = (perTask.get(id) ?? 0) + 1;
|
|
38
|
+
perTask.set(id, nth);
|
|
39
|
+
if (id === 'neg-error')
|
|
40
|
+
throw new ExecutorFailure('synthetic executor error', { output: 'partial', tokens: { input: 4, output: 1 }, usageStatus: 'partial' });
|
|
41
|
+
return { output: id === 'hard' || (id === 'mixed' && nth === 2) ? 'wrong' : 'skillfit-ok',
|
|
42
|
+
tokens: { input: 10, cachedInput: 0, output: 1 },
|
|
43
|
+
...(id === 'pos-unknown' ? {} : { skillTriggered: id === 'pos-fired' || id === 'neg-fired' }) };
|
|
44
|
+
} };
|
|
45
|
+
const cli = (path, flags = []) => spawnSync(process.execPath, [CLI, 'report', 'eval', path, ...flags], { encoding: 'utf8', timeout: 30_000 });
|
|
46
|
+
return { root, bench, skill, runsRoot, executor, calls: () => calls, cli };
|
|
47
|
+
}
|
|
48
|
+
function observedFiles(run, final) {
|
|
49
|
+
return [final, '_plan.json', '_session.json', '_artifacts.json'].map(path => readFileSync(join(run, path), 'utf8'));
|
|
50
|
+
}
|
|
51
|
+
test('completed native calibration uses its own summary, state and difficulty metrics in both formats', async (t) => {
|
|
52
|
+
const f = await fixture(t, ['easy', 'hard', 'mixed']);
|
|
53
|
+
await runBenchCheck({ dir: f.bench, calibrate: { executor: f.executor, trials: 2, maxCalls: 6, runsRoot: f.runsRoot, runGroup: 'calibration' }, log: () => { } });
|
|
54
|
+
const run = join(f.runsRoot, 'calibration'), before = observedFiles(run, '_calibration.json');
|
|
55
|
+
const report = await readEvaluationReport(run);
|
|
56
|
+
assert.ok('evaluationType' in report && report.evaluationType === 'calibration');
|
|
57
|
+
assert.equal(report.status, 'completed');
|
|
58
|
+
assert.equal(report.kind, 'skillfit.calibration-report');
|
|
59
|
+
assert.deepEqual(report.summary?.tasks.map(t => t.difficulty), ['saturated', 'floor', 'discriminative']);
|
|
60
|
+
assert.deepEqual(report.summary?.metrics, { taskCount: 3, measuredTasks: 3, discriminativeTasks: 1, passes: 3, completed: 6, errors: 0, baselinePassRate: 0.5 });
|
|
61
|
+
assert.equal(report.usage?.metrics.input.knownTotal, 60);
|
|
62
|
+
assert.equal(report.usage?.metrics.cachedInput.knownTotal, 0);
|
|
63
|
+
assert.equal(report.usage?.metrics.cachedInput.coverage.final, 6);
|
|
64
|
+
assert.equal(report.acceptance.eligibleForUpgrade, false);
|
|
65
|
+
assert.equal(report.acceptance.automaticUpgrade, false);
|
|
66
|
+
assert.equal(report.evidence.verified, true);
|
|
67
|
+
assert.equal(report.evidence.scope, 'single-arm-native');
|
|
68
|
+
const human = f.cli(run), json = f.cli(run, ['--json']), file = f.cli(join(run, '_calibration.json'));
|
|
69
|
+
for (const output of [human, json, file])
|
|
70
|
+
assert.equal(output.status, 0, output.stderr);
|
|
71
|
+
assert.equal(JSON.parse(json.stdout).status, 'completed');
|
|
72
|
+
assert.equal(human.stdout, file.stdout);
|
|
73
|
+
assert.match(human.stdout, /Baseline pass rate: 3\/6 \(50.0%\)/);
|
|
74
|
+
assert.match(human.stdout, /discriminative tasks: 1\/3/);
|
|
75
|
+
assert.match(human.stdout, /saturated/);
|
|
76
|
+
assert.match(human.stdout, /floor/);
|
|
77
|
+
assert.doesNotMatch(human.stdout, /Overall verdict|State: stopped|McNemar/);
|
|
78
|
+
assert.equal((await exportEvaluation(run, join(f.root, 'export'), { log: () => { } })).status, 'planned');
|
|
79
|
+
assert.equal(existsSync(join(f.root, 'export')), false);
|
|
80
|
+
assert.deepEqual(observedFiles(run, '_calibration.json'), before);
|
|
81
|
+
assert.equal(f.calls(), 6);
|
|
82
|
+
rmSync(join(run, 'easy/baseline/trial-1/_result.json'));
|
|
83
|
+
const missing = await readEvaluationReport(run);
|
|
84
|
+
assert.ok('evaluationType' in missing);
|
|
85
|
+
assert.equal(missing.usage?.invocationsWithUnknownReceipts, 1);
|
|
86
|
+
assert.equal(missing.usage?.metrics.input.coverage.unknown, 1);
|
|
87
|
+
assert.equal(missing.acceptance.eligibleForUpgrade, false);
|
|
88
|
+
});
|
|
89
|
+
test('native trigger reports retain rates, Wilson intervals, classes, unknowns and errors without paired adoption', async (t) => {
|
|
90
|
+
const f = await fixture(t, ['pos-fired', 'pos-missed', 'pos-unknown', 'neg-fired', 'neg-quiet', 'neg-error']);
|
|
91
|
+
await runEval({ skillPath: f.skill, bench: f.bench, agent: 'codex', mode: 'trigger', executor: f.executor,
|
|
92
|
+
trials: 1, maxCalls: 6, runsRoot: f.runsRoot, runGroup: 'trigger', dryRun: false, yes: true, log: () => { } });
|
|
93
|
+
const run = join(f.runsRoot, 'trigger'), before = observedFiles(run, 'manifest.json');
|
|
94
|
+
const saved = JSON.parse(before[0]);
|
|
95
|
+
const report = await readEvaluationReport(run);
|
|
96
|
+
assert.ok('evaluationType' in report && report.evaluationType === 'trigger');
|
|
97
|
+
assert.equal(report.status, 'stopped');
|
|
98
|
+
assert.equal(report.kind, 'skillfit.trigger-report');
|
|
99
|
+
assert.deepEqual(report.summary?.metrics, saved.metrics);
|
|
100
|
+
assert.equal(report.summary?.metrics.recall, 0.5);
|
|
101
|
+
assert.equal(report.summary?.metrics.falseTriggerRate, 0.5);
|
|
102
|
+
assert.equal(report.summary?.metrics.precision, 0.5);
|
|
103
|
+
assert.equal(report.summary?.metrics.f1, 0.5);
|
|
104
|
+
assert.equal(report.summary?.tasks[2]?.unknown, 1);
|
|
105
|
+
assert.equal(report.summary?.tasks[5]?.errors, 1);
|
|
106
|
+
assert.equal(report.acceptance.eligibleForUpgrade, false);
|
|
107
|
+
assert.equal(report.acceptance.automaticUpgrade, false);
|
|
108
|
+
const human = f.cli(run), json = f.cli(join(run, 'manifest.json'), ['--json']);
|
|
109
|
+
assert.equal(human.status, 0, human.stderr);
|
|
110
|
+
assert.equal(json.status, 0, json.stderr);
|
|
111
|
+
assert.equal(JSON.parse(json.stdout).evaluationType, 'trigger');
|
|
112
|
+
assert.equal(JSON.parse(json.stdout).status, 'stopped');
|
|
113
|
+
for (const label of ['Recall: 50.0%', 'False-trigger rate: 50.0%', 'Precision: 50.0%', 'F1: 0.500', 'explicit recall:', 'implicit recall:', 'contextual recall: n/a', 'SKILL.md read', 'upper bound', 'Unknown | Errors'])
|
|
114
|
+
assert.ok(human.stdout.includes(label), label);
|
|
115
|
+
assert.doesNotMatch(human.stdout, /McNemar|Overall verdict|Installation decision/);
|
|
116
|
+
assert.deepEqual(observedFiles(run, 'manifest.json'), before);
|
|
117
|
+
assert.equal(f.calls(), 6);
|
|
118
|
+
});
|
|
119
|
+
test('completed trigger and standalone historical summaries preserve zero denominators and unknown provenance', async (t) => {
|
|
120
|
+
const f = await fixture(t, ['pos-missed', 'pos-unknown']);
|
|
121
|
+
await runEval({ skillPath: f.skill, bench: f.bench, mode: 'trigger', skillInstallDir: '.test-skills', executor: f.executor,
|
|
122
|
+
trials: 1, maxCalls: 2, runsRoot: f.runsRoot, runGroup: 'trigger', dryRun: false, yes: true, log: () => { } });
|
|
123
|
+
const run = join(f.runsRoot, 'trigger'), native = await readEvaluationReport(run);
|
|
124
|
+
assert.ok('evaluationType' in native && native.evaluationType === 'trigger');
|
|
125
|
+
assert.equal(native.status, 'completed');
|
|
126
|
+
assert.equal(native.summary?.metrics.recall, 0);
|
|
127
|
+
assert.equal(native.summary?.metrics.falseTriggerRate, null);
|
|
128
|
+
assert.equal(native.summary?.metrics.precision, null);
|
|
129
|
+
assert.equal(native.summary?.metrics.f1, null);
|
|
130
|
+
const value = JSON.parse(readFileSync(join(run, 'manifest.json'), 'utf8'));
|
|
131
|
+
delete value.experiment;
|
|
132
|
+
delete value.metrics.classRecall;
|
|
133
|
+
delete value.metrics.precisionCi95;
|
|
134
|
+
const standalone = join(f.root, 'historical.json');
|
|
135
|
+
writeFileSync(standalone, JSON.stringify(value));
|
|
136
|
+
const human = [];
|
|
137
|
+
await runEvalReport(standalone, line => human.push(line));
|
|
138
|
+
assert.match(human[0], /State: reported/);
|
|
139
|
+
assert.match(human[0], /False-trigger rate: n\/a/);
|
|
140
|
+
assert.match(human[0], /Precision: n\/a/);
|
|
141
|
+
assert.match(human[0], /F1: n\/a/);
|
|
142
|
+
assert.match(human[0], /Eligible for upgrade: no/);
|
|
143
|
+
assert.equal(f.calls(), 2);
|
|
144
|
+
});
|
|
145
|
+
test('standalone calibration excludes ungraded errors and leaves zero-completion difficulty unknown', async (t) => {
|
|
146
|
+
const root = mkdtempSync(join(tmpdir(), 'skillfit-calibration-summary-'));
|
|
147
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
148
|
+
const path = join(root, 'renamed.json');
|
|
149
|
+
writeFileSync(path, JSON.stringify({ schemaVersion: 1, runGroup: 'historical', inputMode: 'snapshot', trials: 2,
|
|
150
|
+
tasks: [{ id: 'one', passes: 1, completed: 1, errors: 1 }, { id: 'none', passes: 0, completed: 0, errors: 2 }] }));
|
|
151
|
+
const report = await readEvaluationReport(path);
|
|
152
|
+
assert.ok('evaluationType' in report && report.evaluationType === 'calibration');
|
|
153
|
+
assert.equal(report.status, 'reported');
|
|
154
|
+
assert.equal(report.summary?.metrics.baselinePassRate, 1);
|
|
155
|
+
assert.equal(report.summary?.metrics.errors, 3);
|
|
156
|
+
assert.equal(report.summary?.tasks[1]?.passRate, null);
|
|
157
|
+
assert.equal(report.summary?.tasks[1]?.difficulty, 'unmeasured');
|
|
158
|
+
});
|
|
159
|
+
test('stopped and unfinished single-arm sessions never fabricate final metrics or completion', async (t) => {
|
|
160
|
+
for (const mode of ['calibration', 'trigger'])
|
|
161
|
+
await t.test(mode, async (t) => {
|
|
162
|
+
const f = await fixture(t, ['easy']);
|
|
163
|
+
const run = join(f.runsRoot, mode);
|
|
164
|
+
const session = new ExperimentSession({ bench: loadBench(f.bench), target: collectEvaluationTarget(f.skill), groupDir: run,
|
|
165
|
+
workspaces: [join(run, 'easy/baseline/trial-1')], plannedCalls: 1, maxCalls: 1, injected: true, details: { mode } });
|
|
166
|
+
session.finish(new Error('synthetic cancellation'));
|
|
167
|
+
const stopped = await readEvaluationReport(run);
|
|
168
|
+
assert.ok('evaluationType' in stopped);
|
|
169
|
+
assert.equal(stopped.status, 'stopped');
|
|
170
|
+
assert.equal(stopped.summary, null);
|
|
171
|
+
assert.equal(stopped.acceptance.eligibleForUpgrade, false);
|
|
172
|
+
const human = f.cli(run);
|
|
173
|
+
assert.equal(human.status, 0, human.stderr);
|
|
174
|
+
assert.match(human.stdout, /Metrics are unavailable/);
|
|
175
|
+
rmSync(join(run, '_session.json'));
|
|
176
|
+
const unfinished = await readEvaluationReport(run);
|
|
177
|
+
assert.equal(unfinished.status, 'incomplete');
|
|
178
|
+
assert.equal(f.calls(), 0);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
test('single-arm reports reject contradictory counts, metrics, schemas, session states and ignored options', async (t) => {
|
|
182
|
+
const f = await fixture(t, ['pos-fired', 'neg-quiet']);
|
|
183
|
+
await runEval({ skillPath: f.skill, bench: f.bench, mode: 'trigger', skillInstallDir: '.test-skills', executor: f.executor,
|
|
184
|
+
trials: 1, maxCalls: 2, runsRoot: f.runsRoot, runGroup: 'trigger', dryRun: false, yes: true, log: () => { } });
|
|
185
|
+
const run = join(f.runsRoot, 'trigger'), path = join(run, 'manifest.json'), original = readFileSync(path, 'utf8');
|
|
186
|
+
const scenarios = [
|
|
187
|
+
(v) => { v.tasks[0].fired = 2; },
|
|
188
|
+
(v) => { v.tasks[0].runs = -1; },
|
|
189
|
+
(v) => { v.tasks[0].unknown = 0.5; },
|
|
190
|
+
(v) => { v.tasks[1].id = v.tasks[0].id; },
|
|
191
|
+
(v) => { v.metrics.recall = 0; },
|
|
192
|
+
(v) => { v.metrics.recallCi95 = { lo: 0, hi: 0 }; },
|
|
193
|
+
(v) => { v.schemaVersion = 2; },
|
|
194
|
+
(v) => { v.experiment.status = 'incomplete'; },
|
|
195
|
+
];
|
|
196
|
+
for (const change of scenarios) {
|
|
197
|
+
const value = JSON.parse(original);
|
|
198
|
+
change(value);
|
|
199
|
+
writeFileSync(path, JSON.stringify(value));
|
|
200
|
+
await assert.rejects(() => readEvaluationReport(run));
|
|
201
|
+
}
|
|
202
|
+
writeFileSync(path, original);
|
|
203
|
+
for (const json of [false, true]) {
|
|
204
|
+
const replay = f.cli(run, ['--replay', ...(json ? ['--json'] : [])]);
|
|
205
|
+
assert.equal(replay.status, 0, replay.stderr);
|
|
206
|
+
if (json) {
|
|
207
|
+
const result = JSON.parse(replay.stdout);
|
|
208
|
+
assert.equal(result.evidence.verified, true);
|
|
209
|
+
assert.equal(result.evidence.replayedDeliveries, 2);
|
|
210
|
+
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
for (const flags of [['--policy', 'missing.json'], ['--records', run], ['--bench', f.bench]]) {
|
|
214
|
+
for (const json of [false, true]) {
|
|
215
|
+
const result = f.cli(run, [...flags, ...(json ? ['--json'] : [])]);
|
|
216
|
+
assert.equal(result.status, json ? 2 : 1);
|
|
217
|
+
if (json) {
|
|
218
|
+
const failure = JSON.parse(result.stdout);
|
|
219
|
+
assert.equal(failure.status, 'error');
|
|
220
|
+
assert.equal(failure.acceptance.eligibleForUpgrade, false);
|
|
221
|
+
}
|
|
222
|
+
else
|
|
223
|
+
assert.match(result.stderr, /do not support paired|only used with --replay/);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
copyFileSync(path, join(run, '_calibration.json'));
|
|
227
|
+
await assert.rejects(() => readEvaluationReport(run), /Ambiguous run/);
|
|
228
|
+
assert.equal(f.calls(), 2);
|
|
229
|
+
});
|
|
230
|
+
test('invalid calibration summaries fail rather than being mislabeled stopped or interpreted as trigger data', async (t) => {
|
|
231
|
+
const root = mkdtempSync(join(tmpdir(), 'skillfit-invalid-calibration-'));
|
|
232
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
233
|
+
const path = join(root, '_calibration.json'), value = { schemaVersion: 1, runGroup: 'calibration', inputMode: 'workspace', trials: 2,
|
|
234
|
+
tasks: [{ id: 'one', completed: 1, errors: 1, passes: 1 }] };
|
|
235
|
+
for (const change of [(v) => { v.tasks[0].passes = 2; }, (v) => { v.tasks[0].errors = 2; },
|
|
236
|
+
(v) => { v.tasks[0].completed = null; }, (v) => { v.inputMode = 'unknown'; }, (v) => { v.tasks = []; }]) {
|
|
237
|
+
const changed = structuredClone(value);
|
|
238
|
+
change(changed);
|
|
239
|
+
writeFileSync(path, JSON.stringify(changed));
|
|
240
|
+
await assert.rejects(() => readEvaluationReport(path));
|
|
241
|
+
}
|
|
242
|
+
assert.ok(!existsSync(join(root, 'manifest.json')));
|
|
243
|
+
});
|