skillfit 0.15.2 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/README.md +33 -25
- package/README.zh-CN.md +33 -25
- package/benches/code-review/ground-truth/r1.md +3 -3
- package/benches/code-review/verifiers/seeded-bugs.mjs +25 -10
- package/dist/agents/mcp-probe.js +138 -13
- package/dist/bench/authoring.js +10 -2
- package/dist/cli/definition.js +28 -10
- package/dist/cli/doctor.js +33 -14
- package/dist/cli/eval-report.js +1 -1
- package/dist/cli/main.js +53 -6
- package/dist/cli/mcp.js +23 -7
- package/dist/cli/report.js +4 -1
- package/dist/composition.js +16 -0
- package/dist/configuration/bundle.js +150 -47
- package/dist/configuration/install.js +109 -23
- package/dist/configuration/lock.js +28 -0
- package/dist/configuration/mcp-write.js +311 -0
- package/dist/configuration/uninstall.js +241 -0
- package/dist/configuration/upstream.js +3 -0
- package/dist/evaluation/records/session.js +16 -8
- package/docs/README.md +7 -7
- package/docs/guides/experiment-workflow.md +25 -0
- package/docs/guides/selectable-codex.md +35 -4
- package/docs/maintainers/architecture.md +1 -1
- package/docs/reference/eval-component.md +2 -2
- package/docs/schemas/doctor-report.schema.json +92 -0
- package/package.json +1 -1
- package/skills/skillfit/SKILL.md +18 -15
- package/tools/verify/recipes/0.11.0-feature-smoke.mjs +140 -491
- package/tools/verify/recipes/release-feature-smoke.mjs +8 -4
|
@@ -1,571 +1,220 @@
|
|
|
1
|
-
import assert from
|
|
2
|
-
import { spawnSync } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
mkdtempSync,
|
|
7
|
-
readFileSync,
|
|
8
|
-
renameSync,
|
|
9
|
-
rmSync,
|
|
10
|
-
writeFileSync,
|
|
11
|
-
} from "node:fs";
|
|
12
|
-
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
13
|
-
import { pathToFileURL } from "node:url";
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
14
6
|
|
|
15
7
|
// Usage: node 0.11.0-feature-smoke.mjs <installed-or-extracted-package> <fresh-output-parent>
|
|
16
8
|
// No real agent, model API or login probe is used. The package path is supplied
|
|
17
9
|
// by the caller; this check alone does not establish registry publication.
|
|
18
|
-
assert.equal(process.argv.length, 4,
|
|
19
|
-
const installed = resolve(process.argv[2]),
|
|
20
|
-
parent = resolve(process.argv[3]);
|
|
10
|
+
assert.equal(process.argv.length, 4, 'Provide a package directory and a fresh output parent.');
|
|
11
|
+
const installed = resolve(process.argv[2]), parent = resolve(process.argv[3]);
|
|
21
12
|
const insidePackage = relative(installed, parent);
|
|
22
|
-
assert.ok(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
26
|
-
assert.equal(
|
|
27
|
-
existsSync(parent),
|
|
28
|
-
false,
|
|
29
|
-
"The output parent must be fresh; prior smoke receipts are never overwritten.",
|
|
30
|
-
);
|
|
31
|
-
assert.equal(JSON.parse(readFileSync(join(installed, "package.json"), "utf8")).version, "0.11.0");
|
|
13
|
+
assert.ok(isAbsolute(insidePackage) || insidePackage.startsWith(`..${sep}`) || insidePackage === '..', 'Keep smoke output outside the installed package.');
|
|
14
|
+
assert.equal(existsSync(parent), false, 'The output parent must be fresh; prior smoke receipts are never overwritten.');
|
|
15
|
+
assert.equal(JSON.parse(readFileSync(join(installed, 'package.json'), 'utf8')).version, '0.11.0');
|
|
32
16
|
mkdirSync(parent, { recursive: true });
|
|
33
|
-
const root = mkdtempSync(join(parent,
|
|
34
|
-
const home = join(root,
|
|
35
|
-
runsRoot = join(root, "runs");
|
|
17
|
+
const root = mkdtempSync(join(parent, 'offline-foundations-'));
|
|
18
|
+
const home = join(root, 'home'), runsRoot = join(root, 'runs');
|
|
36
19
|
mkdirSync(home);
|
|
37
|
-
const load =
|
|
38
|
-
const { runBenchInit, runBenchCalibration } = await load(
|
|
39
|
-
const { runEval } = await load(
|
|
40
|
-
const { runEvalCli } = await load(
|
|
41
|
-
const { readEvaluationReport } = await load(
|
|
42
|
-
const { exportEvaluation } = await load(
|
|
43
|
-
const { packageFiles } = await load(
|
|
44
|
-
const { sha256File, hashFileSet, listFilesRecursive } = await load(
|
|
20
|
+
const load = file => import(pathToFileURL(join(installed, 'dist', file)).href);
|
|
21
|
+
const { runBenchInit, runBenchCalibration } = await load('commands/bench.js');
|
|
22
|
+
const { runEval } = await load('commands/eval.js');
|
|
23
|
+
const { runEvalCli } = await load('commands/eval-cli.js');
|
|
24
|
+
const { readEvaluationReport } = await load('commands/evaluation-report.js');
|
|
25
|
+
const { exportEvaluation } = await load('commands/eval-export.js');
|
|
26
|
+
const { packageFiles } = await load('harness/replay-package.js');
|
|
27
|
+
const { sha256File, hashFileSet, listFilesRecursive } = await load('harness/hash.js');
|
|
45
28
|
|
|
46
29
|
// Public CLI previews have an empty PATH. Fake-executor runs and replay need
|
|
47
30
|
// only Node's directory to execute the package's trusted fixture programs.
|
|
48
31
|
// Every child receives isolated homes and no API/judge credentials.
|
|
49
|
-
const originalEnvironment = { ...process.env },
|
|
50
|
-
originalFetch = globalThis.fetch;
|
|
32
|
+
const originalEnvironment = { ...process.env }, originalFetch = globalThis.fetch;
|
|
51
33
|
for (const key of Object.keys(process.env)) {
|
|
52
|
-
if (key.toUpperCase() ===
|
|
53
|
-
delete process.env[key];
|
|
34
|
+
if (key.toUpperCase() === 'PATH' || /^(SKILLFIT_|OPENAI_|ANTHROPIC_)/.test(key)) delete process.env[key];
|
|
54
35
|
}
|
|
55
|
-
Object.assign(process.env, {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
let networkAttempts = 0,
|
|
65
|
-
skillfitCliCalls = 0;
|
|
66
|
-
globalThis.fetch = async () => {
|
|
67
|
-
networkAttempts++;
|
|
68
|
-
throw new Error("Network calls are forbidden in this offline smoke.");
|
|
69
|
-
};
|
|
70
|
-
const counts = {
|
|
71
|
-
calibrationHardFailure: 0,
|
|
72
|
-
calibration: 0,
|
|
73
|
-
pairedAgent: 0,
|
|
74
|
-
judge: 0,
|
|
75
|
-
triggerLine: 0,
|
|
76
|
-
triggerPartial: 0,
|
|
77
|
-
triggerUnknown: 0,
|
|
78
|
-
};
|
|
79
|
-
const checks = {},
|
|
80
|
-
tests = {};
|
|
81
|
-
const final = {
|
|
82
|
-
output: "skillfit-ok",
|
|
83
|
-
tokens: { input: 10, cachedInput: 2, output: 3 },
|
|
84
|
-
usageStatus: "final",
|
|
85
|
-
};
|
|
86
|
-
const limits = {
|
|
87
|
-
input: 1000,
|
|
88
|
-
cachedInput: 1000,
|
|
89
|
-
uncachedInput: 1000,
|
|
90
|
-
output: 1000,
|
|
91
|
-
durationSeconds: 1000,
|
|
92
|
-
};
|
|
93
|
-
const json = (file) => JSON.parse(readFileSync(file, "utf8"));
|
|
36
|
+
Object.assign(process.env, { PATH: dirname(process.execPath), HOME: home, USERPROFILE: home, CODEX_HOME: join(home, 'codex'), SKILLFIT_JUDGE: '0' });
|
|
37
|
+
const env = { ...process.env, PATH: '' }, replayEnv = { ...process.env };
|
|
38
|
+
let networkAttempts = 0, skillfitCliCalls = 0;
|
|
39
|
+
globalThis.fetch = async () => { networkAttempts++; throw new Error('Network calls are forbidden in this offline smoke.'); };
|
|
40
|
+
const counts = { calibrationHardFailure: 0, calibration: 0, pairedAgent: 0, judge: 0, triggerLine: 0, triggerPartial: 0, triggerUnknown: 0 };
|
|
41
|
+
const checks = {}, tests = {};
|
|
42
|
+
const final = { output: 'skillfit-ok', tokens: { input: 10, cachedInput: 2, output: 3 }, usageStatus: 'final' };
|
|
43
|
+
const limits = { input: 1000, cachedInput: 1000, uncachedInput: 1000, output: 1000, durationSeconds: 1000 };
|
|
44
|
+
const json = file => JSON.parse(readFileSync(file, 'utf8'));
|
|
94
45
|
const quiet = () => {};
|
|
95
46
|
const fake = (name, response) => ({
|
|
96
|
-
describe: () => ({ kind:
|
|
97
|
-
run: async () => {
|
|
98
|
-
counts[name]++;
|
|
99
|
-
return typeof response === "function" ? response() : structuredClone(response);
|
|
100
|
-
},
|
|
47
|
+
describe: () => ({ kind: 'stub', model: `offline-smoke-${name}` }),
|
|
48
|
+
run: async () => { counts[name]++; return typeof response === 'function' ? response() : structuredClone(response); },
|
|
101
49
|
});
|
|
102
50
|
const cli = (args, expected = 0) => {
|
|
103
51
|
skillfitCliCalls++;
|
|
104
|
-
const child = spawnSync(process.execPath, [join(installed,
|
|
105
|
-
cwd: root,
|
|
106
|
-
env,
|
|
107
|
-
encoding: "utf8",
|
|
108
|
-
timeout: 60_000,
|
|
109
|
-
maxBuffer: 16 * 1024 * 1024,
|
|
110
|
-
});
|
|
52
|
+
const child = spawnSync(process.execPath, [join(installed, 'dist/cli.js'), ...args],
|
|
53
|
+
{ cwd: root, env, encoding: 'utf8', timeout: 60_000, maxBuffer: 16 * 1024 * 1024 });
|
|
111
54
|
assert.equal(child.status, expected, child.stderr || child.stdout);
|
|
112
55
|
return child;
|
|
113
56
|
};
|
|
114
|
-
const noAdoption =
|
|
115
|
-
assert.notEqual(report.acceptance.decision,
|
|
57
|
+
const noAdoption = report => {
|
|
58
|
+
assert.notEqual(report.acceptance.decision, 'accept');
|
|
116
59
|
assert.equal(report.acceptance.eligibleForUpgrade, false);
|
|
117
60
|
assert.equal(report.acceptance.automaticUpgrade, false);
|
|
118
61
|
};
|
|
119
|
-
const snapshotCosts =
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}),
|
|
127
|
-
);
|
|
128
|
-
const ledger = (run) =>
|
|
129
|
-
readFileSync(join(run, "_calls.jsonl"), "utf8")
|
|
130
|
-
.trim()
|
|
131
|
-
.split("\n")
|
|
132
|
-
.map((line) => JSON.parse(line));
|
|
133
|
-
const files = (run) => packageFiles(run).map((file) => [file, sha256File(join(run, file))]);
|
|
134
|
-
const fixture = async (name, kind = "output", sentinel = null) => {
|
|
62
|
+
const snapshotCosts = report => JSON.parse(JSON.stringify({
|
|
63
|
+
costs: report.costs ?? null, invocationCosts: report.invocationCosts ?? null,
|
|
64
|
+
usage: report.usage ?? null, spendingBudget: report.spendingBudget ?? null,
|
|
65
|
+
}));
|
|
66
|
+
const ledger = run => readFileSync(join(run, '_calls.jsonl'), 'utf8').trim().split('\n').map(line => JSON.parse(line));
|
|
67
|
+
const files = run => packageFiles(run).map(file => [file, sha256File(join(run, file))]);
|
|
68
|
+
const fixture = async (name, kind = 'output', sentinel = null) => {
|
|
135
69
|
const bench = join(root, name);
|
|
136
70
|
await runBenchInit({ dir: bench, kind, yes: true, log: quiet });
|
|
137
|
-
const file = join(bench,
|
|
138
|
-
definition = json(file);
|
|
71
|
+
const file = join(bench, 'bench.json'), definition = json(file);
|
|
139
72
|
definition.tasks[0].shouldTrigger = true;
|
|
140
|
-
definition.tasks[0].triggerClass =
|
|
141
|
-
definition.tasks.push({
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
triggerClass: undefined,
|
|
146
|
-
});
|
|
147
|
-
if (sentinel)
|
|
148
|
-
for (const script of ["verifiers/example-task.mjs", "ground-truth/oracle-example-task.mjs"]) {
|
|
149
|
-
writeFileSync(
|
|
150
|
-
join(bench, script),
|
|
151
|
-
`import{writeFileSync as markProbe}from'node:fs';markProbe(${JSON.stringify(sentinel)},'unexpected');\n` +
|
|
152
|
-
readFileSync(join(bench, script), "utf8"),
|
|
153
|
-
);
|
|
154
|
-
}
|
|
73
|
+
definition.tasks[0].triggerClass = 'explicit';
|
|
74
|
+
definition.tasks.push({ ...definition.tasks[0], id: 'negative-task', shouldTrigger: false, triggerClass: undefined });
|
|
75
|
+
if (sentinel) for (const script of ['verifiers/example-task.mjs', 'ground-truth/oracle-example-task.mjs']) {
|
|
76
|
+
writeFileSync(join(bench, script), `import{writeFileSync as markProbe}from'node:fs';markProbe(${JSON.stringify(sentinel)},'unexpected');\n` + readFileSync(join(bench, script), 'utf8'));
|
|
77
|
+
}
|
|
155
78
|
writeFileSync(file, JSON.stringify(definition));
|
|
156
79
|
return bench;
|
|
157
80
|
};
|
|
158
81
|
|
|
159
82
|
try {
|
|
160
|
-
assert.equal(cli([
|
|
161
|
-
const help = cli([
|
|
162
|
-
for (const flag of [
|
|
163
|
-
"--plan-sha",
|
|
164
|
-
"--task",
|
|
165
|
-
"--spending-budget",
|
|
166
|
-
"--executor-timeout-seconds",
|
|
167
|
-
"--runs-root",
|
|
168
|
-
"--export",
|
|
169
|
-
])
|
|
170
|
-
assert.ok(help.includes(flag));
|
|
83
|
+
assert.equal(cli(['--version']).stdout.trim(), '0.11.0');
|
|
84
|
+
const help = cli(['--help']).stdout;
|
|
85
|
+
for (const flag of ['--plan-sha', '--task', '--spending-budget', '--executor-timeout-seconds', '--runs-root', '--export']) assert.ok(help.includes(flag));
|
|
171
86
|
checks.versionAndPublicFlags = true;
|
|
172
87
|
|
|
173
|
-
const skill = join(root,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
"---\nname: smoke-skill\ndescription: Synthetic offline release workflow check.\n---\nInspect the task and return the answer.\n",
|
|
178
|
-
);
|
|
179
|
-
const sentinel = join(root, "unexpected-preview-probe"),
|
|
180
|
-
previewBench = await fixture("preview-bench", "output", sentinel);
|
|
181
|
-
const settings = [
|
|
182
|
-
"--agent",
|
|
183
|
-
"codex",
|
|
184
|
-
"--trials",
|
|
185
|
-
"1",
|
|
186
|
-
"--executor-timeout-seconds",
|
|
187
|
-
"17",
|
|
188
|
-
"--runs-root",
|
|
189
|
-
join(root, "preview-runs"),
|
|
190
|
-
"--json",
|
|
191
|
-
"--dry-run",
|
|
192
|
-
];
|
|
88
|
+
const skill = join(root, 'skill'); mkdirSync(skill);
|
|
89
|
+
writeFileSync(join(skill, 'SKILL.md'), '---\nname: smoke-skill\ndescription: Synthetic offline release workflow check.\n---\nInspect the task and return the answer.\n');
|
|
90
|
+
const sentinel = join(root, 'unexpected-preview-probe'), previewBench = await fixture('preview-bench', 'output', sentinel);
|
|
91
|
+
const settings = ['--agent', 'codex', '--trials', '1', '--executor-timeout-seconds', '17', '--runs-root', join(root, 'preview-runs'), '--json', '--dry-run'];
|
|
193
92
|
const previewRows = [
|
|
194
|
-
[
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
"eval",
|
|
198
|
-
skill,
|
|
199
|
-
"--mode",
|
|
200
|
-
"installed",
|
|
201
|
-
"--bench",
|
|
202
|
-
previewBench,
|
|
203
|
-
"--task",
|
|
204
|
-
"example-task",
|
|
205
|
-
"--max-calls",
|
|
206
|
-
"2",
|
|
207
|
-
"--run-group",
|
|
208
|
-
"preview-paired",
|
|
209
|
-
],
|
|
210
|
-
],
|
|
211
|
-
[
|
|
212
|
-
"calibration",
|
|
213
|
-
[
|
|
214
|
-
"bench",
|
|
215
|
-
"check",
|
|
216
|
-
previewBench,
|
|
217
|
-
"--calibrate",
|
|
218
|
-
"--task",
|
|
219
|
-
"example-task",
|
|
220
|
-
"--max-calls",
|
|
221
|
-
"1",
|
|
222
|
-
"--input",
|
|
223
|
-
"workspace",
|
|
224
|
-
"--run-group",
|
|
225
|
-
"preview-calibration",
|
|
226
|
-
],
|
|
227
|
-
],
|
|
228
|
-
[
|
|
229
|
-
"trigger",
|
|
230
|
-
[
|
|
231
|
-
"eval",
|
|
232
|
-
skill,
|
|
233
|
-
"--mode",
|
|
234
|
-
"trigger",
|
|
235
|
-
"--bench",
|
|
236
|
-
previewBench,
|
|
237
|
-
"--task",
|
|
238
|
-
"example-task",
|
|
239
|
-
"--task",
|
|
240
|
-
"negative-task",
|
|
241
|
-
"--max-calls",
|
|
242
|
-
"2",
|
|
243
|
-
"--run-group",
|
|
244
|
-
"preview-trigger",
|
|
245
|
-
],
|
|
246
|
-
],
|
|
93
|
+
['paired', ['eval', skill, '--mode', 'installed', '--bench', previewBench, '--task', 'example-task', '--max-calls', '2', '--run-group', 'preview-paired']],
|
|
94
|
+
['calibration', ['bench', 'check', previewBench, '--calibrate', '--task', 'example-task', '--max-calls', '1', '--input', 'workspace', '--run-group', 'preview-calibration']],
|
|
95
|
+
['trigger', ['eval', skill, '--mode', 'trigger', '--bench', previewBench, '--task', 'example-task', '--task', 'negative-task', '--max-calls', '2', '--run-group', 'preview-trigger']],
|
|
247
96
|
];
|
|
248
97
|
for (const [mode, args] of previewRows) {
|
|
249
98
|
const child = cli([...args, ...settings]);
|
|
250
|
-
const report = JSON.parse(child.stdout),
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
assert.
|
|
254
|
-
|
|
255
|
-
assert.equal(evaluation.agentPreflight.status, "blocked");
|
|
256
|
-
assert.ok(
|
|
257
|
-
evaluation.agentPreflight.checks.some(
|
|
258
|
-
(check) => check.code === "CLI_AVAILABLE" && check.status === "FAIL",
|
|
259
|
-
),
|
|
260
|
-
);
|
|
261
|
-
assert.ok(
|
|
262
|
-
evaluation.agentPreflight.checks.some(
|
|
263
|
-
(check) => check.code === "AUTHENTICATION" && check.status === "UNKNOWN",
|
|
264
|
-
),
|
|
265
|
-
);
|
|
99
|
+
const report = JSON.parse(child.stdout), plan = report.plan, evaluation = plan.evaluation ?? plan;
|
|
100
|
+
assert.equal(report.status, 'planned'); noAdoption(report);
|
|
101
|
+
assert.equal(evaluation.agentPreflight.status, 'blocked');
|
|
102
|
+
assert.ok(evaluation.agentPreflight.checks.some(check => check.code === 'CLI_AVAILABLE' && check.status === 'FAIL'));
|
|
103
|
+
assert.ok(evaluation.agentPreflight.checks.some(check => check.code === 'AUTHENTICATION' && check.status === 'UNKNOWN'));
|
|
266
104
|
assert.deepEqual(evaluation.agentPreflight.cost, { modelCalls: 0, cliInvocations: 0 });
|
|
267
105
|
assert.equal(evaluation.executorTimeoutSeconds, 17);
|
|
268
|
-
assert.equal(evaluation.plannedCalls, mode ===
|
|
269
|
-
tests[`${mode}PublicPreview`] = {
|
|
270
|
-
status: report.status,
|
|
271
|
-
plannedCalls: evaluation.plannedCalls,
|
|
272
|
-
environment: "blocked",
|
|
273
|
-
authentication: "UNKNOWN",
|
|
274
|
-
modelCalls: 0,
|
|
275
|
-
agentCliCalls: 0,
|
|
276
|
-
};
|
|
106
|
+
assert.equal(evaluation.plannedCalls, mode === 'calibration' ? 1 : 2);
|
|
107
|
+
tests[`${mode}PublicPreview`] = { status: report.status, plannedCalls: evaluation.plannedCalls, environment: 'blocked', authentication: 'UNKNOWN', modelCalls: 0, agentCliCalls: 0 };
|
|
277
108
|
}
|
|
278
|
-
assert.equal(existsSync(sentinel), false);
|
|
279
|
-
assert.equal(
|
|
280
|
-
assert.equal(
|
|
281
|
-
Object.values(counts).reduce((sum, value) => sum + value, 0),
|
|
282
|
-
0,
|
|
283
|
-
);
|
|
109
|
+
assert.equal(existsSync(sentinel), false); assert.equal(existsSync(join(root, 'preview-runs')), false);
|
|
110
|
+
assert.equal(Object.values(counts).reduce((sum, value) => sum + value, 0), 0);
|
|
284
111
|
checks.publicPreviewsArePureWithoutAgentCli = true;
|
|
285
112
|
|
|
286
|
-
const broken = await fixture(
|
|
287
|
-
writeFileSync(join(broken,
|
|
288
|
-
await assert.rejects(
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
calibrate: {
|
|
294
|
-
executor: fake("calibrationHardFailure", final),
|
|
295
|
-
trials: 1,
|
|
296
|
-
maxCalls: 1,
|
|
297
|
-
runsRoot,
|
|
298
|
-
runGroup: "blocked-calibration",
|
|
299
|
-
},
|
|
300
|
-
}),
|
|
301
|
-
(error) =>
|
|
302
|
-
error.name === "CasePreflightFailed" &&
|
|
303
|
-
error.preflight.checks.some(
|
|
304
|
-
(check) => check.code === "UNTOUCHED_FIXTURE" && check.status === "FAIL",
|
|
305
|
-
),
|
|
306
|
-
);
|
|
307
|
-
assert.equal(counts.calibrationHardFailure, 0);
|
|
308
|
-
assert.equal(existsSync(join(runsRoot, "blocked-calibration")), false);
|
|
309
|
-
tests.calibrationHardFailure = {
|
|
310
|
-
gate: "UNTOUCHED_FIXTURE",
|
|
311
|
-
fakeCalls: 0,
|
|
312
|
-
nativeRunCreated: false,
|
|
313
|
-
modelCalls: 0,
|
|
314
|
-
};
|
|
113
|
+
const broken = await fixture('broken-command-bench', 'command');
|
|
114
|
+
writeFileSync(join(broken, 'verifiers/example-task.mjs'), 'process.exit(0);\n');
|
|
115
|
+
await assert.rejects(runBenchCalibration({ dir: broken, taskIds: ['example-task'], log: quiet,
|
|
116
|
+
calibrate: { executor: fake('calibrationHardFailure', final), trials: 1, maxCalls: 1, runsRoot, runGroup: 'blocked-calibration' } }),
|
|
117
|
+
error => error.name === 'CasePreflightFailed' && error.preflight.checks.some(check => check.code === 'UNTOUCHED_FIXTURE' && check.status === 'FAIL'));
|
|
118
|
+
assert.equal(counts.calibrationHardFailure, 0); assert.equal(existsSync(join(runsRoot, 'blocked-calibration')), false);
|
|
119
|
+
tests.calibrationHardFailure = { gate: 'UNTOUCHED_FIXTURE', fakeCalls: 0, nativeRunCreated: false, modelCalls: 0 };
|
|
315
120
|
checks.calibrationHardFailurePreventsSpending = true;
|
|
316
121
|
|
|
317
|
-
const bench = await fixture(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
dir: bench,
|
|
321
|
-
taskIds: ["example-task"],
|
|
322
|
-
log: quiet,
|
|
323
|
-
calibrate: {
|
|
324
|
-
executor: fake("calibration", final),
|
|
325
|
-
trials: 1,
|
|
326
|
-
maxCalls: 1,
|
|
327
|
-
spendingBudget: limits,
|
|
328
|
-
runsRoot,
|
|
329
|
-
runGroup: "calibration",
|
|
330
|
-
},
|
|
331
|
-
});
|
|
122
|
+
const bench = await fixture('bench'), originals = [];
|
|
123
|
+
await runBenchCalibration({ dir: bench, taskIds: ['example-task'], log: quiet,
|
|
124
|
+
calibrate: { executor: fake('calibration', final), trials: 1, maxCalls: 1, spendingBudget: limits, runsRoot, runGroup: 'calibration' } });
|
|
332
125
|
assert.equal(counts.calibration, 1);
|
|
333
|
-
originals.push({
|
|
334
|
-
name: "calibration",
|
|
335
|
-
mode: "calibration",
|
|
336
|
-
run: join(runsRoot, "calibration"),
|
|
337
|
-
calls: 1,
|
|
338
|
-
});
|
|
126
|
+
originals.push({ name: 'calibration', mode: 'calibration', run: join(runsRoot, 'calibration'), calls: 1 });
|
|
339
127
|
|
|
340
|
-
const checklist = JSON.stringify({
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
tokens: { input: 5, cachedInput: 1, output: 2 },
|
|
355
|
-
usageStatus: "final",
|
|
356
|
-
}),
|
|
357
|
-
spendingBudget: limits,
|
|
358
|
-
yes: true,
|
|
359
|
-
dryRun: false,
|
|
360
|
-
runsRoot,
|
|
361
|
-
runGroup: "paired-judge",
|
|
362
|
-
log: quiet,
|
|
363
|
-
});
|
|
364
|
-
assert.equal(counts.pairedAgent, 2);
|
|
365
|
-
assert.equal(counts.judge, 2);
|
|
366
|
-
const pairedRun = join(runsRoot, "paired-judge"),
|
|
367
|
-
paired = await readEvaluationReport(pairedRun);
|
|
368
|
-
assert.equal(paired.invocationCosts.agent.runs, 2);
|
|
369
|
-
assert.equal(paired.invocationCosts.judge.runs, 2);
|
|
370
|
-
assert.equal(paired.invocationCosts.total.runs, 4);
|
|
371
|
-
assert.equal(paired.invocationCosts.agent.metrics.input.knownTotal, 20);
|
|
372
|
-
assert.equal(paired.invocationCosts.judge.metrics.input.knownTotal, 10);
|
|
373
|
-
assert.equal(paired.invocationCosts.total.metrics.input.knownTotal, 30);
|
|
374
|
-
assert.equal(paired.invocationCosts.total.metrics.cachedInput.knownTotal, 6);
|
|
375
|
-
assert.equal(paired.invocationCosts.total.metrics.uncachedInput.knownTotal, 24);
|
|
376
|
-
assert.equal(paired.invocationCosts.total.metrics.output.knownTotal, 10);
|
|
377
|
-
for (const metric of ["input", "cachedInput", "uncachedInput", "output", "durationSeconds"])
|
|
378
|
-
assert.equal(paired.invocationCosts.total.metrics[metric].coverage.final, 4);
|
|
379
|
-
assert.equal(ledger(pairedRun).filter((event) => event.event === "started").length, 4);
|
|
380
|
-
for (const index of [1, 2])
|
|
381
|
-
assert.equal(
|
|
382
|
-
json(join(pairedRun, `example-task/judge-trial-1/call-${index}.json`)).usageStatus,
|
|
383
|
-
"final",
|
|
384
|
-
);
|
|
385
|
-
tests.pairedJudge = {
|
|
386
|
-
fakeAgentCalls: 2,
|
|
387
|
-
fakeJudgeCalls: 2,
|
|
388
|
-
totalCalls: 4,
|
|
389
|
-
invocationCosts: paired.invocationCosts,
|
|
390
|
-
modelCalls: 0,
|
|
391
|
-
};
|
|
128
|
+
const checklist = JSON.stringify({ A: { correct: true, complete: true, grounded: true }, B: { correct: true, complete: true, grounded: true } });
|
|
129
|
+
await runEval({ skillPath: skill, bench, taskIds: ['example-task'], trials: 1, maxCalls: 4,
|
|
130
|
+
executor: fake('pairedAgent', final), judgeExecutor: fake('judge', { output: checklist, rawOutput: 'offline judge transcript', tokens: { input: 5, cachedInput: 1, output: 2 }, usageStatus: 'final' }),
|
|
131
|
+
spendingBudget: limits, yes: true, dryRun: false, runsRoot, runGroup: 'paired-judge', log: quiet });
|
|
132
|
+
assert.equal(counts.pairedAgent, 2); assert.equal(counts.judge, 2);
|
|
133
|
+
const pairedRun = join(runsRoot, 'paired-judge'), paired = await readEvaluationReport(pairedRun);
|
|
134
|
+
assert.equal(paired.invocationCosts.agent.runs, 2); assert.equal(paired.invocationCosts.judge.runs, 2); assert.equal(paired.invocationCosts.total.runs, 4);
|
|
135
|
+
assert.equal(paired.invocationCosts.agent.metrics.input.knownTotal, 20); assert.equal(paired.invocationCosts.judge.metrics.input.knownTotal, 10);
|
|
136
|
+
assert.equal(paired.invocationCosts.total.metrics.input.knownTotal, 30); assert.equal(paired.invocationCosts.total.metrics.cachedInput.knownTotal, 6);
|
|
137
|
+
assert.equal(paired.invocationCosts.total.metrics.uncachedInput.knownTotal, 24); assert.equal(paired.invocationCosts.total.metrics.output.knownTotal, 10);
|
|
138
|
+
for (const metric of ['input', 'cachedInput', 'uncachedInput', 'output', 'durationSeconds']) assert.equal(paired.invocationCosts.total.metrics[metric].coverage.final, 4);
|
|
139
|
+
assert.equal(ledger(pairedRun).filter(event => event.event === 'started').length, 4);
|
|
140
|
+
for (const index of [1, 2]) assert.equal(json(join(pairedRun, `example-task/judge-trial-1/call-${index}.json`)).usageStatus, 'final');
|
|
141
|
+
tests.pairedJudge = { fakeAgentCalls: 2, fakeJudgeCalls: 2, totalCalls: 4, invocationCosts: paired.invocationCosts, modelCalls: 0 };
|
|
392
142
|
checks.judgeBothOrdersRetainCompleteRoleAndTotalCosts = true;
|
|
393
|
-
originals.push({ name:
|
|
143
|
+
originals.push({ name: 'paired-judge', mode: 'paired', run: pairedRun, calls: 4 });
|
|
394
144
|
|
|
395
145
|
for (const [name, counter, response, expected] of [
|
|
396
|
-
[
|
|
397
|
-
[
|
|
398
|
-
|
|
399
|
-
"triggerPartial",
|
|
400
|
-
{
|
|
401
|
-
output: final.output,
|
|
402
|
-
skillTriggered: true,
|
|
403
|
-
tokens: { input: 7, output: 2 },
|
|
404
|
-
usageStatus: "partial",
|
|
405
|
-
},
|
|
406
|
-
"FINAL_USAGE_MISSING",
|
|
407
|
-
],
|
|
408
|
-
[
|
|
409
|
-
"trigger-unknown",
|
|
410
|
-
"triggerUnknown",
|
|
411
|
-
{ output: final.output, skillTriggered: true, usageStatus: "unknown" },
|
|
412
|
-
"FINAL_USAGE_MISSING",
|
|
413
|
-
],
|
|
146
|
+
['trigger-line', 'triggerLine', { ...final, skillTriggered: true }, 'SPENDING_BUDGET_REACHED'],
|
|
147
|
+
['trigger-partial', 'triggerPartial', { output: final.output, skillTriggered: true, tokens: { input: 7, output: 2 }, usageStatus: 'partial' }, 'FINAL_USAGE_MISSING'],
|
|
148
|
+
['trigger-unknown', 'triggerUnknown', { output: final.output, skillTriggered: true, usageStatus: 'unknown' }, 'FINAL_USAGE_MISSING'],
|
|
414
149
|
]) {
|
|
415
|
-
const options = {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
taskIds: ["example-task"],
|
|
419
|
-
mode: "trigger",
|
|
420
|
-
skillInstallDir: ".offline-skills",
|
|
421
|
-
executor: fake(counter, response),
|
|
422
|
-
judgeExecutor: null,
|
|
423
|
-
trials: 3,
|
|
424
|
-
maxCalls: 3,
|
|
425
|
-
spendingBudget: { ...limits, input: name === "trigger-line" ? 10 : 1000 },
|
|
426
|
-
yes: true,
|
|
427
|
-
runsRoot,
|
|
428
|
-
runGroup: name,
|
|
429
|
-
log: quiet,
|
|
430
|
-
};
|
|
150
|
+
const options = { skillPath: skill, bench, taskIds: ['example-task'], mode: 'trigger', skillInstallDir: '.offline-skills',
|
|
151
|
+
executor: fake(counter, response), judgeExecutor: null, trials: 3, maxCalls: 3, spendingBudget: { ...limits, input: name === 'trigger-line' ? 10 : 1000 },
|
|
152
|
+
yes: true, runsRoot, runGroup: name, log: quiet };
|
|
431
153
|
const preview = await runEvalCli({ ...options, dryRun: true });
|
|
432
154
|
assert.equal(counts[counter], 0);
|
|
433
155
|
const report = await runEvalCli({ ...options, dryRun: false }, preview.plan.sha256);
|
|
434
|
-
assert.equal(report.status,
|
|
435
|
-
|
|
436
|
-
assert.equal(
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
session = json(join(run, "_session.json"));
|
|
440
|
-
assert.equal(session.callsStarted, 1);
|
|
441
|
-
assert.equal(session.stopCode, expected);
|
|
442
|
-
assert.equal(ledger(run).filter((event) => event.event === "started").length, 1);
|
|
443
|
-
assert.equal(existsSync(join(run, "example-task/installed/trial-2")), false);
|
|
156
|
+
assert.equal(report.status, 'stopped'); assert.equal(report.evaluationType, 'trigger'); assert.equal(counts[counter], 1); noAdoption(report);
|
|
157
|
+
const run = join(runsRoot, name), session = json(join(run, '_session.json'));
|
|
158
|
+
assert.equal(session.callsStarted, 1); assert.equal(session.stopCode, expected);
|
|
159
|
+
assert.equal(ledger(run).filter(event => event.event === 'started').length, 1);
|
|
160
|
+
assert.equal(existsSync(join(run, 'example-task/installed/trial-2')), false);
|
|
444
161
|
assert.equal(report.usage.runs, 1);
|
|
445
|
-
if (name ===
|
|
162
|
+
if (name === 'trigger-line') assert.equal(report.usage.metrics.input.knownTotal, 10);
|
|
446
163
|
else {
|
|
447
164
|
assert.equal(report.usage.metrics.cachedInput.coverage.unknown, 1);
|
|
448
|
-
assert.equal(
|
|
449
|
-
report.usage.metrics.input.coverage[name === "trigger-partial" ? "partial" : "unknown"],
|
|
450
|
-
1,
|
|
451
|
-
);
|
|
165
|
+
assert.equal(report.usage.metrics.input.coverage[name === 'trigger-partial' ? 'partial' : 'unknown'], 1);
|
|
452
166
|
}
|
|
453
|
-
tests[name] = {
|
|
454
|
-
|
|
455
|
-
stopCode: session.stopCode,
|
|
456
|
-
fakeCalls: 1,
|
|
457
|
-
usage: report.usage,
|
|
458
|
-
modelCalls: 0,
|
|
459
|
-
};
|
|
460
|
-
originals.push({ name, mode: "trigger", run, calls: 1 });
|
|
167
|
+
tests[name] = { status: report.status, stopCode: session.stopCode, fakeCalls: 1, usage: report.usage, modelCalls: 0 };
|
|
168
|
+
originals.push({ name, mode: 'trigger', run, calls: 1 });
|
|
461
169
|
}
|
|
462
170
|
checks.triggerBudgetAndIncompleteUsageStopWithoutRetries = true;
|
|
463
171
|
|
|
464
172
|
for (const item of originals) {
|
|
465
|
-
item.report = await readEvaluationReport(item.run);
|
|
466
|
-
noAdoption(item.report);
|
|
173
|
+
item.report = await readEvaluationReport(item.run); noAdoption(item.report);
|
|
467
174
|
assert.equal(item.report.evidence.verified, true, JSON.stringify(item.report.evidence));
|
|
468
|
-
item.costs = snapshotCosts(item.report);
|
|
469
|
-
item.nativeFiles = files(item.run);
|
|
175
|
+
item.costs = snapshotCosts(item.report); item.nativeFiles = files(item.run);
|
|
470
176
|
}
|
|
471
177
|
const frozenCounts = structuredClone(counts);
|
|
472
|
-
rmSync(bench, { recursive: true });
|
|
473
|
-
rmSync(skill, { recursive: true });
|
|
178
|
+
rmSync(bench, { recursive: true }); rmSync(skill, { recursive: true });
|
|
474
179
|
for (const item of originals) {
|
|
475
|
-
const output = join(root, `export-${item.name}`),
|
|
476
|
-
moved = join(root, `moved ${item.name}`);
|
|
180
|
+
const output = join(root, `export-${item.name}`), moved = join(root, `moved ${item.name}`);
|
|
477
181
|
const plan = await exportEvaluation(item.run, output, { log: quiet });
|
|
478
|
-
assert.equal(plan.status,
|
|
479
|
-
assert.equal(plan.inputSource, "sealed-snapshot");
|
|
480
|
-
assert.equal(existsSync(output), false);
|
|
182
|
+
assert.equal(plan.status, 'planned'); assert.equal(plan.inputSource, 'sealed-snapshot'); assert.equal(existsSync(output), false);
|
|
481
183
|
await exportEvaluation(item.run, output, { yes: true, log: quiet });
|
|
482
|
-
assert.deepEqual(
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
renameSync(output, moved);
|
|
488
|
-
rmSync(item.run, { recursive: true });
|
|
489
|
-
const reproduce = (args) => {
|
|
490
|
-
const child = spawnSync(process.execPath, [join(moved, "reproduce.mjs"), ...args], {
|
|
491
|
-
cwd: root,
|
|
492
|
-
env: replayEnv,
|
|
493
|
-
encoding: "utf8",
|
|
494
|
-
timeout: 60_000,
|
|
495
|
-
maxBuffer: 16 * 1024 * 1024,
|
|
496
|
-
});
|
|
497
|
-
assert.equal(child.status, 0, child.stderr || child.stdout);
|
|
498
|
-
return JSON.parse(child.stdout);
|
|
184
|
+
assert.deepEqual(files(item.run), item.nativeFiles, 'Export must preserve original native evidence.');
|
|
185
|
+
renameSync(output, moved); rmSync(item.run, { recursive: true });
|
|
186
|
+
const reproduce = args => {
|
|
187
|
+
const child = spawnSync(process.execPath, [join(moved, 'reproduce.mjs'), ...args], { cwd: root, env: replayEnv, encoding: 'utf8', timeout: 60_000, maxBuffer: 16 * 1024 * 1024 });
|
|
188
|
+
assert.equal(child.status, 0, child.stderr || child.stdout); return JSON.parse(child.stdout);
|
|
499
189
|
};
|
|
500
|
-
assert.equal(reproduce([
|
|
190
|
+
assert.equal(reproduce(['--verify-only']).modelCalls, 0);
|
|
501
191
|
const replayed = reproduce([]);
|
|
502
|
-
assert.equal(replayed.evidence.verified, true, JSON.stringify(replayed.evidence));
|
|
503
|
-
assert.
|
|
504
|
-
assert.
|
|
505
|
-
noAdoption(replayed);
|
|
506
|
-
assert.equal(replayed.portableReplay.modelCalls, 0);
|
|
507
|
-
assert.deepEqual(counts, frozenCounts);
|
|
192
|
+
assert.equal(replayed.evidence.verified, true, JSON.stringify(replayed.evidence)); assert.equal(replayed.status, item.report.status);
|
|
193
|
+
assert.deepEqual(snapshotCosts(replayed), item.costs); noAdoption(replayed);
|
|
194
|
+
assert.equal(replayed.portableReplay.modelCalls, 0); assert.deepEqual(counts, frozenCounts);
|
|
508
195
|
// The public report also regrades trusted Node verifiers, so it receives
|
|
509
196
|
// the replay environment rather than the empty-PATH preview environment.
|
|
510
|
-
const inspectedChild = spawnSync(
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
{ cwd: root, env: replayEnv, encoding: "utf8", timeout: 60_000, maxBuffer: 16 * 1024 * 1024 },
|
|
514
|
-
);
|
|
515
|
-
skillfitCliCalls++;
|
|
516
|
-
assert.equal(inspectedChild.status, 0, inspectedChild.stderr || inspectedChild.stdout);
|
|
197
|
+
const inspectedChild = spawnSync(process.execPath, [join(installed, 'dist/cli.js'), 'report', 'eval', moved, '--json', '--replay'],
|
|
198
|
+
{ cwd: root, env: replayEnv, encoding: 'utf8', timeout: 60_000, maxBuffer: 16 * 1024 * 1024 });
|
|
199
|
+
skillfitCliCalls++; assert.equal(inspectedChild.status, 0, inspectedChild.stderr || inspectedChild.stdout);
|
|
517
200
|
const inspected = JSON.parse(inspectedChild.stdout);
|
|
518
|
-
assert.equal(inspected.portablePackage.integrityVerified, true);
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
tests[`${item.name}PortableReplay`] = {
|
|
522
|
-
evaluationType: item.mode,
|
|
523
|
-
status: replayed.status,
|
|
524
|
-
deletedOriginalInputs: true,
|
|
525
|
-
deletedOriginalRun: true,
|
|
526
|
-
movedPackage: true,
|
|
527
|
-
exactCostsRetained: true,
|
|
201
|
+
assert.equal(inspected.portablePackage.integrityVerified, true); assert.deepEqual(snapshotCosts(inspected), item.costs); noAdoption(inspected);
|
|
202
|
+
tests[`${item.name}PortableReplay`] = { evaluationType: item.mode, status: replayed.status,
|
|
203
|
+
deletedOriginalInputs: true, deletedOriginalRun: true, movedPackage: true, exactCostsRetained: true,
|
|
528
204
|
retainedCosts: item.costs,
|
|
529
|
-
fakeCallsBeforeReplay: item.calls,
|
|
530
|
-
additionalFakeCalls: 0,
|
|
531
|
-
modelCalls: 0,
|
|
532
|
-
eligibleForUpgrade: false,
|
|
533
|
-
automaticUpgrade: false,
|
|
534
|
-
};
|
|
205
|
+
fakeCallsBeforeReplay: item.calls, additionalFakeCalls: 0, modelCalls: 0, eligibleForUpgrade: false, automaticUpgrade: false };
|
|
535
206
|
}
|
|
536
207
|
checks.allModesMoveDeleteOriginalReplayWithExactCosts = true;
|
|
537
208
|
checks.noAdoptionFromSyntheticOrStoppedEvidence = true;
|
|
538
|
-
assert.equal(networkAttempts, 0);
|
|
539
|
-
assert.
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
version: "0.11.0",
|
|
548
|
-
verifiedAt: new Date().toISOString(),
|
|
549
|
-
nodeVersion: process.version,
|
|
550
|
-
packagePath: installed,
|
|
551
|
-
implementationSha256: hashFileSet(
|
|
552
|
-
join(installed, "dist"),
|
|
553
|
-
listFilesRecursive(join(installed, "dist")),
|
|
554
|
-
),
|
|
555
|
-
scope:
|
|
556
|
-
"Offline check of the caller-supplied package; no registry/publication claim or Skill efficacy evidence.",
|
|
557
|
-
modelCalls: 0,
|
|
558
|
-
agentCliCalls: 0,
|
|
559
|
-
networkAttempts,
|
|
560
|
-
skillfitCliCalls,
|
|
561
|
-
syntheticExecutorCalls: Object.values(counts).reduce((sum, value) => sum + value, 0),
|
|
562
|
-
fakeCallCounts: counts,
|
|
563
|
-
checks,
|
|
564
|
-
tests,
|
|
565
|
-
};
|
|
566
|
-
writeFileSync(join(parent, "feature-smoke.json"), JSON.stringify(receipt, null, 2) + "\n", {
|
|
567
|
-
flag: "wx",
|
|
568
|
-
});
|
|
209
|
+
assert.equal(networkAttempts, 0); assert.deepEqual(counts, frozenCounts);
|
|
210
|
+
assert.equal(Object.values(counts).reduce((sum, value) => sum + value, 0), 8);
|
|
211
|
+
const receipt = { schemaVersion: 1, kind: 'skillfit.release-foundations-smoke', version: '0.11.0',
|
|
212
|
+
verifiedAt: new Date().toISOString(), nodeVersion: process.version,
|
|
213
|
+
packagePath: installed, implementationSha256: hashFileSet(join(installed, 'dist'), listFilesRecursive(join(installed, 'dist'))),
|
|
214
|
+
scope: 'Offline check of the caller-supplied package; no registry/publication claim or Skill efficacy evidence.',
|
|
215
|
+
modelCalls: 0, agentCliCalls: 0, networkAttempts, skillfitCliCalls,
|
|
216
|
+
syntheticExecutorCalls: Object.values(counts).reduce((sum, value) => sum + value, 0), fakeCallCounts: counts, checks, tests };
|
|
217
|
+
writeFileSync(join(parent, 'feature-smoke.json'), JSON.stringify(receipt, null, 2) + '\n', { flag: 'wx' });
|
|
569
218
|
rmSync(root, { recursive: true, force: true });
|
|
570
219
|
console.log(JSON.stringify(receipt));
|
|
571
220
|
} finally {
|