skillfit 0.11.0 → 0.13.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 +68 -104
- package/README.zh-CN.md +68 -101
- package/benches/README.md +6 -2
- package/dist/cli.js +28 -16
- package/dist/commands/bench-calibration.js +5 -1
- package/dist/commands/bench-check-report.js +1 -34
- 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 +157 -328
- package/dist/commands/eval-api-failure.test.js +46 -0
- package/dist/commands/eval-layout.test.js +126 -0
- package/dist/commands/eval-preflight-error.js +9 -0
- package/dist/commands/eval-preflight.js +4 -11
- package/dist/commands/eval-report.js +6 -459
- package/dist/commands/eval.js +7 -32
- package/dist/commands/install.js +14 -98
- package/dist/harness/agent-preflight.js +18 -2
- package/dist/harness/bench-check.js +277 -0
- package/dist/harness/bench-diagnostics.js +34 -0
- package/dist/harness/bench-location.js +29 -0
- package/dist/harness/bench-location.test.js +33 -0
- package/dist/harness/bench.js +8 -3
- package/dist/harness/eval-acceptance.js +1 -1
- package/dist/harness/eval-audit.js +2 -2
- package/dist/harness/eval-manifest.js +456 -0
- package/dist/harness/evaluation-layout.js +30 -0
- package/dist/harness/executors/api.js +20 -7
- package/dist/harness/executors/cli.js +15 -25
- package/dist/harness/experiment-session.js +5 -15
- package/dist/harness/hash.js +3 -1
- package/dist/harness/runner.js +5 -4
- package/dist/harness/single-arm-audit.js +1 -1
- package/dist/harness/trigger.js +1 -1
- package/dist/harness/verifier-timeout.js +8 -0
- package/dist/harness/verifier-timeout.test.js +76 -0
- package/dist/install/constants.js +1 -0
- package/dist/install/transaction.js +112 -0
- package/docs/README.md +65 -0
- package/docs/architecture.md +86 -0
- package/docs/archive-delivery.md +83 -0
- package/docs/archive-inventory.md +91 -0
- package/docs/bench-authoring.md +23 -3
- package/docs/bench-drafting.md +75 -0
- package/docs/case-management.md +12 -1
- package/docs/eval-agent-preflight.md +15 -2
- package/docs/eval-costs.md +28 -2
- package/docs/eval-planning.md +14 -0
- package/docs/evaluation-input-snapshots.md +20 -4
- package/docs/evaluation-reports.md +1 -1
- package/docs/first-real-eval.md +28 -3
- package/docs/growth-roadmap-2026-10.md +23 -18
- package/docs/package-contents.md +73 -0
- package/docs/plans/2026-10-17-workflow-foundations.md +37 -2
- package/docs/plans/2026-10-20-archive-replay-verification.json +125 -0
- package/docs/plans/2026-10-20-archive-source-verification.json +256 -0
- package/docs/plans/2026-10-20-delivery-verification.json +146 -0
- package/docs/plans/2026-10-20-docs-architecture-cleanup.md +233 -0
- package/docs/plans/2026-10-20-install-transactions-and-archive-delivery.md +233 -0
- package/docs/plans/2026-10-21-npm-0.13.0-release.md +41 -0
- 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-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 +54 -11
- package/docs/releases/0.12.0-attestation-check.json +22 -0
- package/docs/releases/0.12.0-attestations.json +155 -0
- package/docs/releases/0.12.0-ci-registry-install.json +90 -0
- package/docs/releases/0.12.0-feature-smoke.json +34 -0
- package/docs/releases/0.12.0-feature-smoke.mjs +73 -0
- package/docs/releases/0.12.0-foundations-smoke.json +1576 -0
- package/docs/releases/0.12.0-local-registry-install.json +75 -0
- package/docs/releases/0.12.0-preparation-attempt-1.json +22 -0
- package/docs/releases/0.12.0-registry-metadata.json +96 -0
- package/docs/releases/0.12.0-signatures.txt +6 -0
- package/docs/releases/0.12.0-verification.json +99 -0
- package/docs/releases/0.12.0.md +82 -0
- package/docs/releases/0.13.0-feature-smoke.mjs +114 -0
- package/docs/releases/0.13.0-preparation.json +102 -0
- package/docs/releases/0.13.0.md +61 -0
- package/docs/releases/archive-delivery-smoke.mjs +37 -0
- package/docs/reproducible-offline-example.md +1 -1
- package/docs/schemas/agent-preflight.schema.json +1 -1
- package/docs/verifier-contract.md +9 -0
- package/evidence/README.md +24 -1
- package/evidence/archive-catalog.v1.json +8044 -0
- package/evidence/fetch-archives.mjs +211 -0
- package/package.json +9 -2
- package/skills/skillfit/SKILL.md +25 -5
- package/dist/cli.test.js +0 -193
- package/dist/commands/bench-calibration.test.js +0 -237
- package/dist/commands/bench-check-json.test.js +0 -242
- package/dist/commands/bench-manage.test.js +0 -87
- package/dist/commands/bench.test.js +0 -1162
- package/dist/commands/bundle.test.js +0 -142
- package/dist/commands/calibration-cli.test.js +0 -145
- package/dist/commands/doctor.test.js +0 -280
- package/dist/commands/eval-agent-preflight.test.js +0 -245
- package/dist/commands/eval-export-modes.test.js +0 -350
- package/dist/commands/eval-export.test.js +0 -279
- package/dist/commands/eval-interruption.test.js +0 -238
- package/dist/commands/eval-preflight.test.js +0 -382
- package/dist/commands/eval-report.test.js +0 -367
- package/dist/commands/eval.test.js +0 -503
- package/dist/commands/evaluation-report.test.js +0 -243
- package/dist/commands/install.test.js +0 -555
- package/dist/commands/replay-cancellation.test.js +0 -105
- package/dist/commands/report.test.js +0 -110
- package/dist/commands/setup.test.js +0 -150
- package/dist/commands/upstream.test.js +0 -139
- package/dist/commands/workflow-entrypoints.test.js +0 -137
- package/dist/docs.test.js +0 -154
- package/dist/frontmatter.test.js +0 -49
- package/dist/harness/bench.test.js +0 -109
- package/dist/harness/bundle.test.js +0 -71
- package/dist/harness/codex-usage.test.js +0 -87
- package/dist/harness/costs.test.js +0 -92
- package/dist/harness/eval-budget.test.js +0 -237
- package/dist/harness/eval-component.test.js +0 -770
- package/dist/harness/eval-efficiency.test.js +0 -56
- package/dist/harness/execution-timing.test.js +0 -61
- package/dist/harness/executors/api.test.js +0 -136
- package/dist/harness/executors/cli.test.js +0 -510
- package/dist/harness/executors/mock.test.js +0 -43
- package/dist/harness/experiment-session.test.js +0 -317
- package/dist/harness/installed-skill.test.js +0 -162
- package/dist/harness/interruption.test.js +0 -31
- package/dist/harness/judge-accounting.test.js +0 -216
- package/dist/harness/judge.test.js +0 -181
- package/dist/harness/kimi-usage.test.js +0 -62
- package/dist/harness/native-diff.test.js +0 -53
- package/dist/harness/oss-lru-cache.test.js +0 -79
- package/dist/harness/oss-normalize-url.test.js +0 -64
- package/dist/harness/oss-regression-witness.test.js +0 -89
- package/dist/harness/oss-skill-followup.test.js +0 -59
- package/dist/harness/prompt.test.js +0 -48
- package/dist/harness/receipts.test.js +0 -148
- package/dist/harness/report.test.js +0 -297
- package/dist/harness/runner.test.js +0 -635
- package/dist/harness/skill-revision.test.js +0 -148
- package/dist/harness/stats.test.js +0 -124
- package/dist/harness/target.test.js +0 -60
- package/dist/harness/trigger.test.js +0 -261
- package/dist/harness/verifier-summary.test.js +0 -99
- package/dist/harness/verifier.test.js +0 -128
- package/dist/harness/waza-behavior.test.js +0 -139
- package/dist/mcp/probe.test.js +0 -139
- package/evidence/artifacts/2026-10-12-diagnosing-revision/calibration-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-diagnosing-revision/interrupted-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-diagnosing-revision/validation-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-diagnosing-v2/regression-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-diagnosing-v2/transfer-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-normalize-url-v2-available/readiness-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-normalize-url-v2-comparison/records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-normalize-url-v2-recovery/records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-normalize-url-v2-validated/records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-13-debugging-completed-development/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-13-debugging-controls-and-sleep-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-13-debugging-development-stops/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-14-debugging-followup-routing-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-14-debugging-independent-validation/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-14-debugging-reading-pilot-and-cost-review/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-14-debugging-spending-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/package.tar.gz +0 -0
package/dist/commands/bench.js
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import {
|
|
2
|
+
import { inspectBenchIntegrity, copyFixture, runOracleGate } from '../harness/bench-check.js';
|
|
3
|
+
import { CasePreflightFailed } from './eval-preflight-error.js';
|
|
4
|
+
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
5
|
import { tmpdir } from 'node:os';
|
|
4
6
|
import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path';
|
|
5
|
-
import { loadBench, selectBenchTasks } from '../harness/bench.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { BENCH_SCHEMA_VERSION, loadBench, selectBenchTasks, validateBenchTask } from '../harness/bench.js';
|
|
8
|
+
import { resolveBenchDir } from '../harness/bench-location.js';
|
|
9
|
+
import { sha256File, sha256Text } from '../harness/hash.js';
|
|
8
10
|
import { runVerifier, verifierFailure } from '../harness/runner.js';
|
|
9
11
|
import { MOCK_MARKER_FILE } from '../harness/constants.js';
|
|
10
|
-
import { verdictFromOutput } from '../harness/verifier-summary.js';
|
|
11
12
|
import { confirm as confirmPrompt } from './confirm.js';
|
|
12
13
|
import { commandTemplateFiles } from './bench-command-template.js';
|
|
13
|
-
import { benchDiagnostic
|
|
14
|
+
import { benchDiagnostic } from '../harness/bench-diagnostics.js';
|
|
14
15
|
import { BACKUP_SUFFIX } from './install.js';
|
|
15
16
|
import { withEvaluationInterrupts, throwIfEvaluationInterrupted } from '../harness/interruption.js';
|
|
16
17
|
import { assertAgentEnvironment, renderAgentEnvironment } from '../harness/agent-preflight.js';
|
|
17
18
|
import { calibrationCasePreflight, executeCalibration, prepareCalibration } from './bench-calibration.js';
|
|
19
|
+
import { freezeSourceFiles } from './bench-source.js';
|
|
20
|
+
import { BenchDraftSession } from './bench-draft.js';
|
|
21
|
+
import { parseVerifierTimeoutSeconds } from '../harness/verifier-timeout.js';
|
|
22
|
+
export { captureSourceFiles } from './bench-source.js';
|
|
18
23
|
export { prepareBenchCalibration } from './bench-calibration.js';
|
|
19
|
-
const FIXTURE_SIZE_WARN_BYTES = 64 * 1024;
|
|
20
|
-
// benches/README.md: a verifier decomposes its acceptance criteria into 2–8 named checks.
|
|
21
|
-
const MIN_FACET_CHECKS = 2;
|
|
22
|
-
const MAX_FACET_CHECKS = 8;
|
|
23
|
-
// docs/metrics.md: >=30% of trigger-labelled tasks should be negative controls.
|
|
24
|
-
const NEGATIVE_CONTROL_TARGET = 0.3;
|
|
25
|
-
const NEGATIVE_CONTROL_PERCENT = 30;
|
|
26
24
|
function templateFiles(benchName) {
|
|
27
25
|
return {
|
|
28
26
|
'bench.json': `${JSON.stringify({
|
|
@@ -142,112 +140,6 @@ export async function runBenchInit(options) {
|
|
|
142
140
|
log('This is a teaching case. Replace it with your own task before measuring Skill benefit.');
|
|
143
141
|
return { dir, created };
|
|
144
142
|
}
|
|
145
|
-
async function probeVerifier(benchDir, verifier, output) {
|
|
146
|
-
const dir = mkdtempSync(join(tmpdir(), 'skillfit-check-'));
|
|
147
|
-
try {
|
|
148
|
-
if (output !== null) {
|
|
149
|
-
writeFileSync(join(dir, '_output.md'), output, 'utf8');
|
|
150
|
-
}
|
|
151
|
-
const result = await runVerifier(benchDir, verifier, dir);
|
|
152
|
-
return {
|
|
153
|
-
exitCode: result.exitCode,
|
|
154
|
-
error: result.error,
|
|
155
|
-
output: result.output,
|
|
156
|
-
checks: verdictFromOutput(result.output)?.checks ?? null,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
finally {
|
|
160
|
-
rmSync(dir, { recursive: true, force: true });
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
function facetCountCheck(taskId, checks) {
|
|
164
|
-
// `checks` is optional in the verifier contract; with no checks there is no graded signal to gate.
|
|
165
|
-
if (checks === null)
|
|
166
|
-
return null;
|
|
167
|
-
if (checks.length >= MIN_FACET_CHECKS && checks.length <= MAX_FACET_CHECKS) {
|
|
168
|
-
return {
|
|
169
|
-
status: 'PASS',
|
|
170
|
-
message: `${taskId}: ${checks.length} facet check(s), within the ${MIN_FACET_CHECKS}–${MAX_FACET_CHECKS} contract`,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
const why = checks.length < MIN_FACET_CHECKS
|
|
174
|
-
? 'a single check is binary pass/fail in facet costume — it carries none of the graded signal facet scores exist to provide'
|
|
175
|
-
: 'the trial score is dominated by whatever these checks happen to measure, and the per-facet table stops being readable';
|
|
176
|
-
return {
|
|
177
|
-
status: 'WARN',
|
|
178
|
-
message: `${taskId}: ${checks.length} facet check(s) — outside the ${MIN_FACET_CHECKS}–${MAX_FACET_CHECKS} range in benches/README.md (${why})`,
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
function copyFixture(fixtureDir, dest) {
|
|
182
|
-
for (const rel of listFilesRecursive(fixtureDir)) {
|
|
183
|
-
const target = join(dest, rel);
|
|
184
|
-
mkdirSync(dirname(target), { recursive: true });
|
|
185
|
-
writeFileSync(target, readFileSync(join(fixtureDir, rel)));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
async function runOracleGate(benchDir, fixtureDir, oracle, verifier) {
|
|
189
|
-
const dir = mkdtempSync(join(tmpdir(), 'skillfit-check-'));
|
|
190
|
-
try {
|
|
191
|
-
copyFixture(fixtureDir, dir);
|
|
192
|
-
const oracleRun = await runVerifier(benchDir, oracle, dir);
|
|
193
|
-
if (oracleRun.error !== null || oracleRun.exitCode !== 0) {
|
|
194
|
-
return {
|
|
195
|
-
kind: 'oracle-failed',
|
|
196
|
-
result: oracleRun,
|
|
197
|
-
command: oracle,
|
|
198
|
-
exitCode: oracleRun.exitCode,
|
|
199
|
-
reason: oracleRun.error !== null || oracleRun.exitCode === null ? verifierFailure('oracle', oracle, oracleRun.error) : null,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
const graded = await runVerifier(benchDir, verifier, dir);
|
|
203
|
-
if (graded.error !== null || graded.exitCode !== 0) {
|
|
204
|
-
return {
|
|
205
|
-
kind: 'verifier-failed',
|
|
206
|
-
result: graded,
|
|
207
|
-
command: verifier,
|
|
208
|
-
reason: graded.error !== null || graded.exitCode === null ? verifierFailure('verifier', verifier, graded.error) : null,
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
const score = verdictFromOutput(graded.output)?.score ?? null;
|
|
212
|
-
if (score !== null && score < 1) {
|
|
213
|
-
return { kind: 'low-score', score, result: graded, command: verifier };
|
|
214
|
-
}
|
|
215
|
-
return { kind: 'pass', score, result: graded, command: verifier };
|
|
216
|
-
}
|
|
217
|
-
finally {
|
|
218
|
-
rmSync(dir, { recursive: true, force: true });
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
async function probeOracle(benchDir, fixture, oracle, verifier) {
|
|
222
|
-
const gate = await runOracleGate(benchDir, join(benchDir, fixture), oracle, verifier);
|
|
223
|
-
switch (gate.kind) {
|
|
224
|
-
case 'oracle-failed':
|
|
225
|
-
return {
|
|
226
|
-
status: 'FAIL',
|
|
227
|
-
evidence: benchCheckEvidence(gate.result, gate.command),
|
|
228
|
-
message: gate.reason ??
|
|
229
|
-
`oracle command itself failed (exit ${gate.exitCode}) — the reference solution cannot run`,
|
|
230
|
-
};
|
|
231
|
-
case 'verifier-failed':
|
|
232
|
-
return {
|
|
233
|
-
status: 'FAIL',
|
|
234
|
-
evidence: benchCheckEvidence(gate.result, gate.command),
|
|
235
|
-
message: gate.reason ?? 'oracle solution does not pass the verifier — the task is unwinnable or the oracle is stale',
|
|
236
|
-
};
|
|
237
|
-
case 'low-score':
|
|
238
|
-
return {
|
|
239
|
-
status: 'FAIL',
|
|
240
|
-
evidence: benchCheckEvidence(gate.result, gate.command),
|
|
241
|
-
message: `oracle passes the verifier but scores ${gate.score.toFixed(2)} on its checks — the checks are stricter than the exit code`,
|
|
242
|
-
};
|
|
243
|
-
case 'pass':
|
|
244
|
-
return {
|
|
245
|
-
status: 'PASS',
|
|
246
|
-
evidence: benchCheckEvidence(gate.result, gate.command),
|
|
247
|
-
message: `oracle solution passes the verifier${gate.score !== null ? ' with full checks' : ''}`,
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
143
|
function renderCheck({ status, message }) {
|
|
252
144
|
return `[${status}] ${message}`;
|
|
253
145
|
}
|
|
@@ -259,7 +151,7 @@ export async function runBenchCalibration(options) {
|
|
|
259
151
|
}
|
|
260
152
|
async function runBenchCheckWithinInterrupts(options, strictCalibration = false) {
|
|
261
153
|
const log = options.log ?? ((msg) => console.log(msg));
|
|
262
|
-
|
|
154
|
+
let dir = resolve(options.dir ?? '.');
|
|
263
155
|
const checks = [];
|
|
264
156
|
let identity = null;
|
|
265
157
|
const push = (code, status, message, task, evidence) => {
|
|
@@ -269,6 +161,7 @@ async function runBenchCheckWithinInterrupts(options, strictCalibration = false)
|
|
|
269
161
|
};
|
|
270
162
|
let bench;
|
|
271
163
|
try {
|
|
164
|
+
dir = resolveBenchDir(options.dir ?? '.');
|
|
272
165
|
bench = selectBenchTasks(loadBench(dir), options.taskIds ?? (options.calibrate ? options.calibrate.taskIds : undefined));
|
|
273
166
|
}
|
|
274
167
|
catch (error) {
|
|
@@ -297,125 +190,7 @@ async function runBenchCheckWithinInterrupts(options, strictCalibration = false)
|
|
|
297
190
|
}
|
|
298
191
|
}
|
|
299
192
|
const offlineStarted = performance.now();
|
|
300
|
-
|
|
301
|
-
let negativeTasks = 0;
|
|
302
|
-
for (const task of bench.tasks) {
|
|
303
|
-
const taskPush = (code, status, message, evidence) => push(code, status, message, task, evidence);
|
|
304
|
-
let facetChecks = null;
|
|
305
|
-
if ((task.verifierKind ?? 'output') === 'command') {
|
|
306
|
-
const fixtureCopy = mkdtempSync(join(tmpdir(), 'skillfit-check-'));
|
|
307
|
-
try {
|
|
308
|
-
copyFixture(join(bench.dir, task.fixture), fixtureCopy);
|
|
309
|
-
const pristine = await runVerifier(bench.dir, task.verifier, fixtureCopy);
|
|
310
|
-
facetChecks = verdictFromOutput(pristine.output)?.checks ?? null;
|
|
311
|
-
if (pristine.error !== null || pristine.exitCode === null) {
|
|
312
|
-
// Without this branch a verifier that cannot even be spawned reads as a clean NOP gate:
|
|
313
|
-
// "fails on the untouched fixture" is exactly what `exitCode !== 0` looks like.
|
|
314
|
-
taskPush('UNTOUCHED_FIXTURE', 'FAIL', `${task.id}: ${verifierFailure('verifier', task.verifier, pristine.error)}`, benchCheckEvidence(pristine, task.verifier));
|
|
315
|
-
}
|
|
316
|
-
else if (pristine.exitCode === 0) {
|
|
317
|
-
taskPush('UNTOUCHED_FIXTURE', 'FAIL', `${task.id}: command verifier already passes on the untouched fixture — the task is solved or the verifier is broken`, benchCheckEvidence(pristine, task.verifier));
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
taskPush('UNTOUCHED_FIXTURE', 'PASS', `${task.id}: command verifier fails on the untouched fixture (the failure reproduces)`, benchCheckEvidence(pristine, task.verifier));
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
finally {
|
|
324
|
-
rmSync(fixtureCopy, { recursive: true, force: true });
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
const missing = await probeVerifier(bench.dir, task.verifier, null);
|
|
329
|
-
if (missing.error !== null || missing.exitCode === null) {
|
|
330
|
-
taskPush('MISSING_OUTPUT', 'FAIL', `${task.id}: ${verifierFailure('verifier', task.verifier, missing.error)}`, benchCheckEvidence(missing, task.verifier));
|
|
331
|
-
}
|
|
332
|
-
else if (missing.exitCode === 0) {
|
|
333
|
-
taskPush('MISSING_OUTPUT', 'FAIL', `${task.id}: verifier does not reject a missing _output.md`, benchCheckEvidence(missing, task.verifier));
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
taskPush('MISSING_OUTPUT', 'PASS', `${task.id}: verifier rejects missing output`, benchCheckEvidence(missing, task.verifier));
|
|
337
|
-
}
|
|
338
|
-
const empty = await probeVerifier(bench.dir, task.verifier, '');
|
|
339
|
-
facetChecks = empty.checks;
|
|
340
|
-
if (empty.error !== null || empty.exitCode === null) {
|
|
341
|
-
taskPush('EMPTY_OUTPUT', 'FAIL', `${task.id}: ${verifierFailure('verifier', task.verifier, empty.error)}`, benchCheckEvidence(empty, task.verifier));
|
|
342
|
-
}
|
|
343
|
-
else if (empty.exitCode === 0) {
|
|
344
|
-
taskPush('EMPTY_OUTPUT', 'FAIL', `${task.id}: verifier passes an empty output — it cannot tell success from silence`, benchCheckEvidence(empty, task.verifier));
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
taskPush('EMPTY_OUTPUT', 'PASS', `${task.id}: verifier rejects empty output`, benchCheckEvidence(empty, task.verifier));
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
const facetGate = facetCountCheck(task.id, facetChecks);
|
|
351
|
-
if (facetGate)
|
|
352
|
-
taskPush('FACET_COUNT', facetGate.status, facetGate.message);
|
|
353
|
-
if (task.oracle) {
|
|
354
|
-
const oracleResult = await probeOracle(bench.dir, task.fixture, task.oracle, task.verifier);
|
|
355
|
-
taskPush('ORACLE', oracleResult.status, `${task.id}: ${oracleResult.message}`, oracleResult.evidence);
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
taskPush('ORACLE', 'WARN', `${task.id}: no oracle — task winnability is unverified (nothing proves a correct solution passes this verifier; register one with --oracle or write ground-truth/oracle-${task.id}.mjs)`);
|
|
359
|
-
}
|
|
360
|
-
const markerPath = join(bench.dir, task.fixture, MOCK_MARKER_FILE);
|
|
361
|
-
if ((task.verifierKind ?? 'output') === 'command') {
|
|
362
|
-
taskPush('MOCK_COVERAGE', 'INFO', `${task.id}: command verifier — mock-arm probes not applicable (a mock writes _output.md text, not file edits)${task.oracle
|
|
363
|
-
? '; offline coverage comes from the oracle and NOP gates above'
|
|
364
|
-
: '; with no oracle registered, nothing offline shows this task is solvable'}`);
|
|
365
|
-
}
|
|
366
|
-
else if (existsSync(markerPath)) {
|
|
367
|
-
try {
|
|
368
|
-
const marker = JSON.parse(readFileSync(markerPath, 'utf8'));
|
|
369
|
-
for (const arm of ['baseline', 'treatment']) {
|
|
370
|
-
const behavior = marker[arm];
|
|
371
|
-
if (behavior?.output === undefined) {
|
|
372
|
-
taskPush(arm === 'baseline' ? 'MOCK_BASELINE' : 'MOCK_TREATMENT', 'INFO', `${task.id}: no mock ${arm} output — this arm was not probed`);
|
|
373
|
-
continue;
|
|
374
|
-
}
|
|
375
|
-
const probe = await probeVerifier(bench.dir, task.verifier, behavior.output);
|
|
376
|
-
taskPush(arm === 'baseline' ? 'MOCK_BASELINE' : 'MOCK_TREATMENT', probe.error !== null || probe.exitCode === null ? 'FAIL' : 'INFO', `${task.id}: mock ${arm} output → ${probe.error !== null || probe.exitCode === null ? verifierFailure('verifier', task.verifier, probe.error) : `verifier ${probe.exitCode === 0 ? 'pass' : 'fail'}`}`, benchCheckEvidence(probe, task.verifier));
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
catch (error) {
|
|
380
|
-
throwIfEvaluationInterrupted();
|
|
381
|
-
taskPush('MOCK_MARKER', 'FAIL', `${task.id}: ${MOCK_MARKER_FILE} is unreadable (${error.message})`);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
taskPush('MOCK_COVERAGE', 'INFO', `${task.id}: no ${MOCK_MARKER_FILE} (offline mock runs will produce empty outputs)`);
|
|
386
|
-
}
|
|
387
|
-
const fixtureDir = join(bench.dir, task.fixture);
|
|
388
|
-
const fixtureBytes = listFilesRecursive(fixtureDir)
|
|
389
|
-
.map((rel) => statSync(join(fixtureDir, rel)).size)
|
|
390
|
-
.reduce((sum, size) => sum + size, 0);
|
|
391
|
-
if (fixtureBytes > FIXTURE_SIZE_WARN_BYTES) {
|
|
392
|
-
taskPush('FIXTURE_SIZE', 'WARN', `${task.id}: fixture is ${Math.round(fixtureBytes / 1024)} KB — inject mode inlines it into every prompt; keep it lean`);
|
|
393
|
-
}
|
|
394
|
-
else {
|
|
395
|
-
taskPush('FIXTURE_SIZE', 'PASS', `${task.id}: fixture size ${Math.round(fixtureBytes / 1024)} KB`);
|
|
396
|
-
}
|
|
397
|
-
if (task.shouldTrigger === undefined) {
|
|
398
|
-
taskPush('TRIGGER_LABEL', 'INFO', `${task.id}: no shouldTrigger label (trigger mode will skip this task)`);
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
labeledTasks++;
|
|
402
|
-
if (task.shouldTrigger === false)
|
|
403
|
-
negativeTasks++;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
if (labeledTasks > 0) {
|
|
407
|
-
const fraction = negativeTasks / labeledTasks;
|
|
408
|
-
const percent = Math.round(fraction * 100);
|
|
409
|
-
if (negativeTasks === 0) {
|
|
410
|
-
push('NEGATIVE_CONTROLS', 'WARN', 'no shouldTrigger:false (negative-control) tasks — trigger mode cannot measure false-trigger rate (see docs/metrics.md)');
|
|
411
|
-
}
|
|
412
|
-
else if (fraction < NEGATIVE_CONTROL_TARGET) {
|
|
413
|
-
push('NEGATIVE_CONTROLS', 'WARN', `${negativeTasks}/${labeledTasks} labeled task(s) are negative controls (${percent}%) — below the ${NEGATIVE_CONTROL_PERCENT}% target in docs/metrics.md, so false-trigger rate rests on a thin sample`);
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
416
|
-
push('NEGATIVE_CONTROLS', 'PASS', `${negativeTasks}/${labeledTasks} labeled task(s) are negative controls (${percent}%) — at or above the ${NEGATIVE_CONTROL_PERCENT}% target`);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
193
|
+
await inspectBenchIntegrity(bench, push);
|
|
419
194
|
if (calibration) {
|
|
420
195
|
const offlineReport = { dir, bench: identity, checks, failures: checks.filter(check => check.status === 'FAIL').length,
|
|
421
196
|
warnings: checks.filter(check => check.status === 'WARN').length };
|
|
@@ -425,7 +200,6 @@ async function runBenchCheckWithinInterrupts(options, strictCalibration = false)
|
|
|
425
200
|
log(`[UNKNOWN] ${check.code}: ${check.message}`);
|
|
426
201
|
if (casePreflight.status === 'blocked') {
|
|
427
202
|
if (strictCalibration) {
|
|
428
|
-
const { CasePreflightFailed } = await import('./eval-preflight.js');
|
|
429
203
|
throw new CasePreflightFailed(casePreflight);
|
|
430
204
|
}
|
|
431
205
|
push('CALIBRATION', 'FAIL', 'Offline case preflight blocked calibration; no agent calls or run directory were created. Fix every hard failure before a fresh plan.');
|
|
@@ -452,13 +226,6 @@ function finish(dir, checks, log, calibrated = false, bench = null) {
|
|
|
452
226
|
return { dir, bench, checks, failures, warnings };
|
|
453
227
|
}
|
|
454
228
|
const TASK_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
455
|
-
export function captureSourceFiles(sourceDir) {
|
|
456
|
-
const git = spawnSync('git', ['ls-files', '-z'], { cwd: sourceDir, encoding: 'utf8' });
|
|
457
|
-
if (git.status === 0 && git.stdout.trim() !== '') {
|
|
458
|
-
return git.stdout.split('\0').filter(Boolean);
|
|
459
|
-
}
|
|
460
|
-
return listFilesRecursive(sourceDir).filter((rel) => !rel.split(/[\\/]/).some((part) => part === '.git' || part === 'node_modules'));
|
|
461
|
-
}
|
|
462
229
|
function verifierForCmd(cmd) {
|
|
463
230
|
return `import { spawnSync } from 'node:child_process';
|
|
464
231
|
|
|
@@ -549,58 +316,45 @@ Node built-ins. Your draft is validated automatically: the verifier must fail th
|
|
|
549
316
|
fixture and pass the oracle-solved one, so test both directions before you finish.
|
|
550
317
|
`;
|
|
551
318
|
}
|
|
552
|
-
async function draftVerifierWithOracle(
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const
|
|
319
|
+
async function draftVerifierWithOracle(session, log) {
|
|
320
|
+
const staging = session.workspace;
|
|
321
|
+
const fixtureDir = join(staging, 'fixture');
|
|
322
|
+
log(`Drafting verifier + oracle; at most 1 call. Records: ${session.dir}`);
|
|
323
|
+
await session.run();
|
|
324
|
+
const verifierPath = join(staging, 'verifier.mjs');
|
|
325
|
+
const oraclePath = join(staging, 'oracle.mjs');
|
|
326
|
+
if (!existsSync(verifierPath) || !existsSync(oraclePath)) {
|
|
327
|
+
throw new Error('the drafting agent did not write verifier.mjs and oracle.mjs into its working directory — nothing was added');
|
|
328
|
+
}
|
|
329
|
+
const nopDir = mkdtempSync(join(tmpdir(), 'skillfit-decompose-nop-'));
|
|
558
330
|
try {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
log(`Drafting verifier + oracle with ${executor.describe().kind} (${executor.describe().model})…`);
|
|
566
|
-
await executor.run(buildDecomposePrompt(prepared.promptText, prepared.fixtureFiles.map((f) => f.rel), prepared.verifierKind), staging);
|
|
567
|
-
const verifierPath = join(staging, 'verifier.mjs');
|
|
568
|
-
const oraclePath = join(staging, 'oracle.mjs');
|
|
569
|
-
if (!existsSync(verifierPath) || !existsSync(oraclePath)) {
|
|
570
|
-
throw new Error('the drafting agent did not write verifier.mjs and oracle.mjs into its working directory — nothing was added');
|
|
571
|
-
}
|
|
572
|
-
const nopDir = mkdtempSync(join(tmpdir(), 'skillfit-decompose-nop-'));
|
|
573
|
-
try {
|
|
574
|
-
copyFixture(fixtureDir, nopDir);
|
|
575
|
-
const nop = await runVerifier(staging, 'node verifier.mjs', nopDir);
|
|
576
|
-
if (nop.error !== null || nop.exitCode === null) {
|
|
577
|
-
throw new Error(`draft rejected: ${verifierFailure('verifier', 'node verifier.mjs', nop.error)}`);
|
|
578
|
-
}
|
|
579
|
-
if (nop.exitCode === 0) {
|
|
580
|
-
throw new Error('draft rejected: the verifier passes the untouched fixture — the task would start solved (NOP gate)');
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
finally {
|
|
584
|
-
rmSync(nopDir, { recursive: true, force: true });
|
|
331
|
+
copyFixture(fixtureDir, nopDir);
|
|
332
|
+
const nop = await runVerifier(staging, 'node verifier.mjs', nopDir, session.plan.verifierTimeoutSeconds);
|
|
333
|
+
session.gate('untouched-fixture', nop);
|
|
334
|
+
if (nop.error !== null || nop.exitCode === null) {
|
|
335
|
+
throw new Error(`draft rejected: ${verifierFailure('verifier', 'node verifier.mjs', nop.error)}`);
|
|
585
336
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
throw new Error(`draft rejected: ${solvedGate.reason ?? 'the oracle command failed on a fresh fixture copy'}`);
|
|
337
|
+
if (nop.exitCode === 0) {
|
|
338
|
+
throw new Error('draft rejected: the verifier passes the untouched fixture — the task would start solved (NOP gate)');
|
|
589
339
|
}
|
|
590
|
-
if (solvedGate.kind === 'verifier-failed') {
|
|
591
|
-
throw new Error(`draft rejected: ${solvedGate.reason ?? 'the verifier fails even after the oracle solved the task (oracle gate)'}`);
|
|
592
|
-
}
|
|
593
|
-
if (solvedGate.kind === 'low-score') {
|
|
594
|
-
throw new Error(`draft rejected: the oracle scores ${solvedGate.score.toFixed(2)} on the drafted checks — checks are stricter than the oracle`);
|
|
595
|
-
}
|
|
596
|
-
return {
|
|
597
|
-
verifierSource: readFileSync(verifierPath, 'utf8'),
|
|
598
|
-
oracleSource: readFileSync(oraclePath, 'utf8'),
|
|
599
|
-
};
|
|
600
340
|
}
|
|
601
341
|
finally {
|
|
602
|
-
rmSync(
|
|
342
|
+
rmSync(nopDir, { recursive: true, force: true });
|
|
603
343
|
}
|
|
344
|
+
const solvedGate = await runOracleGate(staging, fixtureDir, 'node oracle.mjs', 'node verifier.mjs', session.plan.verifierTimeoutSeconds, (name, result) => session.gate(name, result));
|
|
345
|
+
if (solvedGate.kind === 'oracle-failed') {
|
|
346
|
+
throw new Error(`draft rejected: ${solvedGate.reason ?? 'the oracle command failed on a fresh fixture copy'}`);
|
|
347
|
+
}
|
|
348
|
+
if (solvedGate.kind === 'verifier-failed') {
|
|
349
|
+
throw new Error(`draft rejected: ${solvedGate.reason ?? 'the verifier fails even after the oracle solved the task (oracle gate)'}`);
|
|
350
|
+
}
|
|
351
|
+
if (solvedGate.kind === 'low-score') {
|
|
352
|
+
throw new Error(`draft rejected: the oracle scores ${solvedGate.score.toFixed(2)} on the drafted checks — checks are stricter than the oracle`);
|
|
353
|
+
}
|
|
354
|
+
return {
|
|
355
|
+
verifierSource: readFileSync(verifierPath, 'utf8'),
|
|
356
|
+
oracleSource: readFileSync(oraclePath, 'utf8'),
|
|
357
|
+
};
|
|
604
358
|
}
|
|
605
359
|
function assertInsideBench(benchDir, target) {
|
|
606
360
|
const rel = relative(benchDir, target);
|
|
@@ -608,7 +362,38 @@ function assertInsideBench(benchDir, target) {
|
|
|
608
362
|
throw new Error(`Refusing to write outside the bench directory: ${target}`);
|
|
609
363
|
}
|
|
610
364
|
}
|
|
365
|
+
function assertBenchWrites(benchDir, targets) {
|
|
366
|
+
for (const target of targets) {
|
|
367
|
+
assertInsideBench(benchDir, target);
|
|
368
|
+
const parts = relative(benchDir, target).split(/[\\/]/);
|
|
369
|
+
let path = benchDir;
|
|
370
|
+
for (let index = 0; index < parts.length; index++) {
|
|
371
|
+
path = join(path, parts[index]);
|
|
372
|
+
try {
|
|
373
|
+
const stat = lstatSync(path);
|
|
374
|
+
if (stat.isSymbolicLink())
|
|
375
|
+
throw new Error(`Refusing a symlink in bench output: ${path}`);
|
|
376
|
+
if (index < parts.length - 1 ? !stat.isDirectory() : !stat.isFile())
|
|
377
|
+
throw new Error(`Refusing to overwrite a non-file or traverse a non-directory: ${path}`);
|
|
378
|
+
}
|
|
379
|
+
catch (error) {
|
|
380
|
+
if (error.code !== 'ENOENT')
|
|
381
|
+
throw error;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
try {
|
|
385
|
+
const stat = lstatSync(target + BACKUP_SUFFIX);
|
|
386
|
+
if (stat.isSymbolicLink() || !stat.isFile())
|
|
387
|
+
throw new Error(`Refusing an unsafe backup target: ${target + BACKUP_SUFFIX}`);
|
|
388
|
+
}
|
|
389
|
+
catch (error) {
|
|
390
|
+
if (error.code !== 'ENOENT')
|
|
391
|
+
throw error;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
611
395
|
export function applyBenchWrites(benchDir, writes) {
|
|
396
|
+
assertBenchWrites(benchDir, writes.map(write => write.target));
|
|
612
397
|
const applied = [];
|
|
613
398
|
try {
|
|
614
399
|
for (const write of writes) {
|
|
@@ -657,7 +442,11 @@ export function applyBenchWrites(benchDir, writes) {
|
|
|
657
442
|
}
|
|
658
443
|
}
|
|
659
444
|
export async function runBenchAdd(options) {
|
|
445
|
+
return options.dryRun ? runBenchAddWithinInterrupts(options) : withEvaluationInterrupts(() => runBenchAddWithinInterrupts(options));
|
|
446
|
+
}
|
|
447
|
+
async function runBenchAddWithinInterrupts(options) {
|
|
660
448
|
const log = options.log ?? ((msg) => console.log(msg));
|
|
449
|
+
const timeout = options.verifierTimeoutSeconds === undefined ? {} : { verifierTimeoutSeconds: parseVerifierTimeoutSeconds(options.verifierTimeoutSeconds) };
|
|
661
450
|
if (!options.freeze && !options.fromCommit) {
|
|
662
451
|
throw new Error('bench add needs an importer: --freeze (current directory) or --from-commit <sha> (git history).');
|
|
663
452
|
}
|
|
@@ -679,8 +468,15 @@ export async function runBenchAdd(options) {
|
|
|
679
468
|
if (!existsSync(benchJsonPath)) {
|
|
680
469
|
throw new Error(`Not a bench directory (missing bench.json): ${benchDir} — run \`skillfit bench init\` first.`);
|
|
681
470
|
}
|
|
682
|
-
const
|
|
471
|
+
const originalManifest = readFileSync(benchJsonPath, 'utf8');
|
|
472
|
+
const benchJson = JSON.parse(originalManifest);
|
|
683
473
|
const tasks = Array.isArray(benchJson.tasks) ? benchJson.tasks : [];
|
|
474
|
+
if (benchJson.schemaVersion !== BENCH_SCHEMA_VERSION || !Array.isArray(benchJson.tasks))
|
|
475
|
+
throw new Error('Invalid bench.json schema or task list; fix the bench before adding a task.');
|
|
476
|
+
for (const [index, task] of tasks.entries())
|
|
477
|
+
validateBenchTask(benchDir, task, index);
|
|
478
|
+
if (new Set(tasks.map(task => task.id)).size !== tasks.length)
|
|
479
|
+
throw new Error('Duplicate task IDs in bench.json; fix the bench before adding a task.');
|
|
684
480
|
const prepared = options.fromCommit
|
|
685
481
|
? prepareFromCommit(options, cwd)
|
|
686
482
|
: prepareFreeze(options, cwd);
|
|
@@ -691,19 +487,15 @@ export async function runBenchAdd(options) {
|
|
|
691
487
|
if (tasks.some((task) => task?.id === taskId)) {
|
|
692
488
|
throw new Error(`Task "${taskId}" already exists in ${benchJsonPath}.`);
|
|
693
489
|
}
|
|
694
|
-
|
|
695
|
-
const drafted = await draftVerifierWithOracle(options, prepared, log);
|
|
696
|
-
prepared.verifierSource = drafted.verifierSource;
|
|
697
|
-
prepared.oracleSource = drafted.oracleSource;
|
|
698
|
-
}
|
|
490
|
+
const draft = options.decompose ? new BenchDraftSession(options, taskId, benchDir, cwd, prepared.fixtureFiles, buildDecomposePrompt(prepared.promptText, prepared.fixtureFiles.map(file => file.rel), prepared.verifierKind)) : undefined;
|
|
699
491
|
const generated = {
|
|
700
492
|
[`prompts/${taskId}.md`]: `${prepared.promptText.trimEnd()}\n`,
|
|
701
493
|
[`prompts/${taskId}.trigger.md`]: `${prepared.promptText.trimEnd()}\n\nThe repository is in your current working directory.\n`,
|
|
702
494
|
[`verifiers/${taskId}.mjs`]: prepared.verifierSource,
|
|
703
495
|
[`ground-truth/${taskId}.md`]: prepared.groundTruth,
|
|
704
496
|
};
|
|
705
|
-
if (prepared.oracleSource) {
|
|
706
|
-
generated[`ground-truth/oracle-${taskId}.mjs`] = prepared.oracleSource;
|
|
497
|
+
if (prepared.oracleSource || options.decompose) {
|
|
498
|
+
generated[`ground-truth/oracle-${taskId}.mjs`] = prepared.oracleSource ?? '';
|
|
707
499
|
}
|
|
708
500
|
const taskEntry = {
|
|
709
501
|
id: taskId,
|
|
@@ -712,11 +504,29 @@ export async function runBenchAdd(options) {
|
|
|
712
504
|
promptTrigger: `prompts/${taskId}.trigger.md`,
|
|
713
505
|
verifier: `node verifiers/${taskId}.mjs`,
|
|
714
506
|
verifierKind: prepared.verifierKind,
|
|
507
|
+
...timeout,
|
|
715
508
|
rubric: `ground-truth/${taskId}.md`,
|
|
716
|
-
...(prepared.oracleSource ? { oracle: `node ground-truth/oracle-${taskId}.mjs` } : {}),
|
|
509
|
+
...(prepared.oracleSource || options.decompose ? { oracle: `node ground-truth/oracle-${taskId}.mjs` } : {}),
|
|
717
510
|
...(options.oracle ? { oracle: options.oracle } : {}),
|
|
718
511
|
...(options.shouldTrigger !== undefined ? { shouldTrigger: options.shouldTrigger } : {}),
|
|
719
512
|
};
|
|
513
|
+
const targets = [...prepared.fixtureFiles.map(file => join(benchDir, 'fixtures', taskId, file.rel)),
|
|
514
|
+
...Object.keys(generated).map(rel => join(benchDir, rel)), benchJsonPath];
|
|
515
|
+
assertBenchWrites(benchDir, targets);
|
|
516
|
+
if (sha256File(benchJsonPath) !== sha256Text(originalManifest))
|
|
517
|
+
throw new Error('Bench manifest changed while preparing the task; nothing was written.');
|
|
518
|
+
const writeState = () => targets.flatMap(target => [target, target + BACKUP_SUFFIX]).map(path => existsSync(path) ? sha256File(path) : null);
|
|
519
|
+
const expectedWrites = JSON.stringify(writeState());
|
|
520
|
+
const assertOutputsUnchanged = () => {
|
|
521
|
+
assertBenchWrites(benchDir, targets);
|
|
522
|
+
if (JSON.stringify(writeState()) !== expectedWrites)
|
|
523
|
+
throw new Error('Bench outputs changed while preparing the task; nothing was written. Review a fresh plan.');
|
|
524
|
+
};
|
|
525
|
+
if (draft) {
|
|
526
|
+
log(`Draft plan: 1 call; ceiling ${draft.plan.maxCalls}; executor deadline ${draft.plan.executorTimeoutSeconds}s; no automatic retry.`);
|
|
527
|
+
log(`Draft records: ${draft.dir}`);
|
|
528
|
+
log(`Spending limits: ${draft.plan.spendingBudget ? JSON.stringify(draft.plan.spendingBudget) : 'not set; token/cache usage may remain unknown'}. Authentication: unknown offline.`);
|
|
529
|
+
}
|
|
720
530
|
if (options.verifierCmd) {
|
|
721
531
|
// The string is not used once and discarded: it is written into a generated .mjs and re-executed
|
|
722
532
|
// with a shell on every later `bench check` and `eval`. Disclose it before writing, in both the
|
|
@@ -738,38 +548,57 @@ export async function runBenchAdd(options) {
|
|
|
738
548
|
}
|
|
739
549
|
if (!options.yes) {
|
|
740
550
|
const confirm = options.confirm ?? confirmPrompt;
|
|
741
|
-
const ok = await confirm(
|
|
551
|
+
const ok = await confirm(`${draft ? 'Authorize 1 drafting call, retain its costs, then ' : ''}Add ${prepared.fixtureFiles.length} fixture file(s) + ${Object.keys(generated).length} generated file(s) into ${benchDir}? [y/N] `);
|
|
742
552
|
if (!ok) {
|
|
743
553
|
log('Aborted — nothing was written.');
|
|
744
554
|
return null;
|
|
745
555
|
}
|
|
746
556
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
557
|
+
let failure;
|
|
558
|
+
try {
|
|
559
|
+
throwIfEvaluationInterrupted();
|
|
560
|
+
assertOutputsUnchanged();
|
|
561
|
+
if (draft) {
|
|
562
|
+
const drafted = await draftVerifierWithOracle(draft, log);
|
|
563
|
+
generated[`verifiers/${taskId}.mjs`] = drafted.verifierSource;
|
|
564
|
+
generated[`ground-truth/oracle-${taskId}.mjs`] = drafted.oracleSource;
|
|
751
565
|
}
|
|
752
|
-
writes
|
|
566
|
+
const writes = [];
|
|
567
|
+
for (const file of prepared.fixtureFiles) {
|
|
568
|
+
if (file.rel.split(/[\\/]/).includes('..') || isAbsolute(file.rel)) {
|
|
569
|
+
throw new Error(`Fixture path escapes the task directory: ${file.rel}`);
|
|
570
|
+
}
|
|
571
|
+
writes.push({ target: join(benchDir, 'fixtures', taskId, file.rel), content: file.content });
|
|
572
|
+
}
|
|
573
|
+
for (const [rel, content] of Object.entries(generated)) {
|
|
574
|
+
writes.push({ target: join(benchDir, rel), content });
|
|
575
|
+
}
|
|
576
|
+
benchJson.tasks = [...tasks, taskEntry];
|
|
577
|
+
writes.push({ target: benchJsonPath, content: `${JSON.stringify(benchJson, null, 2)}\n` });
|
|
578
|
+
throwIfEvaluationInterrupted();
|
|
579
|
+
assertOutputsUnchanged();
|
|
580
|
+
applyBenchWrites(benchDir, writes);
|
|
581
|
+
log(`Task "${taskId}" added to ${benchDir} (${prepared.fixtureFiles.length} fixture file(s), verifier: ${prepared.verifierKind}).`);
|
|
582
|
+
log('Next:');
|
|
583
|
+
log(` skillfit bench check ${benchDir}`);
|
|
584
|
+
log(` skillfit eval <skill-path> --bench ${benchDir} --agent <id> --trials 5`);
|
|
585
|
+
return {
|
|
586
|
+
dir: benchDir,
|
|
587
|
+
taskId,
|
|
588
|
+
files: [
|
|
589
|
+
...prepared.fixtureFiles.map((file) => `fixtures/${taskId}/${file.rel}`),
|
|
590
|
+
...Object.keys(generated),
|
|
591
|
+
'bench.json',
|
|
592
|
+
],
|
|
593
|
+
};
|
|
753
594
|
}
|
|
754
|
-
|
|
755
|
-
|
|
595
|
+
catch (error) {
|
|
596
|
+
failure = error;
|
|
597
|
+
throw error;
|
|
598
|
+
}
|
|
599
|
+
finally {
|
|
600
|
+
draft?.finish(failure);
|
|
756
601
|
}
|
|
757
|
-
benchJson.tasks = [...tasks, taskEntry];
|
|
758
|
-
writes.push({ target: benchJsonPath, content: `${JSON.stringify(benchJson, null, 2)}\n` });
|
|
759
|
-
applyBenchWrites(benchDir, writes);
|
|
760
|
-
log(`Task "${taskId}" added to ${benchDir} (${prepared.fixtureFiles.length} fixture file(s), verifier: ${prepared.verifierKind}).`);
|
|
761
|
-
log('Next:');
|
|
762
|
-
log(` skillfit bench check ${benchDir}`);
|
|
763
|
-
log(` skillfit eval <skill-path> --bench ${benchDir} --agent <id> --trials 5`);
|
|
764
|
-
return {
|
|
765
|
-
dir: benchDir,
|
|
766
|
-
taskId,
|
|
767
|
-
files: [
|
|
768
|
-
...prepared.fixtureFiles.map((file) => `fixtures/${taskId}/${file.rel}`),
|
|
769
|
-
...Object.keys(generated),
|
|
770
|
-
'bench.json',
|
|
771
|
-
],
|
|
772
|
-
};
|
|
773
602
|
}
|
|
774
603
|
function prepareFreeze(options, cwd) {
|
|
775
604
|
const promptText = options.prompt ??
|
|
@@ -794,7 +623,7 @@ function prepareFreeze(options, cwd) {
|
|
|
794
623
|
if (!existsSync(sourceDir)) {
|
|
795
624
|
throw new Error(`--source-dir does not exist: ${sourceDir}`);
|
|
796
625
|
}
|
|
797
|
-
const captured =
|
|
626
|
+
const captured = freezeSourceFiles(sourceDir, resolve(cwd, options.benchDir ?? '.'), options.include);
|
|
798
627
|
if (captured.length === 0) {
|
|
799
628
|
throw new Error(`No capturable files in ${sourceDir} (empty git index or directory).`);
|
|
800
629
|
}
|
|
@@ -811,7 +640,7 @@ function prepareFreeze(options, cwd) {
|
|
|
811
640
|
: options.verifierCmd
|
|
812
641
|
? 'command'
|
|
813
642
|
: 'output',
|
|
814
|
-
fixtureFiles: captured
|
|
643
|
+
fixtureFiles: captured,
|
|
815
644
|
groundTruth: `# Ground truth — frozen task
|
|
816
645
|
|
|
817
646
|
Frozen from a real failure on ${new Date().toISOString().slice(0, 10)}.
|