skillfit 0.12.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 +60 -119
- package/README.zh-CN.md +60 -116
- package/dist/commands/bench-check-report.js +1 -34
- package/dist/commands/bench.js +6 -239
- 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/install.js +14 -98
- package/dist/harness/bench-check.js +277 -0
- package/dist/harness/bench-diagnostics.js +34 -0
- package/dist/harness/eval-acceptance.js +1 -1
- package/dist/harness/eval-audit.js +1 -1
- package/dist/harness/eval-manifest.js +456 -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/evaluation-reports.md +1 -1
- package/docs/growth-roadmap-2026-10.md +14 -18
- package/docs/package-contents.md +73 -0
- 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.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-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 +14 -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/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/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 -1166
- 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 -269
- package/dist/commands/eval-cli-usage.test.js +0 -75
- 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 -263
- 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/npm-first-run.test.js +0 -74
- 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 -175
- package/dist/harness/executors/cli.test.js +0 -541
- 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
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { spawn, spawnSync } from 'node:child_process';
|
|
3
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
import { pathToFileURL } from 'node:url';
|
|
7
|
-
import { test } from 'node:test';
|
|
8
|
-
import { runBenchCheck, runBenchInit } from './bench.js';
|
|
9
|
-
import { runEval } from './eval.js';
|
|
10
|
-
import { exportEvaluation } from './eval-export.js';
|
|
11
|
-
import { readEvaluationReport } from './evaluation-report.js';
|
|
12
|
-
import { ExperimentSession } from '../harness/experiment-session.js';
|
|
13
|
-
import { loadBench } from '../harness/bench.js';
|
|
14
|
-
import { collectEvaluationTarget } from '../harness/target.js';
|
|
15
|
-
import { packageFiles, verifyReplayPackage } from '../harness/replay-package.js';
|
|
16
|
-
import { sha256File, sha256Text } from '../harness/hash.js';
|
|
17
|
-
import { createSpendingBudgetRecorder } from '../harness/eval-budget.js';
|
|
18
|
-
import { summarizeCosts } from '../harness/costs.js';
|
|
19
|
-
async function fixture(t, classified = true) {
|
|
20
|
-
const root = mkdtempSync(join(tmpdir(), 'skillfit-export-modes-'));
|
|
21
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
22
|
-
const bench = join(root, 'bench'), skill = join(root, 'skill'), runsRoot = join(root, 'runs');
|
|
23
|
-
await runBenchInit({ dir: bench, yes: true, log: () => { } });
|
|
24
|
-
const file = join(bench, 'bench.json'), definition = JSON.parse(readFileSync(file, 'utf8'));
|
|
25
|
-
definition.tasks[0].shouldTrigger = true;
|
|
26
|
-
if (classified)
|
|
27
|
-
definition.tasks[0].triggerClass = 'explicit';
|
|
28
|
-
writeFileSync(file, JSON.stringify(definition));
|
|
29
|
-
mkdirSync(skill);
|
|
30
|
-
writeFileSync(join(skill, 'SKILL.md'), '# Offline export test\n');
|
|
31
|
-
let calls = 0;
|
|
32
|
-
const executor = { describe: () => ({ kind: 'stub', model: 'offline-only' }), run: async () => {
|
|
33
|
-
calls++;
|
|
34
|
-
return { output: 'skillfit-ok', skillTriggered: true, tokens: { input: 10, output: 3 }, usageStatus: 'partial' };
|
|
35
|
-
} };
|
|
36
|
-
return { root, bench, skill, runsRoot, executor, calls: () => calls };
|
|
37
|
-
}
|
|
38
|
-
function replay(root, verifyOnly = false) {
|
|
39
|
-
const result = spawnSync(process.execPath, [join(root, 'reproduce.mjs'), ...(verifyOnly ? ['--verify-only'] : [])], { encoding: 'utf8', timeout: 30_000, maxBuffer: 8 * 1024 * 1024 });
|
|
40
|
-
assert.equal(result.status, 0, result.stderr);
|
|
41
|
-
return JSON.parse(result.stdout);
|
|
42
|
-
}
|
|
43
|
-
function reseal(run) {
|
|
44
|
-
const index = JSON.parse(readFileSync(join(run, '_artifacts.json'), 'utf8'));
|
|
45
|
-
index.files = Object.fromEntries(packageFiles(run).filter(path => path !== '_artifacts.json').map(path => [path, sha256File(join(run, path))]));
|
|
46
|
-
writeFileSync(join(run, '_artifacts.json'), JSON.stringify(index));
|
|
47
|
-
}
|
|
48
|
-
function rewritePlan(run, change) {
|
|
49
|
-
const plan = JSON.parse(readFileSync(join(run, '_plan.json'), 'utf8'));
|
|
50
|
-
change(plan);
|
|
51
|
-
const bytes = JSON.stringify(plan, null, 2) + '\n', sha256 = sha256Text(bytes);
|
|
52
|
-
writeFileSync(join(run, '_plan.json'), bytes);
|
|
53
|
-
const session = JSON.parse(readFileSync(join(run, '_session.json'), 'utf8'));
|
|
54
|
-
session.planSha256 = sha256;
|
|
55
|
-
writeFileSync(join(run, '_session.json'), JSON.stringify(session));
|
|
56
|
-
const summaryName = plan.details.mode === 'calibration' ? '_calibration.json' : 'manifest.json';
|
|
57
|
-
const summary = JSON.parse(readFileSync(join(run, summaryName), 'utf8'));
|
|
58
|
-
summary.experiment = session;
|
|
59
|
-
writeFileSync(join(run, summaryName), JSON.stringify(summary));
|
|
60
|
-
const index = JSON.parse(readFileSync(join(run, '_artifacts.json'), 'utf8'));
|
|
61
|
-
index.planSha256 = sha256;
|
|
62
|
-
writeFileSync(join(run, '_artifacts.json'), JSON.stringify(index));
|
|
63
|
-
reseal(run);
|
|
64
|
-
}
|
|
65
|
-
test('calibration and trigger export/replay survive deleted inputs and retain single-arm observations, unknown cache and partial costs', async (t) => {
|
|
66
|
-
for (const variant of ['calibration', 'trigger', 'trigger-unclassified'])
|
|
67
|
-
await t.test(variant, async (t) => {
|
|
68
|
-
const mode = variant === 'calibration' ? 'calibration' : 'trigger';
|
|
69
|
-
const f = await fixture(t, variant !== 'trigger-unclassified'), run = join(f.runsRoot, mode), output = join(f.root, 'portable');
|
|
70
|
-
if (mode === 'calibration')
|
|
71
|
-
await runBenchCheck({ dir: f.bench, calibrate: { executor: f.executor, trials: 1, maxCalls: 1, runsRoot: f.runsRoot, runGroup: mode }, log: () => { } });
|
|
72
|
-
else
|
|
73
|
-
await runEval({ skillPath: f.skill, bench: f.bench, mode, skillInstallDir: '.test-skills', executor: f.executor, trials: 1, maxCalls: 1, runsRoot: f.runsRoot, runGroup: mode, dryRun: false, yes: true, log: () => { } });
|
|
74
|
-
const before = await readEvaluationReport(run);
|
|
75
|
-
assert.ok('evaluationType' in before && before.evaluationType === mode);
|
|
76
|
-
assert.equal(before.evidence.verified, true, JSON.stringify(before.evidence));
|
|
77
|
-
assert.equal(before.usage?.metrics.input.knownTotal, 10);
|
|
78
|
-
assert.equal(before.usage?.metrics.input.coverage.partial, 1);
|
|
79
|
-
assert.equal(before.usage?.metrics.cachedInput.coverage.unknown, 1);
|
|
80
|
-
const nativeFiles = packageFiles(run).map(file => [file, sha256File(join(run, file))]);
|
|
81
|
-
rmSync(f.bench, { recursive: true });
|
|
82
|
-
rmSync(f.skill, { recursive: true });
|
|
83
|
-
assert.equal((await exportEvaluation(run, output, { log: () => { } })).status, 'planned');
|
|
84
|
-
assert.equal(existsSync(output), false);
|
|
85
|
-
await exportEvaluation(run, output, { yes: true, log: () => { } });
|
|
86
|
-
assert.deepEqual(packageFiles(run).map(file => [file, sha256File(join(run, file))]), nativeFiles, 'Native receipts and ledgers remain untouched.');
|
|
87
|
-
const moved = join(f.root, 'received offline package');
|
|
88
|
-
renameSync(output, moved);
|
|
89
|
-
rmSync(run, { recursive: true });
|
|
90
|
-
assert.equal(verifyReplayPackage(moved).evaluationType, mode);
|
|
91
|
-
assert.equal(replay(moved, true).modelCalls, 0);
|
|
92
|
-
const result = replay(moved);
|
|
93
|
-
assert.equal(result.evaluationType, mode);
|
|
94
|
-
assert.equal(result.evidence.verified, true);
|
|
95
|
-
assert.equal(result.evidence.replayedDeliveries, 1);
|
|
96
|
-
assert.deepEqual(result.summary, JSON.parse(JSON.stringify(before.summary)));
|
|
97
|
-
assert.deepEqual(result.usage, before.usage);
|
|
98
|
-
assert.equal(result.acceptance.decision, 'inconclusive');
|
|
99
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
100
|
-
assert.equal(result.acceptance.automaticUpgrade, false);
|
|
101
|
-
assert.equal(result.portableReplay.modelCalls, 0);
|
|
102
|
-
assert.equal(f.calls(), 1);
|
|
103
|
-
const inspected = await readEvaluationReport(moved);
|
|
104
|
-
assert.ok('portablePackage' in inspected && inspected.portablePackage.integrityVerified);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
test('stopped single-arm exports preserve missing invocation receipt as unknown and never invent a summary', async (t) => {
|
|
108
|
-
for (const mode of ['calibration', 'trigger'])
|
|
109
|
-
await t.test(mode, async (t) => {
|
|
110
|
-
const f = await fixture(t), run = join(f.runsRoot, mode), arm = mode === 'calibration' ? 'baseline' : 'installed', workspace = join(run, 'example-task', arm, 'trial-1');
|
|
111
|
-
const session = new ExperimentSession({ bench: loadBench(f.bench), target: collectEvaluationTarget(f.skill), groupDir: run, workspaces: [workspace], plannedCalls: 1, maxCalls: 1, injected: true, details: { mode, trials: 1 } });
|
|
112
|
-
mkdirSync(workspace, { recursive: true });
|
|
113
|
-
const prompt = 'Saved invocation with a lost receipt';
|
|
114
|
-
writeFileSync(join(workspace, '_prompt.txt'), prompt);
|
|
115
|
-
await session.wrap(f.executor, 'agent').run(prompt, workspace);
|
|
116
|
-
session.finish(new Error('Synthetic interruption before receipt persistence'));
|
|
117
|
-
const before = await readEvaluationReport(run);
|
|
118
|
-
assert.ok('evaluationType' in before);
|
|
119
|
-
assert.equal(before.status, 'stopped');
|
|
120
|
-
assert.equal(before.summary, null);
|
|
121
|
-
assert.equal(before.evidence.verified, true, JSON.stringify(before.evidence));
|
|
122
|
-
assert.equal(before.usage?.invocationsWithUnknownReceipts, 1);
|
|
123
|
-
assert.equal(before.usage?.metrics.input.coverage.unknown, 1);
|
|
124
|
-
assert.equal(before.usage?.metrics.durationSeconds.coverage.unknown, 1);
|
|
125
|
-
const output = join(f.root, 'portable');
|
|
126
|
-
await exportEvaluation(run, output, { yes: true, log: () => { } });
|
|
127
|
-
rmSync(f.bench, { recursive: true });
|
|
128
|
-
rmSync(f.skill, { recursive: true });
|
|
129
|
-
rmSync(run, { recursive: true });
|
|
130
|
-
const result = replay(output);
|
|
131
|
-
assert.equal(result.status, 'stopped');
|
|
132
|
-
assert.equal(result.summary, null);
|
|
133
|
-
assert.deepEqual(result.usage, before.usage);
|
|
134
|
-
assert.equal(result.evidence.replayedDeliveries, 0);
|
|
135
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
136
|
-
assert.equal(f.calls(), 1);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
test('single-arm semantic audit rejects resealed wrong summary and changed local verdicts', async (t) => {
|
|
140
|
-
const f = await fixture(t), run = join(f.runsRoot, 'calibration');
|
|
141
|
-
await runBenchCheck({ dir: f.bench, calibrate: { executor: f.executor, trials: 1, runsRoot: f.runsRoot, runGroup: 'calibration' }, log: () => { } });
|
|
142
|
-
const file = join(run, '_calibration.json'), original = readFileSync(file, 'utf8'), summary = JSON.parse(original);
|
|
143
|
-
summary.tasks[0].passes = 0;
|
|
144
|
-
writeFileSync(file, JSON.stringify(summary));
|
|
145
|
-
reseal(run);
|
|
146
|
-
const bad = await readEvaluationReport(run);
|
|
147
|
-
assert.equal(bad.evidence.verified, false);
|
|
148
|
-
assert.match(JSON.stringify(bad.evidence), /summary differs from receipts/);
|
|
149
|
-
await assert.rejects(exportEvaluation(run, join(f.root, 'bad'), { yes: true, log: () => { } }), /audit failed/);
|
|
150
|
-
writeFileSync(file, original);
|
|
151
|
-
reseal(run);
|
|
152
|
-
const output = join(f.root, 'portable');
|
|
153
|
-
await exportEvaluation(run, output, { yes: true, log: () => { } });
|
|
154
|
-
const delivery = join(output, 'run/example-task/baseline/trial-1/_output.md');
|
|
155
|
-
writeFileSync(delivery, 'wrong delivery');
|
|
156
|
-
const index = JSON.parse(readFileSync(join(output, 'run/_artifacts.json'), 'utf8'));
|
|
157
|
-
index.files['example-task/baseline/trial-1/_output.md'] = sha256File(delivery);
|
|
158
|
-
writeFileSync(join(output, 'run/_artifacts.json'), JSON.stringify(index));
|
|
159
|
-
const metadata = JSON.parse(readFileSync(join(output, 'replay-package.json'), 'utf8'));
|
|
160
|
-
for (const file of Object.keys(metadata.files))
|
|
161
|
-
metadata.files[file] = sha256File(join(output, file));
|
|
162
|
-
writeFileSync(join(output, 'replay-package.json'), JSON.stringify(metadata));
|
|
163
|
-
const replayed = spawnSync(process.execPath, [join(output, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000 });
|
|
164
|
-
assert.equal(replayed.status, 2);
|
|
165
|
-
assert.match(replayed.stderr, /verdict differs/);
|
|
166
|
-
assert.equal(f.calls(), 1);
|
|
167
|
-
});
|
|
168
|
-
test('paired judge portable replay retains both review calls and full costs without invoking judge again', async (t) => {
|
|
169
|
-
const f = await fixture(t);
|
|
170
|
-
let judgeCalls = 0;
|
|
171
|
-
const judge = { describe: () => ({ kind: 'stub', model: 'offline-judge' }), run: async () => {
|
|
172
|
-
judgeCalls++;
|
|
173
|
-
return { output: JSON.stringify({ A: { correct: true, complete: true, grounded: true }, B: { correct: true, complete: true, grounded: true } }), tokens: { input: 20, cachedInput: 4, output: 5 }, usageStatus: 'final' };
|
|
174
|
-
} };
|
|
175
|
-
const run = join(f.runsRoot, 'judge');
|
|
176
|
-
await runEval({ skillPath: f.skill, bench: f.bench, executor: f.executor, judgeExecutor: judge,
|
|
177
|
-
trials: 1, maxCalls: 4, runsRoot: f.runsRoot, runGroup: 'judge', dryRun: false, yes: true, log: () => { } });
|
|
178
|
-
const before = await readEvaluationReport(run);
|
|
179
|
-
assert.equal(before.evidence.verified, true, JSON.stringify(before.evidence));
|
|
180
|
-
const output = join(f.root, 'portable');
|
|
181
|
-
await exportEvaluation(run, output, { yes: true, log: () => { } });
|
|
182
|
-
rmSync(f.bench, { recursive: true });
|
|
183
|
-
rmSync(f.skill, { recursive: true });
|
|
184
|
-
rmSync(run, { recursive: true });
|
|
185
|
-
const result = replay(output);
|
|
186
|
-
assert.equal(result.evidence.verified, true);
|
|
187
|
-
assert.equal(result.evidence.replayedDeliveries, 2);
|
|
188
|
-
assert.deepEqual(result.invocationCosts, 'invocationCosts' in before ? before.invocationCosts : null);
|
|
189
|
-
assert.equal(result.invocationCosts.judge.runs, 2);
|
|
190
|
-
assert.equal(result.invocationCosts.judge.metrics.input.knownTotal, 40);
|
|
191
|
-
assert.equal(result.invocationCosts.agent.metrics.input.coverage.partial, 2);
|
|
192
|
-
assert.equal(result.invocationCosts.total.runs, 4);
|
|
193
|
-
assert.equal(result.acceptance.automaticUpgrade, false);
|
|
194
|
-
assert.equal(f.calls(), 2);
|
|
195
|
-
assert.equal(judgeCalls, 2);
|
|
196
|
-
});
|
|
197
|
-
test('resealing an outer inventory cannot hide missing plan inputs, a changed approval or a mismatched prompt', async (t) => {
|
|
198
|
-
for (const damage of ['inputs', 'approval', 'prompt', 'invoked'])
|
|
199
|
-
await t.test(damage, async (t) => {
|
|
200
|
-
const f = await fixture(t), run = join(f.runsRoot, 'calibration');
|
|
201
|
-
await runBenchCheck({ dir: f.bench, calibrate: { executor: f.executor, trials: 1, runsRoot: f.runsRoot, runGroup: 'calibration' }, log: () => { } });
|
|
202
|
-
if (damage === 'inputs')
|
|
203
|
-
rewritePlan(run, plan => { delete plan.inputs; });
|
|
204
|
-
if (damage === 'approval')
|
|
205
|
-
rewritePlan(run, plan => { plan.details.executorTimeoutSeconds += 1; });
|
|
206
|
-
if (damage === 'prompt') {
|
|
207
|
-
writeFileSync(join(run, 'example-task/baseline/trial-1/_prompt.txt'), 'different invocation');
|
|
208
|
-
reseal(run);
|
|
209
|
-
}
|
|
210
|
-
if (damage === 'invoked') {
|
|
211
|
-
const path = join(run, 'example-task/baseline/trial-1/_result.json'), receipt = JSON.parse(readFileSync(path, 'utf8'));
|
|
212
|
-
receipt.executorInvoked = false;
|
|
213
|
-
writeFileSync(path, JSON.stringify(receipt));
|
|
214
|
-
reseal(run);
|
|
215
|
-
}
|
|
216
|
-
const report = await readEvaluationReport(run);
|
|
217
|
-
assert.equal(report.evidence.verified, false, damage);
|
|
218
|
-
assert.ok(report.evidence.reasons.length);
|
|
219
|
-
await assert.rejects(exportEvaluation(run, join(f.root, 'refused'), { yes: true, log: () => { } }), /audit failed/);
|
|
220
|
-
assert.equal(existsSync(join(f.root, 'refused')), false);
|
|
221
|
-
assert.equal(f.calls(), 1);
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
test('single-arm budget replay includes setup attempts that never invoked an Agent', async (t) => {
|
|
225
|
-
const f = await fixture(t), run = join(f.runsRoot, 'calibration'), workspace = join(run, 'example-task/baseline/trial-1');
|
|
226
|
-
const limits = { input: 100, cachedInput: 100, uncachedInput: 100, output: 100, durationSeconds: 100 };
|
|
227
|
-
const session = new ExperimentSession({ bench: loadBench(f.bench), target: collectEvaluationTarget(f.skill), groupDir: run,
|
|
228
|
-
workspaces: [workspace], plannedCalls: 1, maxCalls: 1, injected: true,
|
|
229
|
-
details: { mode: 'calibration', inputMode: 'snapshot', trials: 1, spendingBudget: limits } });
|
|
230
|
-
mkdirSync(workspace, { recursive: true });
|
|
231
|
-
const observation = { executorInvoked: false, passed: false, error: 'Synthetic Git setup refusal', durationSeconds: 0, tokens: null, usageStatus: 'unknown' };
|
|
232
|
-
writeFileSync(join(workspace, '_result.json'), JSON.stringify({ schemaVersion: 2, taskId: 'example-task', trial: 1, condition: 'baseline', ...observation }));
|
|
233
|
-
const budget = createSpendingBudgetRecorder({ budget: limits, groupDir: run }), identity = { taskId: 'example-task', condition: 'baseline', trial: 1 };
|
|
234
|
-
budget.before(identity);
|
|
235
|
-
let failure;
|
|
236
|
-
try {
|
|
237
|
-
budget.after(identity, observation);
|
|
238
|
-
}
|
|
239
|
-
catch (error) {
|
|
240
|
-
failure = error;
|
|
241
|
-
}
|
|
242
|
-
assert.ok(failure);
|
|
243
|
-
const summary = { schemaVersion: 1, runGroup: 'calibration', inputMode: 'snapshot', trials: 1,
|
|
244
|
-
tasks: [{ id: 'example-task', passes: 0, completed: 0, errors: 1 }], costs: summarizeCosts({ baseline: [observation], treatment: [] }, { baseline: [], treatment: [] }), experiment: session.summary() };
|
|
245
|
-
writeFileSync(join(run, '_calibration.json'), JSON.stringify(summary));
|
|
246
|
-
session.finish(failure, summary, '_calibration.json');
|
|
247
|
-
const before = await readEvaluationReport(run);
|
|
248
|
-
assert.ok('evaluationType' in before);
|
|
249
|
-
assert.equal(before.evidence.verified, true, JSON.stringify(before.evidence));
|
|
250
|
-
assert.equal(before.usage?.runs, 0);
|
|
251
|
-
assert.equal(before.status, 'stopped');
|
|
252
|
-
const output = join(f.root, 'portable');
|
|
253
|
-
await exportEvaluation(run, output, { yes: true, log: () => { } });
|
|
254
|
-
const result = replay(output);
|
|
255
|
-
assert.equal(result.evidence.verified, true);
|
|
256
|
-
assert.equal(result.usage.runs, 0);
|
|
257
|
-
assert.equal(result.summary.metrics.errors, 1);
|
|
258
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
259
|
-
assert.equal(f.calls(), 0);
|
|
260
|
-
});
|
|
261
|
-
test('portable replay forwards interruption and waits for verifier cleanup before exiting', async (t) => {
|
|
262
|
-
for (const signal of ['SIGINT', 'SIGTERM'])
|
|
263
|
-
await t.test(signal, async (t) => {
|
|
264
|
-
const f = await fixture(t), enabled = join(f.root, 'enable-hanging-verifier'), pidFile = join(f.root, 'verifier.pid');
|
|
265
|
-
writeFileSync(join(f.bench, 'verifiers/example-task.mjs'), `import{existsSync,readFileSync,writeFileSync}from'node:fs';import{join}from'node:path';if(existsSync(${JSON.stringify(enabled)})){writeFileSync(${JSON.stringify(pidFile)},String(process.pid));setInterval(()=>{},1000);}else{const file=join(process.argv[2],'_output.md');const passed=existsSync(file)&&readFileSync(file,'utf8').includes('skillfit-ok');console.log(JSON.stringify({passed}));process.exit(passed?0:1);}`);
|
|
266
|
-
const run = join(f.runsRoot, 'cancel');
|
|
267
|
-
await runEval({ skillPath: f.skill, bench: f.bench, executor: f.executor, judgeExecutor: null,
|
|
268
|
-
trials: 1, runsRoot: f.runsRoot, runGroup: 'cancel', dryRun: false, yes: true, log: () => { } });
|
|
269
|
-
const output = join(f.root, 'portable');
|
|
270
|
-
await exportEvaluation(run, output, { yes: true, log: () => { } });
|
|
271
|
-
const before = packageFiles(output).map(path => [path, sha256File(join(output, path))]);
|
|
272
|
-
writeFileSync(enabled, 'hang only replay');
|
|
273
|
-
const entry = join(output, 'reproduce.mjs');
|
|
274
|
-
const argv = process.platform === 'win32' ? ['--input-type=module', '--eval', `process.on('message',message=>{if(message?.signal)process.emit(message.signal);});process.channel?.unref();await import(${JSON.stringify(pathToFileURL(entry).href)});`] : [entry];
|
|
275
|
-
const child = spawn(process.execPath, argv, { stdio: ['ignore', 'pipe', 'pipe', 'ipc'], windowsHide: true });
|
|
276
|
-
let stdout = '', stderr = '', verifierPid;
|
|
277
|
-
child.stdout.on('data', chunk => { stdout += String(chunk); });
|
|
278
|
-
child.stderr.on('data', chunk => { stderr += String(chunk); });
|
|
279
|
-
const closed = new Promise((resolve, reject) => { child.once('close', resolve); child.once('error', reject); });
|
|
280
|
-
t.after(() => { child.kill('SIGKILL'); if (verifierPid)
|
|
281
|
-
try {
|
|
282
|
-
process.kill(verifierPid, 'SIGKILL');
|
|
283
|
-
}
|
|
284
|
-
catch { /* Already cleaned. */ } });
|
|
285
|
-
const until = Date.now() + 15_000;
|
|
286
|
-
while (!existsSync(pidFile) && Date.now() < until)
|
|
287
|
-
await new Promise(resolve => setTimeout(resolve, 20));
|
|
288
|
-
assert.ok(existsSync(pidFile), `Pinned replay verifier did not start: ${stderr}`);
|
|
289
|
-
verifierPid = Number(readFileSync(pidFile, 'utf8'));
|
|
290
|
-
assert.doesNotThrow(() => process.kill(verifierPid, 0));
|
|
291
|
-
if (process.platform === 'win32')
|
|
292
|
-
child.send({ signal });
|
|
293
|
-
else
|
|
294
|
-
child.kill(signal);
|
|
295
|
-
let timer;
|
|
296
|
-
try {
|
|
297
|
-
const code = await Promise.race([closed, new Promise((_, reject) => { timer = setTimeout(() => reject(new Error('Portable replay did not finish verifier cleanup after interruption.')), 15_000); })]);
|
|
298
|
-
assert.equal(code, signal === 'SIGINT' ? 130 : 143, stderr);
|
|
299
|
-
}
|
|
300
|
-
finally {
|
|
301
|
-
if (timer)
|
|
302
|
-
clearTimeout(timer);
|
|
303
|
-
}
|
|
304
|
-
assert.equal(stdout, '', 'Interrupted replay must not emit a successful JSON assessment.');
|
|
305
|
-
assert.match(stderr, /waited for the pinned CLI/);
|
|
306
|
-
let alive = true;
|
|
307
|
-
try {
|
|
308
|
-
process.kill(verifierPid, 0);
|
|
309
|
-
}
|
|
310
|
-
catch {
|
|
311
|
-
alive = false;
|
|
312
|
-
}
|
|
313
|
-
assert.equal(alive, false, 'Local verifier must have exited before reproduce.mjs exits.');
|
|
314
|
-
verifierPid = undefined;
|
|
315
|
-
assert.deepEqual(packageFiles(output).map(path => [path, sha256File(join(output, path))]), before, 'Replay cancellation never alters sealed input evidence.');
|
|
316
|
-
assert.equal(f.calls(), 2);
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
test('broken single-arm inventory preserves readable costs and counts lost or invalid receipts as unknown', async (t) => {
|
|
320
|
-
for (const mode of ['calibration', 'trigger'])
|
|
321
|
-
await t.test(mode, async (t) => {
|
|
322
|
-
const f = await fixture(t), run = join(f.runsRoot, mode), arm = mode === 'calibration' ? 'baseline' : 'installed';
|
|
323
|
-
if (mode === 'calibration')
|
|
324
|
-
await runBenchCheck({ dir: f.bench, calibrate: { executor: f.executor, trials: 2, runsRoot: f.runsRoot, runGroup: mode }, log: () => { } });
|
|
325
|
-
else
|
|
326
|
-
await runEval({ skillPath: f.skill, bench: f.bench, mode, skillInstallDir: '.test-skills', executor: f.executor,
|
|
327
|
-
trials: 2, runsRoot: f.runsRoot, runGroup: mode, dryRun: false, yes: true, log: () => { } });
|
|
328
|
-
const first = join(run, 'example-task', arm, 'trial-1/_result.json'), second = join(run, 'example-task', arm, 'trial-2/_result.json');
|
|
329
|
-
rmSync(first);
|
|
330
|
-
const missing = await readEvaluationReport(run);
|
|
331
|
-
assert.ok('evaluationType' in missing);
|
|
332
|
-
assert.equal(missing.evidence.verified, false);
|
|
333
|
-
assert.equal(missing.usage?.runs, 2);
|
|
334
|
-
assert.equal(missing.usage?.invocationsWithUnknownReceipts, 1);
|
|
335
|
-
assert.equal(missing.usage?.metrics.input.knownTotal, 10);
|
|
336
|
-
assert.equal(missing.usage?.metrics.input.coverage.partial, 1);
|
|
337
|
-
assert.equal(missing.usage?.metrics.input.coverage.unknown, 1);
|
|
338
|
-
writeFileSync(second, '{invalid raw receipt');
|
|
339
|
-
const invalid = await readEvaluationReport(run);
|
|
340
|
-
assert.ok('evaluationType' in invalid);
|
|
341
|
-
assert.equal(invalid.evidence.verified, false);
|
|
342
|
-
assert.equal(invalid.usage?.runs, 2);
|
|
343
|
-
assert.equal(invalid.usage?.invocationsWithUnknownReceipts, 2);
|
|
344
|
-
assert.equal(invalid.usage?.metrics.input.coverage.unknown, 2);
|
|
345
|
-
assert.match(invalid.usage?.scope ?? '', /Unaudited/);
|
|
346
|
-
assert.equal(invalid.acceptance.eligibleForUpgrade, false);
|
|
347
|
-
await assert.rejects(exportEvaluation(run, join(f.root, 'invalid'), { yes: true, log: () => { } }), /Native evidence inventory changed/);
|
|
348
|
-
assert.equal(f.calls(), 2);
|
|
349
|
-
});
|
|
350
|
-
});
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { chmodSync, existsSync, lstatSync, 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 } from './bench.js';
|
|
9
|
-
import { runEval } from './eval.js';
|
|
10
|
-
import { exportEvaluation } from './eval-export.js';
|
|
11
|
-
import { reportEvalComponent } from './eval-component.js';
|
|
12
|
-
import { MockExecutor } from '../harness/executors/mock.js';
|
|
13
|
-
import { packageFiles, packageMember, verifyReplayPackage } from '../harness/replay-package.js';
|
|
14
|
-
import { sha256File, sha256Text } from '../harness/hash.js';
|
|
15
|
-
import { loadBench } from '../harness/bench.js';
|
|
16
|
-
import { collectEvaluationTarget } from '../harness/target.js';
|
|
17
|
-
import { ExperimentSession } from '../harness/experiment-session.js';
|
|
18
|
-
import { runTrial } from '../harness/runner.js';
|
|
19
|
-
import { ExecutorFailure } from '../harness/types.js';
|
|
20
|
-
async function fixture(t, stopped = false) {
|
|
21
|
-
const root = mkdtempSync(join(tmpdir(), 'skillfit-export-'));
|
|
22
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
23
|
-
const bench = join(root, 'bench'), skill = join(root, 'skill'), runsRoot = join(root, 'runs'), run = join(runsRoot, 'saved');
|
|
24
|
-
await runBenchInit({ dir: bench, yes: true, log: () => { } });
|
|
25
|
-
mkdirSync(skill);
|
|
26
|
-
writeFileSync(join(skill, 'SKILL.md'), '# Synthetic export test\n');
|
|
27
|
-
const mock = new MockExecutor();
|
|
28
|
-
let calls = 0;
|
|
29
|
-
const executor = { describe: () => mock.describe(), run: async (...args) => {
|
|
30
|
-
calls++;
|
|
31
|
-
if (stopped)
|
|
32
|
-
throw new ExecutorFailure('synthetic stop', { output: 'partial result', tokens: { input: 9, cachedInput: 3, output: 2 }, usageStatus: 'partial' });
|
|
33
|
-
return mock.run(...args);
|
|
34
|
-
} };
|
|
35
|
-
if (!stopped)
|
|
36
|
-
await runEval({ skillPath: skill, bench, taskIds: ['example-task'], trials: 1, maxCalls: 2,
|
|
37
|
-
executor, judgeExecutor: null, dryRun: false, yes: true, runsRoot, runGroup: 'saved', log: () => { } });
|
|
38
|
-
else {
|
|
39
|
-
const target = collectEvaluationTarget(skill), loaded = loadBench(bench);
|
|
40
|
-
const session = new ExperimentSession({ bench: loaded, target, groupDir: run, workspaces: [join(run, 'example-task/baseline/trial-1')],
|
|
41
|
-
plannedCalls: 2, maxCalls: 2, injected: true, details: { mode: 'inject' } });
|
|
42
|
-
await runTrial({ bench: loaded, target, executor: session.wrap(executor, 'agent'), trials: 1, runsRoot, runGroup: 'saved', log: () => { } }, 'example-task', 'baseline', 1);
|
|
43
|
-
session.finish(new Error('synthetic stop'));
|
|
44
|
-
}
|
|
45
|
-
return { root, bench, skill, run, output: join(root, 'portable'), calls: () => calls };
|
|
46
|
-
}
|
|
47
|
-
test('export previews are read-only and complete packages replay after original paths disappear', async (t) => {
|
|
48
|
-
const f = await fixture(t), originalPlan = readFileSync(join(f.run, '_plan.json'), 'utf8');
|
|
49
|
-
const before = await reportEvalComponent(f.run);
|
|
50
|
-
rmSync(f.bench, { recursive: true });
|
|
51
|
-
rmSync(f.skill, { recursive: true });
|
|
52
|
-
const movedRun = join(f.root, 'moved native run');
|
|
53
|
-
renameSync(f.run, movedRun);
|
|
54
|
-
f.run = movedRun;
|
|
55
|
-
const plan = await exportEvaluation(f.run, f.output, { log: () => { } });
|
|
56
|
-
assert.equal(plan.status, 'planned');
|
|
57
|
-
assert.equal(plan.modelCalls, 0);
|
|
58
|
-
assert.ok(!existsSync(f.output));
|
|
59
|
-
assert.equal(plan.inputSource, 'sealed-snapshot');
|
|
60
|
-
await exportEvaluation(f.run, f.output, { yes: true, log: () => { } });
|
|
61
|
-
assert.equal(readFileSync(join(f.run, '_plan.json'), 'utf8'), originalPlan);
|
|
62
|
-
const moved = join(f.root, 'received package');
|
|
63
|
-
renameSync(f.output, moved);
|
|
64
|
-
rmSync(f.run, { recursive: true });
|
|
65
|
-
const checksum = spawnSync(process.execPath, [join(moved, 'reproduce.mjs'), '--verify-only'], { encoding: 'utf8' });
|
|
66
|
-
assert.equal(checksum.status, 0, checksum.stderr);
|
|
67
|
-
assert.equal(JSON.parse(checksum.stdout).modelCalls, 0);
|
|
68
|
-
const replay = spawnSync(process.execPath, [join(moved, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000 });
|
|
69
|
-
assert.equal(replay.status, 0, replay.stderr);
|
|
70
|
-
const data = JSON.parse(replay.stdout);
|
|
71
|
-
assert.equal(data.evidence.verified, true);
|
|
72
|
-
assert.equal(data.acceptance.automaticUpgrade, false);
|
|
73
|
-
assert.deepEqual(data.costs, 'costs' in before ? before.costs : null);
|
|
74
|
-
assert.deepEqual(data.casePreflight, JSON.parse(originalPlan).details.casePreflight, 'export retains the original probes, including offline timing and unknowns');
|
|
75
|
-
const inspected = await reportEvalComponent(moved, { replay: true });
|
|
76
|
-
assert.ok('portablePackage' in inspected && inspected.portablePackage.integrityVerified);
|
|
77
|
-
assert.equal(f.calls(), 2);
|
|
78
|
-
});
|
|
79
|
-
test('stopped exports preserve partial costs and cannot become completed evidence', async (t) => {
|
|
80
|
-
const f = await fixture(t, true), before = await reportEvalComponent(f.run);
|
|
81
|
-
assert.equal(before.status, 'stopped');
|
|
82
|
-
rmSync(f.bench, { recursive: true });
|
|
83
|
-
rmSync(f.skill, { recursive: true });
|
|
84
|
-
await exportEvaluation(f.run, f.output, { yes: true, log: () => { } });
|
|
85
|
-
const replay = spawnSync(process.execPath, [join(f.output, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000 });
|
|
86
|
-
assert.equal(replay.status, 0, replay.stderr);
|
|
87
|
-
const data = JSON.parse(replay.stdout);
|
|
88
|
-
assert.equal(data.status, 'stopped');
|
|
89
|
-
assert.equal(data.evidence.verified, false);
|
|
90
|
-
assert.deepEqual(data.costs, 'costs' in before ? before.costs : null);
|
|
91
|
-
assert.equal(data.acceptance.eligibleForUpgrade, false);
|
|
92
|
-
assert.equal(f.calls(), 1);
|
|
93
|
-
});
|
|
94
|
-
test('human and JSON reports accept identical native inputs and preserve completed/stopped evidence', async (t) => {
|
|
95
|
-
const cli = fileURLToPath(new URL('../cli.js', import.meta.url));
|
|
96
|
-
for (const stopped of [false, true])
|
|
97
|
-
await t.test(stopped ? 'stopped' : 'completed', async (t) => {
|
|
98
|
-
const f = await fixture(t, stopped), before = readFileSync(join(f.run, '_artifacts.json'), 'utf8');
|
|
99
|
-
const invoke = (path, args = []) => spawnSync(process.execPath, [cli, 'report', 'eval', path, ...args], { encoding: 'utf8', timeout: 30_000, maxBuffer: 8 * 1024 * 1024 });
|
|
100
|
-
const machine = invoke(f.run, ['--json']);
|
|
101
|
-
assert.equal(machine.status, 0, machine.stderr);
|
|
102
|
-
const data = JSON.parse(machine.stdout), human = invoke(f.run);
|
|
103
|
-
assert.equal(human.status, 0, human.stderr);
|
|
104
|
-
assert.match(human.stdout, new RegExp(`State: ${data.status}`));
|
|
105
|
-
assert.match(human.stdout, new RegExp(`Acceptance: ${data.acceptance.decision}`));
|
|
106
|
-
assert.match(human.stdout, new RegExp(`Native evidence: ${data.evidence.verified ? 'verified' : 'unverified'}`));
|
|
107
|
-
assert.match(human.stdout, /Automatic upgrade: no/);
|
|
108
|
-
assert.match(human.stdout, /Sealed input cost:/);
|
|
109
|
-
if (!stopped) {
|
|
110
|
-
const manifest = invoke(join(f.run, 'manifest.json'));
|
|
111
|
-
assert.equal(manifest.status, 0, manifest.stderr);
|
|
112
|
-
assert.equal(manifest.stdout, human.stdout);
|
|
113
|
-
const policyPath = join(f.root, 'policy.json');
|
|
114
|
-
writeFileSync(policyPath, '{}');
|
|
115
|
-
const flags = ['--records', f.run, '--policy', policyPath];
|
|
116
|
-
const policyJson = invoke(join(f.run, 'manifest.json'), [...flags, '--json']);
|
|
117
|
-
const policyHuman = invoke(join(f.run, 'manifest.json'), flags);
|
|
118
|
-
assert.equal(policyJson.status, 0, policyJson.stderr);
|
|
119
|
-
assert.equal(policyHuman.status, 0, policyHuman.stderr);
|
|
120
|
-
assert.match(policyHuman.stdout, new RegExp(`Acceptance: ${JSON.parse(policyJson.stdout).acceptance.decision}`));
|
|
121
|
-
const replay = invoke(f.run, ['--replay']);
|
|
122
|
-
assert.equal(replay.status, 0, replay.stderr);
|
|
123
|
-
assert.match(replay.stdout, /Native evidence: verified/);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
assert.match(human.stdout, /No completed paired comparison/);
|
|
127
|
-
assert.match(human.stdout, /Retained costs/);
|
|
128
|
-
assert.match(human.stdout, /partial/);
|
|
129
|
-
}
|
|
130
|
-
await exportEvaluation(f.run, f.output, { yes: true, log: () => { } });
|
|
131
|
-
const portable = invoke(f.output, ['--replay']);
|
|
132
|
-
assert.equal(portable.status, 0, portable.stderr);
|
|
133
|
-
assert.match(portable.stdout, new RegExp(`State: ${data.status}`));
|
|
134
|
-
assert.match(portable.stdout, /Automatic upgrade: no/);
|
|
135
|
-
assert.equal(readFileSync(join(f.run, '_artifacts.json'), 'utf8'), before);
|
|
136
|
-
assert.equal(f.calls(), stopped ? 1 : 2);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
test('human incomplete reports retain unknown receipts and never invent a completed quality result', async (t) => {
|
|
140
|
-
const root = mkdtempSync(join(tmpdir(), 'skillfit-report-incomplete-'));
|
|
141
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
142
|
-
writeFileSync(join(root, '_plan.json'), '{}');
|
|
143
|
-
writeFileSync(join(root, '_calls.jsonl'), JSON.stringify({ event: 'started', role: 'agent', workdir: join(root, 'case/baseline/trial-1') }) + '\n');
|
|
144
|
-
const cli = fileURLToPath(new URL('../cli.js', import.meta.url));
|
|
145
|
-
const human = spawnSync(process.execPath, [cli, 'report', 'eval', root], { encoding: 'utf8' });
|
|
146
|
-
assert.equal(human.status, 0, human.stderr);
|
|
147
|
-
assert.match(human.stdout, /State: incomplete/);
|
|
148
|
-
assert.match(human.stdout, /Missing or invalid invocation receipts: 1/);
|
|
149
|
-
assert.match(human.stdout, /Acceptance: inconclusive/);
|
|
150
|
-
assert.match(human.stdout, /Eligible for upgrade: no/);
|
|
151
|
-
assert.match(human.stdout, /unknown/);
|
|
152
|
-
assert.ok(!existsSync(join(root, 'manifest.json')));
|
|
153
|
-
});
|
|
154
|
-
test('changed original inputs do not prevent export; nested destinations and collisions still fail', async (t) => {
|
|
155
|
-
const f = await fixture(t), original = readFileSync(join(f.run, '_artifacts.json'), 'utf8');
|
|
156
|
-
await assert.rejects(() => exportEvaluation(f.run, join(f.run, 'bad'), { yes: true, log: () => { } }), /outside/);
|
|
157
|
-
mkdirSync(f.output);
|
|
158
|
-
await assert.rejects(() => exportEvaluation(f.run, f.output, { yes: true, log: () => { } }), /already exists/);
|
|
159
|
-
rmSync(f.output, { recursive: true });
|
|
160
|
-
writeFileSync(join(f.skill, 'SKILL.md'), 'changed');
|
|
161
|
-
await assert.rejects(() => exportEvaluation(f.run, join(f.skill, 'bad'), { yes: true, log: () => { } }), /outside/);
|
|
162
|
-
await exportEvaluation(f.run, f.output, { yes: true, log: () => { } });
|
|
163
|
-
assert.equal(readFileSync(join(f.output, 'inputs/target/SKILL.md'), 'utf8'), '# Synthetic export test\n');
|
|
164
|
-
assert.equal(readFileSync(join(f.run, '_artifacts.json'), 'utf8'), original);
|
|
165
|
-
});
|
|
166
|
-
test('portable inspections reject changed files, extra files and unsafe paths', async (t) => {
|
|
167
|
-
const f = await fixture(t);
|
|
168
|
-
await exportEvaluation(f.run, f.output, { yes: true, log: () => { } });
|
|
169
|
-
for (const path of ['../escape', '/absolute', 'C:/escape', 'a\\b', '.git/config'])
|
|
170
|
-
assert.throws(() => packageMember(f.output, path), /Unsafe/);
|
|
171
|
-
writeFileSync(join(f.output, 'extra'), 'unexpected');
|
|
172
|
-
assert.throws(() => verifyReplayPackage(f.output), /inventory/);
|
|
173
|
-
rmSync(join(f.output, 'extra'));
|
|
174
|
-
writeFileSync(join(f.output, 'run/manifest.json'), '{}');
|
|
175
|
-
await assert.rejects(() => reportEvalComponent(f.output, { replay: true }), /hash mismatch/);
|
|
176
|
-
const human = spawnSync(process.execPath, [fileURLToPath(new URL('../cli.js', import.meta.url)), 'report', 'eval', f.output], { encoding: 'utf8' });
|
|
177
|
-
assert.notEqual(human.status, 0);
|
|
178
|
-
assert.match(human.stderr, /hash mismatch/);
|
|
179
|
-
const verify = spawnSync(process.execPath, [join(f.output, 'reproduce.mjs'), '--verify-only'], { encoding: 'utf8' });
|
|
180
|
-
assert.equal(verify.status, 2);
|
|
181
|
-
assert.equal(f.calls(), 2);
|
|
182
|
-
});
|
|
183
|
-
test('restored input roots still require original fingerprints and CLI exports are plans by default', async (t) => {
|
|
184
|
-
const f = await fixture(t), restored = join(f.root, 'restored-skill');
|
|
185
|
-
renameSync(f.skill, restored);
|
|
186
|
-
assert.equal((await exportEvaluation(f.run, f.output, { log: () => { } })).status, 'planned');
|
|
187
|
-
const cli = fileURLToPath(new URL('../cli.js', import.meta.url));
|
|
188
|
-
const result = spawnSync(process.execPath, [cli, 'report', 'eval', f.run, '--export', f.output,
|
|
189
|
-
'--input-root', `target=${restored}`, '--json'], { encoding: 'utf8' });
|
|
190
|
-
assert.equal(result.status, 0, result.stderr);
|
|
191
|
-
assert.equal(JSON.parse(result.stdout).status, 'planned');
|
|
192
|
-
assert.ok(!existsSync(f.output));
|
|
193
|
-
await exportEvaluation(f.run, f.output, { yes: true, inputRoots: [`target=${restored}`], log: () => { } });
|
|
194
|
-
assert.equal(verifyReplayPackage(f.output).hasManifest, true);
|
|
195
|
-
assert.equal(f.calls(), 2);
|
|
196
|
-
});
|
|
197
|
-
/** Build a historical plan without inventing snapshots for old evidence. */
|
|
198
|
-
function legacy(run) {
|
|
199
|
-
const plan = JSON.parse(readFileSync(join(run, '_plan.json'), 'utf8'));
|
|
200
|
-
delete plan.inputSnapshot;
|
|
201
|
-
rmSync(join(run, '_inputs'), { recursive: true });
|
|
202
|
-
rmSync(join(run, '_inputs.json'));
|
|
203
|
-
const bytes = JSON.stringify(plan, null, 2) + '\n', planSha256 = sha256Text(bytes);
|
|
204
|
-
writeFileSync(join(run, '_plan.json'), bytes);
|
|
205
|
-
const manifest = JSON.parse(readFileSync(join(run, 'manifest.json'), 'utf8'));
|
|
206
|
-
manifest.experiment.planSha256 = planSha256;
|
|
207
|
-
writeFileSync(join(run, 'manifest.json'), JSON.stringify(manifest));
|
|
208
|
-
const session = JSON.parse(readFileSync(join(run, '_session.json'), 'utf8'));
|
|
209
|
-
session.planSha256 = planSha256;
|
|
210
|
-
writeFileSync(join(run, '_session.json'), JSON.stringify(session));
|
|
211
|
-
writeFileSync(join(run, '_artifacts.json'), JSON.stringify({ schemaVersion: 1, planSha256,
|
|
212
|
-
files: Object.fromEntries(packageFiles(run).filter(path => path !== '_artifacts.json').map(path => [path, sha256File(join(run, path))])), links: {} }));
|
|
213
|
-
}
|
|
214
|
-
test('historical runs retain matching-root recovery and never acquire synthetic snapshots', async (t) => {
|
|
215
|
-
const f = await fixture(t);
|
|
216
|
-
legacy(f.run);
|
|
217
|
-
const restored = join(f.root, 'restored');
|
|
218
|
-
renameSync(f.skill, restored);
|
|
219
|
-
await assert.rejects(exportEvaluation(f.run, f.output, { log: () => { } }));
|
|
220
|
-
const plan = await exportEvaluation(f.run, f.output, { yes: true, inputRoots: [`target=${restored}`], log: () => { } });
|
|
221
|
-
assert.equal(plan.inputSource, 'original-or-recovered');
|
|
222
|
-
assert.ok(!existsSync(join(f.run, '_inputs')));
|
|
223
|
-
assert.equal(verifyReplayPackage(f.output).hasManifest, true);
|
|
224
|
-
writeFileSync(join(restored, 'SKILL.md'), 'wrong revision');
|
|
225
|
-
await assert.rejects(exportEvaluation(f.run, join(f.root, 'bad'), { inputRoots: [`target=${restored}`], log: () => { } }), /changed|unavailable/);
|
|
226
|
-
});
|
|
227
|
-
test('snapshot damage never falls back to matching originals, even after resealing the outer inventory', async (t) => {
|
|
228
|
-
for (const damage of ['missing', 'changed', 'extra', 'link', 'index'])
|
|
229
|
-
await t.test(damage, async (t) => {
|
|
230
|
-
const f = await fixture(t), file = join(f.run, '_inputs/target/SKILL.md');
|
|
231
|
-
if (damage === 'missing')
|
|
232
|
-
rmSync(file);
|
|
233
|
-
if (damage === 'changed')
|
|
234
|
-
writeFileSync(file, 'tampered');
|
|
235
|
-
if (damage === 'extra')
|
|
236
|
-
writeFileSync(join(f.run, '_inputs/extra'), 'unlisted');
|
|
237
|
-
if (damage === 'link') {
|
|
238
|
-
rmSync(file);
|
|
239
|
-
symlinkSync(join(f.skill, 'SKILL.md'), file);
|
|
240
|
-
}
|
|
241
|
-
if (damage === 'index')
|
|
242
|
-
writeFileSync(join(f.run, '_inputs.json'), '{}');
|
|
243
|
-
if (damage !== 'link') {
|
|
244
|
-
const index = JSON.parse(readFileSync(join(f.run, '_artifacts.json'), 'utf8'));
|
|
245
|
-
index.files = Object.fromEntries(packageFiles(f.run).filter(path => path !== '_artifacts.json').map(path => [path, sha256File(join(f.run, path))]));
|
|
246
|
-
writeFileSync(join(f.run, '_artifacts.json'), JSON.stringify(index));
|
|
247
|
-
}
|
|
248
|
-
await assert.rejects(exportEvaluation(f.run, f.output, { yes: true, inputRoots: [`target=${f.skill}`], log: () => { } }));
|
|
249
|
-
assert.ok(!existsSync(f.output));
|
|
250
|
-
assert.equal(f.calls(), 2);
|
|
251
|
-
const report = await reportEvalComponent(f.run);
|
|
252
|
-
assert.ok('evidence' in report && !report.evidence.verified);
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
test('copies preserve empty fixture directories and executable local verifiers', async (t) => {
|
|
256
|
-
const root = mkdtempSync(join(tmpdir(), 'skillfit-empty-input-'));
|
|
257
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
258
|
-
const bench = join(root, 'bench'), skill = join(root, 'skill'), run = join(root, 'runs/saved');
|
|
259
|
-
mkdirSync(join(bench, 'empty'), { recursive: true });
|
|
260
|
-
mkdirSync(skill);
|
|
261
|
-
writeFileSync(join(skill, 'SKILL.md'), '# Offline empty-fixture test');
|
|
262
|
-
const verifier = join(bench, 'check.mjs');
|
|
263
|
-
writeFileSync(verifier, "import{existsSync,readFileSync}from'node:fs';import{join}from'node:path';const p=join(process.argv[2],'_output.md');process.exit(existsSync(p)&&readFileSync(p,'utf8')==='answer'?0:1);");
|
|
264
|
-
chmodSync(verifier, 0o755);
|
|
265
|
-
writeFileSync(join(bench, 'bench.json'), JSON.stringify({ schemaVersion: 1, tasks: [{ id: 'empty', fixture: 'empty', prompt: 'prompt.md', verifier: 'node check.mjs' }] }));
|
|
266
|
-
writeFileSync(join(bench, 'prompt.md'), 'Give the expected answer.');
|
|
267
|
-
const executor = { describe: () => ({ kind: 'mock', model: 'offline' }), run: async () => ({ output: 'answer' }) };
|
|
268
|
-
await runEval({ skillPath: skill, bench, executor, judgeExecutor: null, trials: 1, dryRun: false, yes: true, runsRoot: join(root, 'runs'), runGroup: 'saved', log: () => { } });
|
|
269
|
-
rmSync(bench, { recursive: true });
|
|
270
|
-
rmSync(skill, { recursive: true });
|
|
271
|
-
const output = join(root, 'portable');
|
|
272
|
-
await exportEvaluation(run, output, { yes: true, log: () => { } });
|
|
273
|
-
assert.ok(lstatSync(join(output, 'inputs/bench/empty')).isDirectory());
|
|
274
|
-
if (process.platform !== 'win32')
|
|
275
|
-
assert.ok(lstatSync(join(output, 'inputs/bench/check.mjs')).mode & 0o111);
|
|
276
|
-
const replay = spawnSync(process.execPath, [join(output, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000 });
|
|
277
|
-
assert.equal(replay.status, 0, replay.stderr);
|
|
278
|
-
assert.equal(JSON.parse(replay.stdout).evidence.verified, true);
|
|
279
|
-
});
|