skillfit 0.10.1 → 0.12.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 +43 -8
- package/README.zh-CN.md +43 -8
- package/benches/README.md +6 -2
- package/dist/cli.js +153 -37
- package/dist/cli.test.js +94 -0
- package/dist/commands/bench-calibration.js +201 -0
- package/dist/commands/bench-calibration.test.js +237 -0
- package/dist/commands/bench-check-json.test.js +24 -3
- package/dist/commands/bench-draft.js +167 -0
- package/dist/commands/bench-draft.test.js +168 -0
- package/dist/commands/bench-manage.js +5 -4
- package/dist/commands/bench-source.js +101 -0
- package/dist/commands/bench-source.test.js +84 -0
- package/dist/commands/bench.js +227 -245
- package/dist/commands/bench.test.js +7 -3
- package/dist/commands/calibration-cli.test.js +145 -0
- package/dist/commands/eval-agent-preflight.test.js +269 -0
- package/dist/commands/eval-api-failure.test.js +46 -0
- package/dist/commands/eval-cli-usage.test.js +75 -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-interruption.test.js +26 -1
- package/dist/commands/eval-layout.test.js +126 -0
- 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 +113 -88
- package/dist/commands/evaluation-report.js +5 -0
- package/dist/commands/evaluation-report.test.js +243 -0
- package/dist/commands/npm-first-run.test.js +74 -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 +196 -0
- package/dist/harness/bench-location.js +29 -0
- package/dist/harness/bench-location.test.js +33 -0
- package/dist/harness/bench.js +10 -4
- package/dist/harness/command.js +49 -0
- package/dist/harness/eval-audit.js +162 -17
- 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/evaluation-layout.js +30 -0
- package/dist/harness/executors/api.js +24 -10
- package/dist/harness/executors/api.test.js +57 -0
- package/dist/harness/executors/cli.js +15 -25
- package/dist/harness/executors/cli.test.js +33 -2
- package/dist/harness/experiment-session.js +23 -25
- package/dist/harness/experiment-session.test.js +8 -0
- package/dist/harness/hash.js +3 -1
- 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 +44 -33
- package/dist/harness/runner.test.js +23 -0
- package/dist/harness/single-arm-audit.js +436 -0
- package/dist/harness/trigger.js +22 -4
- package/dist/harness/trigger.test.js +12 -0
- package/dist/harness/verifier-error.js +65 -0
- package/dist/harness/verifier-timeout.js +8 -0
- package/dist/harness/verifier-timeout.test.js +76 -0
- package/dist/harness/verifier.test.js +128 -0
- package/docs/bench-authoring.md +57 -12
- package/docs/bench-check-json.md +28 -5
- package/docs/bench-drafting.md +75 -0
- package/docs/case-management.md +12 -1
- package/docs/eval-agent-preflight.md +114 -0
- package/docs/eval-case-preflight.md +5 -0
- package/docs/eval-component.md +38 -10
- package/docs/eval-costs.md +70 -0
- package/docs/eval-planning.md +167 -0
- package/docs/evaluation-input-snapshots.md +22 -5
- 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 +75 -3
- package/docs/growth-roadmap-2026-10.md +51 -10
- package/docs/metrics.md +40 -3
- package/docs/plans/2026-10-17-workflow-foundations.md +99 -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-ci-registry-install.json +130 -0
- package/docs/releases/0.11.0-feature-smoke.json +1576 -0
- package/docs/releases/0.11.0-feature-smoke.mjs +224 -0
- package/docs/releases/0.11.0-local-attempt-1.json +24 -0
- package/docs/releases/0.11.0-local-attempt-1.log +19 -0
- package/docs/releases/0.11.0-local-registry-install.json +25 -0
- package/docs/releases/0.11.0-registry-metadata.json +33 -0
- package/docs/releases/0.11.0-signatures.txt +12 -0
- package/docs/releases/0.11.0-verification.json +95 -0
- package/docs/releases/0.11.0.md +90 -0
- package/docs/releases/0.12.0-feature-smoke.mjs +73 -0
- package/docs/releases/0.12.0.md +68 -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 +108 -0
- package/package.json +1 -1
- package/skills/skillfit/SKILL.md +61 -8
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { test } from 'node:test';
|
|
8
|
+
import { runBenchInit, runBenchCalibration, prepareBenchCalibration } from './bench.js';
|
|
9
|
+
import { runEval } from './eval.js';
|
|
10
|
+
import { runEvalCli } from './eval-cli.js';
|
|
11
|
+
import { readEvaluationReport } from './evaluation-report.js';
|
|
12
|
+
import { exportEvaluation } from './eval-export.js';
|
|
13
|
+
import { loadBench } from '../harness/bench.js';
|
|
14
|
+
import { hashFileSet, listFilesRecursive } from '../harness/hash.js';
|
|
15
|
+
import { assertEvaluationOutputLayout } from '../harness/evaluation-layout.js';
|
|
16
|
+
async function fixture(t) {
|
|
17
|
+
const root = mkdtempSync(join(tmpdir(), 'skillfit-layout-'));
|
|
18
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
19
|
+
const bench = join(root, 'bench'), skill = join(root, 'skill'), old = join(root, 'old'), home = join(root, 'home');
|
|
20
|
+
await runBenchInit({ dir: bench, yes: true, log: () => { } });
|
|
21
|
+
for (const [dir, body] of [[skill, 'new'], [old, 'old']]) {
|
|
22
|
+
mkdirSync(dir);
|
|
23
|
+
writeFileSync(join(dir, 'SKILL.md'), `---\nname: layout-skill\ndescription: Offline layout regression.\n---\n${body}\n`);
|
|
24
|
+
}
|
|
25
|
+
mkdirSync(home);
|
|
26
|
+
const definition = JSON.parse(readFileSync(join(bench, 'bench.json'), 'utf8'));
|
|
27
|
+
definition.tasks[0].shouldTrigger = true;
|
|
28
|
+
writeFileSync(join(bench, 'bench.json'), JSON.stringify(definition));
|
|
29
|
+
let calls = 0;
|
|
30
|
+
const base = { skillPath: skill, bench, agent: 'codex', trials: 1, maxCalls: 2, dryRun: false, yes: true,
|
|
31
|
+
runsRoot: join(root, 'runs'), runGroup: 'study', judgeExecutor: null, log: () => { },
|
|
32
|
+
sessionOptions: { homeDir: home, env: {}, versionProbe: () => null },
|
|
33
|
+
executor: { describe: () => ({ kind: 'cli', model: 'offline-layout', detail: 'Injected offline test executor.' }), run: async () => {
|
|
34
|
+
calls++;
|
|
35
|
+
return { output: 'skillfit-ok', skillTriggered: true, tokens: { input: 10, cachedInput: 2, output: 3 } };
|
|
36
|
+
} } };
|
|
37
|
+
return { root, bench, skill, old, base, calls: () => calls };
|
|
38
|
+
}
|
|
39
|
+
test('bench Git directories/worktree files do not change input hashes; real task bytes still do', async (t) => {
|
|
40
|
+
const f = await fixture(t), original = loadBench(f.bench).contentSha256;
|
|
41
|
+
assert.equal(original, hashFileSet(f.bench, listFilesRecursive(f.bench)), 'Git-free fingerprints keep their previous meaning.');
|
|
42
|
+
mkdirSync(join(f.bench, '.git'));
|
|
43
|
+
writeFileSync(join(f.bench, '.git', 'HEAD'), 'ref: refs/heads/main\n');
|
|
44
|
+
const nested = join(f.bench, 'fixtures', 'example-task', '.git');
|
|
45
|
+
writeFileSync(nested, 'gitdir: /unread-worktree-metadata\n');
|
|
46
|
+
assert.equal(loadBench(f.bench).contentSha256, original);
|
|
47
|
+
writeFileSync(join(f.bench, '.git', 'HEAD'), 'ref: refs/heads/other\n');
|
|
48
|
+
assert.equal(loadBench(f.bench).contentSha256, original);
|
|
49
|
+
rmSync(join(f.bench, '.git'), { recursive: true });
|
|
50
|
+
writeFileSync(join(f.bench, '.git'), 'gitdir: /unread-worktree-metadata\n');
|
|
51
|
+
assert.equal(loadBench(f.bench).contentSha256, original);
|
|
52
|
+
writeFileSync(join(f.bench, 'prompts', 'example-task.md'), 'Changed actual task.');
|
|
53
|
+
assert.notEqual(loadBench(f.bench).contentSha256, original);
|
|
54
|
+
const definition = JSON.parse(readFileSync(join(f.bench, 'bench.json'), 'utf8'));
|
|
55
|
+
definition.tasks[0].prompt = '.git';
|
|
56
|
+
writeFileSync(join(f.bench, 'bench.json'), JSON.stringify(definition));
|
|
57
|
+
assert.throws(() => loadBench(f.bench), /cannot reference Git metadata/);
|
|
58
|
+
});
|
|
59
|
+
for (const mode of ['inject', 'installed', 'trigger', 'calibration'])
|
|
60
|
+
test(`${mode}: Git-root benches seal and audit without Git data`, async (t) => {
|
|
61
|
+
const f = await fixture(t);
|
|
62
|
+
mkdirSync(join(f.bench, '.git'));
|
|
63
|
+
writeFileSync(join(f.bench, '.git', 'HEAD'), 'metadata before preview');
|
|
64
|
+
const group = join(f.base.runsRoot, f.base.runGroup);
|
|
65
|
+
if (mode === 'calibration') {
|
|
66
|
+
const calibrate = { executor: f.base.executor, trials: 1, maxCalls: 1, runsRoot: f.base.runsRoot, runGroup: f.base.runGroup };
|
|
67
|
+
const preview = prepareBenchCalibration({ dir: f.bench, calibrate });
|
|
68
|
+
writeFileSync(join(f.bench, '.git', 'HEAD'), 'metadata after preview');
|
|
69
|
+
assert.equal(prepareBenchCalibration({ dir: f.bench, calibrate }).planSha256, preview.planSha256);
|
|
70
|
+
await runBenchCalibration({ dir: f.bench, calibrate: { ...calibrate, reviewedPlanSha256: preview.planSha256 }, log: () => { } });
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const base = { ...f.base, mode, ...(mode === 'installed' ? { baselineSkillPath: f.old } : {}) };
|
|
74
|
+
const preview = await runEvalCli({ ...base, dryRun: true });
|
|
75
|
+
writeFileSync(join(f.bench, '.git', 'HEAD'), 'metadata after preview');
|
|
76
|
+
assert.equal((await runEvalCli({ ...base, dryRun: true })).plan.sha256, preview.plan.sha256);
|
|
77
|
+
const executed = await runEvalCli(base, preview.plan.sha256);
|
|
78
|
+
assert.equal(executed.status, 'completed', 'executionError' in executed ? String(executed.executionError) : 'Expected a completed offline run.');
|
|
79
|
+
}
|
|
80
|
+
assert.equal(existsSync(join(group, '_inputs', 'bench', '.git')), false);
|
|
81
|
+
const report = await readEvaluationReport(group, { replay: true });
|
|
82
|
+
assert.equal(report.status, 'completed', readFileSync(join(group, '_session.json'), 'utf8'));
|
|
83
|
+
assert.equal(report.evidence.verified, true, report.evidence.reasons.join('; '));
|
|
84
|
+
const calls = f.calls();
|
|
85
|
+
assert.equal(calls, mode === 'calibration' || mode === 'trigger' ? 1 : 2);
|
|
86
|
+
if (mode === 'inject') {
|
|
87
|
+
const portable = join(f.root, 'portable');
|
|
88
|
+
await exportEvaluation(group, portable, { yes: true, log: () => { } });
|
|
89
|
+
const moved = join(f.root, 'moved');
|
|
90
|
+
renameSync(portable, moved);
|
|
91
|
+
rmSync(f.bench, { recursive: true });
|
|
92
|
+
rmSync(f.skill, { recursive: true });
|
|
93
|
+
rmSync(group, { recursive: true });
|
|
94
|
+
const replay = spawnSync(process.execPath, [join(moved, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000, maxBuffer: 8 * 1024 * 1024 });
|
|
95
|
+
assert.equal(replay.status, 0, replay.stderr);
|
|
96
|
+
assert.equal(JSON.parse(replay.stdout).evidence.verified, true);
|
|
97
|
+
assert.equal(f.calls(), calls);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
test('every preview rejects output inside inputs before probes, calls or directories, including aliases', async (t) => {
|
|
101
|
+
const f = await fixture(t), marker = join(f.root, 'verifier-ran');
|
|
102
|
+
writeFileSync(join(f.bench, 'verifiers', 'example-task.mjs'), `import{writeFileSync}from'node:fs';writeFileSync(${JSON.stringify(marker)},'probed');process.exit(1);`);
|
|
103
|
+
const alias = join(f.root, 'bench-alias');
|
|
104
|
+
symlinkSync(f.bench, alias, process.platform === 'win32' ? 'junction' : 'dir');
|
|
105
|
+
const roots = [join(f.bench, 'runs'), join(f.bench, 'fixtures', 'example-task', 'runs'), join(f.skill, 'runs'), join(alias, 'new', 'runs'), join(f.root, '.git', 'runs')];
|
|
106
|
+
for (const mode of ['inject', 'installed', 'trigger']) {
|
|
107
|
+
for (const runsRoot of [...roots, ...(mode === 'installed' ? [join(f.old, 'runs')] : [])]) {
|
|
108
|
+
await assert.rejects(runEvalCli({ ...f.base, mode, runsRoot, dryRun: true,
|
|
109
|
+
...(mode === 'installed' ? { baselineSkillPath: f.old } : {}) }), /output must be outside/);
|
|
110
|
+
assert.equal(existsSync(join(runsRoot, 'study')), false);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const runsRoot of [roots[0], roots[3], roots[4]])
|
|
114
|
+
assert.throws(() => prepareBenchCalibration({ dir: f.bench,
|
|
115
|
+
calibrate: { executor: f.base.executor, trials: 1, runsRoot, runGroup: 'study' } }), /output must be outside/);
|
|
116
|
+
await assert.rejects(runEval({ ...f.base, runsRoot: roots[0] }), /output must be outside/);
|
|
117
|
+
assert.equal(existsSync(marker), false);
|
|
118
|
+
assert.equal(f.calls(), 0);
|
|
119
|
+
assert.throws(() => assertEvaluationOutputLayout(fileURLToPath(new URL('../not-created', import.meta.url)), { benchDir: f.bench }), /output must be outside/);
|
|
120
|
+
const cli = spawnSync(process.execPath, [fileURLToPath(new URL('../cli.js', import.meta.url)), 'eval', f.skill,
|
|
121
|
+
'--bench', f.bench, '--agent', 'codex', '--runs-root', roots[0], '--run-group', 'study', '--dry-run', '--json'], { encoding: 'utf8', env: { PATH: '' } });
|
|
122
|
+
assert.equal(cli.status, 2);
|
|
123
|
+
assert.equal(JSON.parse(cli.stdout).kind, 'skillfit.eval-error');
|
|
124
|
+
assert.equal(existsSync(marker), false);
|
|
125
|
+
assert.equal(f.calls(), 0);
|
|
126
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { basename, dirname } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { hashFileSet, listFilesRecursive, sha256Text } from '../harness/hash.js';
|
|
5
|
+
import { runEval } from './eval.js';
|
|
6
|
+
/** Shared read-only planning and confirmation for command-line and file requests. */
|
|
7
|
+
export async function prepareEvalPlan(options, context) {
|
|
8
|
+
const implementationDir = fileURLToPath(new URL('../../dist', import.meta.url));
|
|
9
|
+
const implementationSha256 = hashFileSet(implementationDir, listFilesRecursive(implementationDir));
|
|
10
|
+
const lines = [];
|
|
11
|
+
let evaluation;
|
|
12
|
+
await runEval({ ...options, dryRun: true, log: line => lines.push(line), onPlan: preview => { evaluation = preview; } });
|
|
13
|
+
if (!evaluation)
|
|
14
|
+
throw new Error('No paired evaluation plan is available.');
|
|
15
|
+
if (existsSync(evaluation.outputDir))
|
|
16
|
+
throw new Error('Run group already exists; declare a fresh group without overwriting evidence.');
|
|
17
|
+
const describe = (preview) => ({ schemaVersion: 1, kind: 'skillfit.eval-plan',
|
|
18
|
+
...context, implementationSha256, evaluation: preview });
|
|
19
|
+
const data = describe(evaluation), sha256 = sha256Text(JSON.stringify(data));
|
|
20
|
+
const plan = { ...data, sha256 };
|
|
21
|
+
const resolved = { ...options, runsRoot: dirname(evaluation.outputDir), runGroup: basename(evaluation.outputDir) };
|
|
22
|
+
return { plan, lines, options: resolved,
|
|
23
|
+
assertCurrent: (preview) => {
|
|
24
|
+
if (sha256Text(JSON.stringify(describe(preview))) !== sha256)
|
|
25
|
+
throw new Error('Plan changed before execution; no calls allowed.');
|
|
26
|
+
} };
|
|
27
|
+
}
|
|
28
|
+
export function confirmEvalPlan(expected, actual) {
|
|
29
|
+
if (!expected || !/^[0-9a-f]{64}$/i.test(expected) || expected.toLowerCase() !== actual) {
|
|
30
|
+
throw new Error('Execution requires --plan-sha matching the current dry-run plan; inputs, policy, executor or implementation changed.');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function plannedEvalResult(plan) {
|
|
34
|
+
return { schemaVersion: 1, kind: 'skillfit.eval-result', status: 'planned', plan,
|
|
35
|
+
acceptance: { decision: 'inconclusive', eligibleForUpgrade: false, automaticUpgrade: false,
|
|
36
|
+
reasons: [{ code: 'PLAN_ONLY', message: 'No agent call or outcome is available.' }] } };
|
|
37
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert/strict';
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
5
|
import { delimiter, join } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
@@ -8,6 +8,8 @@ import { test } from 'node:test';
|
|
|
8
8
|
import { runBenchInit } from './bench.js';
|
|
9
9
|
import { componentError, reportEvalComponent } from './eval-component.js';
|
|
10
10
|
import { runEval } from './eval.js';
|
|
11
|
+
import { runEvalCli } from './eval-cli.js';
|
|
12
|
+
import { exportEvaluation } from './eval-export.js';
|
|
11
13
|
import { CasePreflightFailed } from './eval-preflight.js';
|
|
12
14
|
import { MockExecutor } from '../harness/executors/mock.js';
|
|
13
15
|
const read = (path) => JSON.parse(readFileSync(path, 'utf8'));
|
|
@@ -31,6 +33,147 @@ async function setup(t, kind = 'command') {
|
|
|
31
33
|
return { root, bench, skill, old, raw, save, base, judge, calls: () => calls, judges: () => judges,
|
|
32
34
|
verifier: join(bench, 'verifiers/example-task.mjs'), oracle: join(bench, 'ground-truth/oracle-example-task.mjs') };
|
|
33
35
|
}
|
|
36
|
+
test('grader load/runtime/reported errors block output and command tasks without an oracle or any executor call', async (t) => {
|
|
37
|
+
for (const kind of ['command', 'output'])
|
|
38
|
+
for (const [name, source] of [
|
|
39
|
+
['syntax', 'const broken = ;'], ['runtime', 'missingGraderFunction();'],
|
|
40
|
+
['dependency', "import './absent-grader-dependency.mjs';"],
|
|
41
|
+
['reported-zero-exit', "console.log(JSON.stringify({schemaVersion:1,kind:'skillfit.verifier-error',message:'grader unavailable'}));"],
|
|
42
|
+
])
|
|
43
|
+
await t.test(`${kind}: ${name}`, async (t) => {
|
|
44
|
+
const f = await setup(t, kind);
|
|
45
|
+
delete f.raw.tasks[0].oracle;
|
|
46
|
+
writeFileSync(f.verifier, source);
|
|
47
|
+
f.save();
|
|
48
|
+
await assert.rejects(runEval(f.base), error => {
|
|
49
|
+
assert.ok(error instanceof CasePreflightFailed);
|
|
50
|
+
const gate = error.preflight.checks.find(c => c.code === (kind === 'command' ? 'UNTOUCHED_FIXTURE' : 'MISSING_OUTPUT'));
|
|
51
|
+
assert.equal(gate?.status, 'FAIL');
|
|
52
|
+
assert.match(gate.evidence.error, /VERIFIER_(RUNTIME|REPORTED)_ERROR/);
|
|
53
|
+
assert.notEqual(gate.evidence.exitCode, null);
|
|
54
|
+
return true;
|
|
55
|
+
});
|
|
56
|
+
assert.equal(f.calls(), 0);
|
|
57
|
+
assert.equal(f.judges(), 0);
|
|
58
|
+
assert.ok(!existsSync(f.base.runsRoot));
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
test('an oracle explicitly reporting an infrastructure error cannot pass by exiting zero', async (t) => {
|
|
62
|
+
const f = await setup(t);
|
|
63
|
+
writeFileSync(f.oracle, "console.log(JSON.stringify({schemaVersion:1,kind:'skillfit.verifier-error',message:'reference environment unavailable'}));");
|
|
64
|
+
await assert.rejects(runEval(f.base), error => {
|
|
65
|
+
assert.ok(error instanceof CasePreflightFailed);
|
|
66
|
+
const gate = error.preflight.checks.find(c => c.code === 'ORACLE');
|
|
67
|
+
assert.equal(gate?.status, 'FAIL');
|
|
68
|
+
assert.equal(gate.evidence.exitCode, 0);
|
|
69
|
+
assert.match(gate.evidence.error, /VERIFIER_REPORTED_ERROR/);
|
|
70
|
+
return true;
|
|
71
|
+
});
|
|
72
|
+
assert.equal(f.calls(), 0);
|
|
73
|
+
assert.ok(!existsSync(f.base.runsRoot));
|
|
74
|
+
});
|
|
75
|
+
test('quoted verifier/oracle paths grade a real file repair, preserve failure/pass and replay without originals', async (t) => {
|
|
76
|
+
const f = await setup(t);
|
|
77
|
+
renameSync(f.verifier, join(f.bench, 'verifiers/check answer.mjs'));
|
|
78
|
+
renameSync(f.oracle, join(f.bench, 'ground-truth/repair answer.mjs'));
|
|
79
|
+
f.raw.tasks[0].verifier = 'node "verifiers/check answer.mjs"';
|
|
80
|
+
f.raw.tasks[0].oracle = "node 'ground-truth/repair answer.mjs'";
|
|
81
|
+
f.save();
|
|
82
|
+
let calls = 0;
|
|
83
|
+
const executor = { describe: () => ({ kind: 'mock', model: 'offline-quoted-repair' }), run: async (_p, dir) => {
|
|
84
|
+
if (++calls === 2)
|
|
85
|
+
writeFileSync(join(dir, 'index.js'), 'export const add = (a,b) => a+b;\n');
|
|
86
|
+
return { output: 'done', tokens: { input: 10, cachedInput: 4, output: 2 } };
|
|
87
|
+
} };
|
|
88
|
+
const base = { ...f.base, executor }, preview = await runEvalCli({ ...base, dryRun: true });
|
|
89
|
+
assert.ok('plan' in preview);
|
|
90
|
+
const result = await runEvalCli(base, preview.plan.sha256);
|
|
91
|
+
assert.equal(result.status, 'completed');
|
|
92
|
+
assert.ok('quality' in result);
|
|
93
|
+
assert.equal(result.evidence.verified, true);
|
|
94
|
+
assert.equal(result.quality.improvedPairs, 1);
|
|
95
|
+
assert.equal(result.quality.regressedPairs, 0);
|
|
96
|
+
const run = join(base.runsRoot, base.runGroup);
|
|
97
|
+
const before = read(join(run, 'example-task/baseline/trial-1/_result.json')), after = read(join(run, 'example-task/treatment/trial-1/_result.json'));
|
|
98
|
+
assert.equal(before.error, null);
|
|
99
|
+
assert.equal(before.passed, false);
|
|
100
|
+
assert.equal(after.error, null);
|
|
101
|
+
assert.equal(after.passed, true);
|
|
102
|
+
for (const dir of [f.bench, f.skill, f.old])
|
|
103
|
+
rmSync(dir, { recursive: true });
|
|
104
|
+
const replay = await reportEvalComponent(run, { replay: true });
|
|
105
|
+
assert.equal(replay.evidence.verified, true);
|
|
106
|
+
assert.ok('costs' in replay);
|
|
107
|
+
assert.deepEqual(replay.costs, result.costs);
|
|
108
|
+
assert.ok('replayedDeliveries' in replay.evidence);
|
|
109
|
+
assert.equal(replay.evidence.replayedDeliveries, 2);
|
|
110
|
+
const output = join(f.root, 'portable');
|
|
111
|
+
await exportEvaluation(run, output, { yes: true, log: () => { } });
|
|
112
|
+
rmSync(run, { recursive: true });
|
|
113
|
+
const child = spawnSync(process.execPath, [join(output, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000 });
|
|
114
|
+
assert.equal(child.status, 0, child.stderr);
|
|
115
|
+
assert.equal(JSON.parse(child.stdout).evidence.verified, true);
|
|
116
|
+
assert.deepEqual(JSON.parse(child.stdout).costs, result.costs);
|
|
117
|
+
assert.equal(calls, 2);
|
|
118
|
+
});
|
|
119
|
+
test('a grader exception after an invoked repair stops a budgeted run and retains final invocation costs', async (t) => {
|
|
120
|
+
const f = await setup(t);
|
|
121
|
+
delete f.raw.tasks[0].oracle;
|
|
122
|
+
f.save();
|
|
123
|
+
writeFileSync(f.verifier, "import{readFileSync}from'node:fs';import{join}from'node:path';if(readFileSync(join(process.argv[2],'index.js'),'utf8').includes('a + b'))throw new TypeError('grader broke on repaired input');console.log(JSON.stringify({passed:false}));process.exit(1);");
|
|
124
|
+
let calls = 0;
|
|
125
|
+
const executor = { describe: () => ({ kind: 'mock', model: 'offline-grader-crash' }), run: async (_p, dir) => {
|
|
126
|
+
calls++;
|
|
127
|
+
writeFileSync(join(dir, 'index.js'), 'export const add = (a,b) => a + b;\n');
|
|
128
|
+
return { output: 'fixed', tokens: { input: 10, cachedInput: 4, output: 2 } };
|
|
129
|
+
} };
|
|
130
|
+
const result = await runEvalCli({ ...f.base, executor, spendingBudget: { input: 100, cachedInput: 100, uncachedInput: 100, output: 100, durationSeconds: 100 } });
|
|
131
|
+
assert.equal(result.status, 'stopped');
|
|
132
|
+
assert.equal(calls, 1);
|
|
133
|
+
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
134
|
+
const receipt = read(join(f.base.runsRoot, f.base.runGroup, 'example-task/baseline/trial-1/_result.json'));
|
|
135
|
+
assert.match(receipt.error, /VERIFIER_RUNTIME_ERROR/);
|
|
136
|
+
assert.equal(receipt.usageStatus, 'final');
|
|
137
|
+
assert.deepEqual(receipt.tokens, { input: 10, cachedInput: 4, output: 2 });
|
|
138
|
+
assert.ok('costs' in result);
|
|
139
|
+
assert.equal(result.costs.populations.attempts.baseline.metrics.input.knownTotal, 10);
|
|
140
|
+
assert.equal(result.costs.populations.attempts.baseline.metrics.input.coverage.final, 1);
|
|
141
|
+
assert.ok(!existsSync(join(f.base.runsRoot, f.base.runGroup, 'example-task/treatment/trial-1')));
|
|
142
|
+
});
|
|
143
|
+
test('offline replay refuses a new verifier infrastructure error even when its nonzero exit matches the saved failure', async (t) => {
|
|
144
|
+
const f = await setup(t), name = 'SKILLFIT_OFFLINE_VERIFIER_ERROR', previous = process.env[name];
|
|
145
|
+
delete f.raw.tasks[0].oracle;
|
|
146
|
+
f.save();
|
|
147
|
+
writeFileSync(f.verifier, `if(process.env.${name})throw new Error('replay grader unavailable');console.log(JSON.stringify({passed:false}));process.exit(1);`);
|
|
148
|
+
delete process.env[name];
|
|
149
|
+
let calls = 0;
|
|
150
|
+
const executor = { describe: () => ({ kind: 'mock', model: 'offline-replay-grader' }), run: async () => {
|
|
151
|
+
calls++;
|
|
152
|
+
return { output: 'done', tokens: { input: 10, cachedInput: 4, output: 2 } };
|
|
153
|
+
} };
|
|
154
|
+
try {
|
|
155
|
+
await runEval({ ...f.base, executor });
|
|
156
|
+
const run = join(f.base.runsRoot, f.base.runGroup), path = join(run, 'manifest.json'), original = readFileSync(path, 'utf8');
|
|
157
|
+
const saved = await reportEvalComponent(run);
|
|
158
|
+
assert.equal(saved.evidence.verified, true);
|
|
159
|
+
assert.ok('costs' in saved);
|
|
160
|
+
process.env[name] = '1';
|
|
161
|
+
const replay = await reportEvalComponent(run, { replay: true });
|
|
162
|
+
assert.equal(replay.evidence.verified, false);
|
|
163
|
+
assert.ok('costs' in replay);
|
|
164
|
+
assert.match(replay.evidence.reasons.join(' '), /Replay verifier failed: VERIFIER_RUNTIME_ERROR/);
|
|
165
|
+
assert.equal(replay.acceptance.eligibleForUpgrade, false);
|
|
166
|
+
assert.deepEqual(replay.costs, saved.costs);
|
|
167
|
+
assert.equal(readFileSync(path, 'utf8'), original);
|
|
168
|
+
assert.equal(calls, 2);
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
if (previous === undefined)
|
|
172
|
+
delete process.env[name];
|
|
173
|
+
else
|
|
174
|
+
process.env[name] = previous;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
34
177
|
for (const mode of ['inject', 'installed', 'trigger'])
|
|
35
178
|
test(`${mode}: a broken NOP gate blocks all agent/judge calls before run creation`, async (t) => {
|
|
36
179
|
const f = await setup(t);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { agentEnvironmentReportLines } from '../harness/agent-preflight.js';
|
|
3
|
+
import { renderSingleArmReport } from './eval-single-arm-report.js';
|
|
2
4
|
import { CONCLUSIVE_TASKS, CONCLUSIVE_TRIALS, formatP, formatPp1, verdictFor } from '../harness/report.js';
|
|
3
5
|
import { mcnemarExactP } from '../harness/stats.js';
|
|
4
6
|
import { validateSkillInstallDir } from '../harness/installed-skill.js';
|
|
5
7
|
import { assertCostTotals, COST_METRICS, renderCostLines } from '../harness/costs.js';
|
|
8
|
+
import { parseInvocationCosts, renderInvocationCostLines } from '../harness/invocation-costs.js';
|
|
6
9
|
const MAX_MANIFEST_BYTES = 16 * 1024 * 1024;
|
|
7
10
|
function object(value, label) {
|
|
8
11
|
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
@@ -53,6 +56,8 @@ function experiment(value) {
|
|
|
53
56
|
const callsStarted = integer(item['callsStarted'], 'experiment.callsStarted');
|
|
54
57
|
const callsFinished = integer(item['callsFinished'], 'experiment.callsFinished');
|
|
55
58
|
const stopReason = item['stopReason'] === null ? null : string(item['stopReason'], 'experiment.stopReason');
|
|
59
|
+
if (item['stopCode'] !== undefined && !['EXECUTION_FAILED', 'FINAL_USAGE_MISSING', 'SPENDING_BUDGET_REACHED'].includes(String(item['stopCode'])))
|
|
60
|
+
throw new Error('Invalid experiment.stopCode');
|
|
56
61
|
if (![plannedCalls, maxCalls, callsStarted, callsFinished].every(Number.isSafeInteger) ||
|
|
57
62
|
maxCalls < plannedCalls || callsStarted > plannedCalls || callsFinished > callsStarted ||
|
|
58
63
|
(status === 'completed' && (stopReason !== null || callsFinished !== plannedCalls)) ||
|
|
@@ -61,7 +66,8 @@ function experiment(value) {
|
|
|
61
66
|
throw new Error('experiment status, call counts, ceiling, and stop reason contradict each other');
|
|
62
67
|
}
|
|
63
68
|
return { schemaVersion: 1, status, plannedCalls, maxCalls, callsStarted, callsFinished, stopReason,
|
|
64
|
-
planSha256: hash(item['planSha256'], 'experiment.planSha256')
|
|
69
|
+
planSha256: hash(item['planSha256'], 'experiment.planSha256'),
|
|
70
|
+
...(item['stopCode'] === undefined ? {} : { stopCode: item['stopCode'] }) };
|
|
65
71
|
}
|
|
66
72
|
function counts(value, label) {
|
|
67
73
|
const item = object(value, label);
|
|
@@ -425,6 +431,7 @@ export function parseEvalReport(value) {
|
|
|
425
431
|
}
|
|
426
432
|
return {
|
|
427
433
|
runGroup: string(manifest['runGroup'], 'runGroup'),
|
|
434
|
+
...(manifest['invocationCosts'] === undefined ? {} : { invocationCosts: parseInvocationCosts(manifest['invocationCosts']) }),
|
|
428
435
|
createdAt,
|
|
429
436
|
target: { kind, name: string(target['name'], 'target.name'), sha256: hash(target['bundleSha256'], 'target.bundleSha256') },
|
|
430
437
|
baselineTarget,
|
|
@@ -584,6 +591,8 @@ export function renderEvalMarkdown(report) {
|
|
|
584
591
|
lines.push(...renderCostLines(report.overall.costs));
|
|
585
592
|
else
|
|
586
593
|
lines.push('Cache partitions and all-invocation costs were not recorded in this legacy manifest. Missing usage is unknown; the report does not infer it from prompt size or treat it as zero.');
|
|
594
|
+
if (report.invocationCosts)
|
|
595
|
+
lines.push('', ...renderInvocationCostLines(report.invocationCosts));
|
|
587
596
|
lines.push('', '## Warnings', '');
|
|
588
597
|
if (report.warnings.length === 0)
|
|
589
598
|
lines.push('- None');
|
|
@@ -595,8 +604,12 @@ export function renderEvalMarkdown(report) {
|
|
|
595
604
|
export async function runEvalReport(inputPath, log = console.log, options = {}) {
|
|
596
605
|
// Import after module initialization: component assessment itself uses this
|
|
597
606
|
// module's manifest parser. Both CLI formats must share the same assessment.
|
|
598
|
-
const {
|
|
599
|
-
const result = await
|
|
607
|
+
const { readEvaluationReport } = await import('./evaluation-report.js');
|
|
608
|
+
const result = await readEvaluationReport(inputPath, options);
|
|
609
|
+
if ('evaluationType' in result) {
|
|
610
|
+
log(renderSingleArmReport(result));
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
600
613
|
const root = result.evidence.runDir;
|
|
601
614
|
const safe = (message) => escapeMarkdown(message.replaceAll(root, '[run]'));
|
|
602
615
|
const lines = [];
|
|
@@ -613,12 +626,14 @@ export async function runEvalReport(inputPath, log = console.log, options = {})
|
|
|
613
626
|
if ('startedAgentDispatches' in result.costs)
|
|
614
627
|
lines.push(`- Started agent dispatches: ${result.costs.startedAgentDispatches}`, `- Missing or invalid invocation receipts: ${result.costs.invocationsWithUnknownReceipts}`);
|
|
615
628
|
lines.push('', '## Retained costs', '', ...renderCostLines(result.costs.populations));
|
|
629
|
+
lines.push('', ...renderInvocationCostLines(result.invocationCosts));
|
|
616
630
|
}
|
|
617
631
|
lines.push('', '## Evidence and acceptance', '', `- State: ${result.status}`, `- Native evidence: ${result.evidence.verified ? 'verified' : 'unverified'}`, `- Acceptance: ${result.acceptance.decision}`, `- Eligible for upgrade: ${result.acceptance.eligibleForUpgrade ? 'yes' : 'no'}`, '- Automatic upgrade: no');
|
|
618
632
|
for (const reason of result.acceptance.reasons)
|
|
619
633
|
lines.push(`- ${reason.code}: ${safe(reason.message)}`);
|
|
620
634
|
for (const reason of result.evidence.reasons)
|
|
621
635
|
lines.push(`- Audit: ${safe(reason)}`);
|
|
636
|
+
lines.push(...agentEnvironmentReportLines(result.agentPreflight).map(line => `- ${safe(line)}`));
|
|
622
637
|
if (result.casePreflight) {
|
|
623
638
|
const gate = result.casePreflight;
|
|
624
639
|
if (typeof gate.status === 'string' && gate.summary && [gate.summary.failures, gate.summary.warnings, gate.summary.unknown].every(n => typeof n === 'number' && Number.isSafeInteger(n) && n >= 0)) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { existsSync, statSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { readSingleArmReport } from './eval-single-arm-report.js';
|
|
4
|
+
import { auditSingleArmEvaluation } from '../harness/single-arm-audit.js';
|
|
5
|
+
/** Shared async single-arm report reader; only native evidence can be replayed. */
|
|
6
|
+
export async function reportSingleArmEvaluation(path, options = {}) {
|
|
7
|
+
const report = readSingleArmReport(path);
|
|
8
|
+
if (!report)
|
|
9
|
+
return null;
|
|
10
|
+
if (options.policyPath || options.recordsPath)
|
|
11
|
+
throw new Error('Single-arm reports do not support paired --policy or external --records overrides.');
|
|
12
|
+
if (options.benchDir && !options.replay)
|
|
13
|
+
throw new Error('--bench is only used with --replay for a single-arm report.');
|
|
14
|
+
const input = resolve(path), root = statSync(input).isDirectory() ? input : dirname(input);
|
|
15
|
+
if (!existsSync(join(root, '_plan.json')) || !existsSync(join(root, '_session.json')) || !existsSync(join(root, '_artifacts.json'))) {
|
|
16
|
+
if (options.replay)
|
|
17
|
+
throw new Error('Offline single-arm replay requires a sealed native run, not a standalone historical summary.');
|
|
18
|
+
return report;
|
|
19
|
+
}
|
|
20
|
+
return { ...report, ...await auditSingleArmEvaluation(root, options) };
|
|
21
|
+
}
|