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
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { chmodSync, existsSync, mkdirSync, mkdtempSync, 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 { getAgent } from '../agents.js';
|
|
9
|
-
import { findExecutable, globalSkillRoots, inspectAgentEnvironment, AgentPreflightFailed, assertRecordedAgentEnvironment } from '../harness/agent-preflight.js';
|
|
10
|
-
import { collectEvaluationTarget } from '../harness/target.js';
|
|
11
|
-
import { runEval } from './eval.js';
|
|
12
|
-
import { runEvalCli } from './eval-cli.js';
|
|
13
|
-
import { runEvalComponent, reportEvalComponent, componentError } from './eval-component.js';
|
|
14
|
-
import { exportEvaluation } from './eval-export.js';
|
|
15
|
-
import { runEvalReport } from './eval-report.js';
|
|
16
|
-
const CLI = fileURLToPath(new URL('../cli.js', import.meta.url));
|
|
17
|
-
function setup(t) {
|
|
18
|
-
const root = mkdtempSync(join(tmpdir(), 'skillfit-agent-env-'));
|
|
19
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
20
|
-
const home = join(root, 'home'), profile = join(root, 'profile'), bin = join(root, 'bin'), skill = join(root, 'candidate'), bench = join(root, 'bench');
|
|
21
|
-
for (const dir of [home, profile, bin, skill, join(bench, 'fixture')])
|
|
22
|
-
mkdirSync(dir, { recursive: true });
|
|
23
|
-
writeFileSync(join(skill, 'SKILL.md'), '---\nname: actual-skill-name\ndescription: Test a local answer.\n---\nReturn OK.\n');
|
|
24
|
-
writeFileSync(join(bench, 'fixture/input.txt'), 'input');
|
|
25
|
-
writeFileSync(join(bench, 'prompt.md'), 'Return OK.');
|
|
26
|
-
const verifier = join(bench, 'verify.mjs');
|
|
27
|
-
writeFileSync(verifier, "import{existsSync,readFileSync}from'node:fs';import{join}from'node:path';const file=join(process.argv[2],'_output.md');const passed=existsSync(file)&&readFileSync(file,'utf8').trim()==='OK';console.log(JSON.stringify({passed}));process.exit(passed?0:1);");
|
|
28
|
-
writeFileSync(join(bench, 'bench.json'), JSON.stringify({ schemaVersion: 1, name: 'agent-preflight', tasks: [{ id: 't', fixture: 'fixture', prompt: 'prompt.md', verifier: 'node verify.mjs', shouldTrigger: true }] }));
|
|
29
|
-
const env = { ...process.env, HOME: home, USERPROFILE: home, CODEX_HOME: profile, PATH: bin, SKILLFIT_JUDGE: '0' };
|
|
30
|
-
// Native OS home resolution is not used by direct tests; child CLI tests use both home overrides.
|
|
31
|
-
const binary = join(bin, process.platform === 'win32' ? 'codex.CMD' : 'codex');
|
|
32
|
-
writeFileSync(binary, 'synthetic executable; must never be run');
|
|
33
|
-
chmodSync(binary, 0o755);
|
|
34
|
-
const target = collectEvaluationTarget(skill), definition = getAgent('codex');
|
|
35
|
-
const role = { role: 'agent', definition, executor: { kind: 'cli', model: 'cli-configured' }, injected: false };
|
|
36
|
-
const inspect = (roles = [role]) => inspectAgentEnvironment({ roles, target, mode: 'inject', homeDir: home, env });
|
|
37
|
-
const conflict = (folder = 'alias-folder', name = 'actual-skill-name') => {
|
|
38
|
-
const dir = join(globalSkillRoots(definition, home, env).at(-1), folder);
|
|
39
|
-
mkdirSync(dir, { recursive: true });
|
|
40
|
-
writeFileSync(join(dir, 'SKILL.md'), `---\nname: ${name}\ndescription: A synthetic global Skill.\n---\nPrivate body must not appear in the report.\n`);
|
|
41
|
-
return dir;
|
|
42
|
-
};
|
|
43
|
-
let calls = 0;
|
|
44
|
-
const base = { skillPath: skill, bench, agent: 'codex', trials: 1, maxCalls: 2, dryRun: false, yes: true,
|
|
45
|
-
runsRoot: join(root, 'runs'), runGroup: 'env', judgeExecutor: null, sessionOptions: { homeDir: home, env, versionProbe: () => null },
|
|
46
|
-
executor: { describe: () => ({ kind: 'mock', model: 'offline-agent-env' }), run: async () => {
|
|
47
|
-
calls++;
|
|
48
|
-
return { output: 'OK', tokens: { input: 10, cachedInput: 4, output: 2 } };
|
|
49
|
-
} }, log: () => { } };
|
|
50
|
-
return { root, home, profile, bin, binary, env, target, role, inspect, conflict, base, bench, skill, verifier, calls: () => calls };
|
|
51
|
-
}
|
|
52
|
-
test('PATH lookup inspects executable files without running a CLI or accepting config directories as installation', t => {
|
|
53
|
-
const f = setup(t);
|
|
54
|
-
assert.equal(findExecutable('codex', f.env), findExecutable(f.binary, f.env));
|
|
55
|
-
assert.equal(findExecutable('missing-agent', f.env), null);
|
|
56
|
-
assert.equal(findExecutable('codex', { ...f.env, PATH: '' }), null);
|
|
57
|
-
mkdirSync(join(f.bin, 'directory-agent'));
|
|
58
|
-
assert.equal(findExecutable('directory-agent', f.env), null);
|
|
59
|
-
if (process.platform !== 'win32') {
|
|
60
|
-
chmodSync(f.binary, 0o644);
|
|
61
|
-
assert.equal(findExecutable('codex', f.env), null);
|
|
62
|
-
}
|
|
63
|
-
const report = inspectAgentEnvironment({ roles: [f.role], target: f.target, mode: 'inject', homeDir: f.home, env: { ...f.env, PATH: '' } });
|
|
64
|
-
assert.equal(report.status, 'blocked');
|
|
65
|
-
assert.equal(report.checks.find(c => c.code === 'CLI_AVAILABLE').status, 'FAIL');
|
|
66
|
-
assert.deepEqual(report.cost, { modelCalls: 0, cliInvocations: 0 });
|
|
67
|
-
});
|
|
68
|
-
test('Windows PATH/PATHEXT lookup accepts command shims and case-insensitive environment keys', t => {
|
|
69
|
-
const f = setup(t), file = join(f.bin, 'offline.CMD');
|
|
70
|
-
writeFileSync(file, 'must never execute');
|
|
71
|
-
const path = findExecutable('offline', { Path: `"${f.bin}"`, PathExt: '.CMD;.EXE' }, 'win32');
|
|
72
|
-
assert.ok(path?.endsWith('offline.CMD'));
|
|
73
|
-
assert.equal(findExecutable('absent', { Path: f.bin, PATHEXT: '.CMD' }, 'win32'), null);
|
|
74
|
-
assert.equal(findExecutable('offline', { Path: 'missing', PATH: f.bin, PATHEXT: '.CMD' }, 'win32'), path);
|
|
75
|
-
});
|
|
76
|
-
test('local readiness never claims login even with credentials/config files present, and emits no secret values', t => {
|
|
77
|
-
const f = setup(t), secret = 'synthetic-secret-never-report';
|
|
78
|
-
writeFileSync(join(f.profile, 'auth.json'), JSON.stringify({ access_token: secret }));
|
|
79
|
-
const report = inspectAgentEnvironment({ roles: [f.role], target: f.target, mode: 'installed', homeDir: f.home,
|
|
80
|
-
env: { ...f.env, OPENAI_API_KEY: secret } });
|
|
81
|
-
assert.equal(report.status, 'ready');
|
|
82
|
-
assert.equal(report.checks.find(c => c.code === 'AUTHENTICATION').status, 'UNKNOWN');
|
|
83
|
-
assertRecordedAgentEnvironment(report);
|
|
84
|
-
assert.equal(JSON.stringify(report).includes(secret), false);
|
|
85
|
-
assert.deepEqual(f.inspect(), f.inspect());
|
|
86
|
-
assert.equal(f.calls(), 0);
|
|
87
|
-
});
|
|
88
|
-
test('capability checks use matrix declarations and cover trigger support, installation paths and the judge CLI', t => {
|
|
89
|
-
const f = setup(t), claude = getAgent('claude-code');
|
|
90
|
-
const trigger = inspectAgentEnvironment({ roles: [{ ...f.role, definition: claude }], target: f.target, mode: 'trigger', homeDir: f.home, env: f.env });
|
|
91
|
-
assert.equal(trigger.status, 'blocked');
|
|
92
|
-
assert.match(trigger.checks.find(c => c.code === 'MATRIX_CAPABILITY').message, /streamJson/);
|
|
93
|
-
const missingDirs = structuredClone(f.role.definition);
|
|
94
|
-
missingDirs.skills.projectDirs = [];
|
|
95
|
-
const installed = inspectAgentEnvironment({ roles: [{ ...f.role, definition: missingDirs }], target: f.target, mode: 'installed', homeDir: f.home, env: f.env });
|
|
96
|
-
assert.match(installed.checks.find(c => c.code === 'MATRIX_CAPABILITY').message, /project Skill directory/);
|
|
97
|
-
const judge = structuredClone(f.role.definition);
|
|
98
|
-
judge.headless.argv = ['missing-offline-judge'];
|
|
99
|
-
const judged = f.inspect([f.role, { ...f.role, role: 'judge', definition: judge }]);
|
|
100
|
-
assert.equal(judged.status, 'blocked');
|
|
101
|
-
assert.equal(judged.checks.find(c => c.role === 'judge' && c.code === 'CLI_AVAILABLE').status, 'FAIL');
|
|
102
|
-
assert.equal(judged.checks.filter(c => c.code === 'AUTHENTICATION').length, 2);
|
|
103
|
-
});
|
|
104
|
-
test('global conflicts include frontmatter aliases and configured home overrides without exposing Skill bodies', t => {
|
|
105
|
-
const f = setup(t), dir = f.conflict();
|
|
106
|
-
const report = f.inspect(), conflict = report.checks.find(c => c.code === 'GLOBAL_SKILL_CONFLICT');
|
|
107
|
-
assert.equal(report.status, 'blocked');
|
|
108
|
-
assert.equal(conflict.status, 'FAIL');
|
|
109
|
-
assert.deepEqual(conflict.paths, [dir]);
|
|
110
|
-
assert.match(conflict.message, /Baseline contamination risk/);
|
|
111
|
-
assert.equal(JSON.stringify(report).includes('Private body'), false);
|
|
112
|
-
rmSync(dir, { recursive: true });
|
|
113
|
-
f.conflict(f.target.name, 'different-frontmatter-name');
|
|
114
|
-
assert.equal(f.inspect().status, 'blocked', 'directory-name conflicts remain blocked too');
|
|
115
|
-
});
|
|
116
|
-
test('global alias directories are inspected, and unreadable roots remain explicitly unknown', t => {
|
|
117
|
-
const f = setup(t), real = join(f.root, 'external-skill');
|
|
118
|
-
mkdirSync(real);
|
|
119
|
-
writeFileSync(join(real, 'SKILL.md'), '---\nname: actual-skill-name\ndescription: Alias test.\n---\n');
|
|
120
|
-
const root = globalSkillRoots(f.role.definition, f.home, f.env)[0];
|
|
121
|
-
mkdirSync(root, { recursive: true });
|
|
122
|
-
symlinkSync(real, join(root, 'linked'), process.platform === 'win32' ? 'junction' : 'dir');
|
|
123
|
-
assert.equal(f.inspect().status, 'blocked');
|
|
124
|
-
rmSync(join(root, 'linked'));
|
|
125
|
-
rmSync(root, { recursive: true });
|
|
126
|
-
writeFileSync(root, 'not a directory');
|
|
127
|
-
const unknown = f.inspect().checks.find(c => c.code === 'GLOBAL_SKILL_SCAN');
|
|
128
|
-
assert.equal(unknown.status, 'UNKNOWN');
|
|
129
|
-
assert.ok(unknown.paths.includes(root));
|
|
130
|
-
});
|
|
131
|
-
test('injected executors cannot attest real CLI readiness and API execution does not require a CLI', t => {
|
|
132
|
-
const f = setup(t), injected = f.inspect([{ ...f.role, injected: true }]);
|
|
133
|
-
assert.equal(injected.checks.find(c => c.code === 'EXECUTOR_INJECTED').status, 'UNKNOWN');
|
|
134
|
-
const api = f.inspect([{ role: 'agent', injected: false, executor: { kind: 'api', model: 'offline-not-called' } }]);
|
|
135
|
-
assert.equal(api.status, 'ready');
|
|
136
|
-
assert.equal(api.checks.find(c => c.code === 'CLI_AVAILABLE').status, 'INFO');
|
|
137
|
-
const invalid = structuredClone(api);
|
|
138
|
-
invalid.checks.find(c => c.code === 'AUTHENTICATION').status = 'PASS';
|
|
139
|
-
assert.throws(() => assertRecordedAgentEnvironment(invalid), /environment check/);
|
|
140
|
-
});
|
|
141
|
-
test('capability mismatch is structured and blocks both preview and live execution without invoking API/agent', async (t) => {
|
|
142
|
-
const f = setup(t);
|
|
143
|
-
for (const dryRun of [true, false])
|
|
144
|
-
await assert.rejects(runEval({ ...f.base, dryRun, inputMode: 'workspace',
|
|
145
|
-
executor: { describe: () => ({ kind: 'api', model: 'offline-api' }), run: async () => { throw new Error('must never run'); } } }), error => {
|
|
146
|
-
assert.ok(error instanceof AgentPreflightFailed);
|
|
147
|
-
assert.equal(componentError(error).error.code, 'AGENT_PREFLIGHT_FAILED');
|
|
148
|
-
assert.equal(error.agentPreflight.checks.find(c => c.code === 'MATRIX_CAPABILITY').status, 'FAIL');
|
|
149
|
-
return true;
|
|
150
|
-
});
|
|
151
|
-
assert.equal(f.calls(), 0);
|
|
152
|
-
assert.equal(existsSync(f.base.runsRoot), false);
|
|
153
|
-
});
|
|
154
|
-
test('global conflict blocks before any case verifier, executor, version probe or native directory is created', async (t) => {
|
|
155
|
-
const f = setup(t), sentinel = join(f.root, 'verifier-started'), conflict = f.conflict();
|
|
156
|
-
writeFileSync(f.verifier, `import{writeFileSync}from'node:fs';writeFileSync(${JSON.stringify(sentinel)},'called');process.exit(1);`);
|
|
157
|
-
await assert.rejects(runEval({ ...f.base, sessionOptions: { ...f.base.sessionOptions,
|
|
158
|
-
versionProbe: () => { throw new Error('must not probe the CLI'); } } }), error => {
|
|
159
|
-
assert.ok(error instanceof AgentPreflightFailed);
|
|
160
|
-
assert.equal(error.agentPreflight.status, 'blocked');
|
|
161
|
-
assert.ok(error.message.includes(conflict));
|
|
162
|
-
return true;
|
|
163
|
-
});
|
|
164
|
-
assert.equal(existsSync(sentinel), false);
|
|
165
|
-
assert.equal(f.calls(), 0);
|
|
166
|
-
assert.equal(existsSync(f.base.runsRoot), false);
|
|
167
|
-
});
|
|
168
|
-
test('case probes cannot silently change Agent readiness before first dispatch', async (t) => {
|
|
169
|
-
const f = setup(t), globalDir = join(globalSkillRoots(f.role.definition, f.home, f.env)[0], 'new-global');
|
|
170
|
-
writeFileSync(f.verifier, `import{mkdirSync,writeFileSync}from'node:fs';import{join}from'node:path';mkdirSync(${JSON.stringify(globalDir)},{recursive:true});writeFileSync(join(${JSON.stringify(globalDir)},'SKILL.md'),${JSON.stringify('---\nname: actual-skill-name\ndescription: Changed during probe.\n---\n')});console.log(JSON.stringify({passed:false}));process.exit(1);`);
|
|
171
|
-
await assert.rejects(runEval(f.base), AgentPreflightFailed);
|
|
172
|
-
assert.equal(f.calls(), 0);
|
|
173
|
-
assert.equal(existsSync(f.base.runsRoot), false);
|
|
174
|
-
});
|
|
175
|
-
test('ordinary and request plans bind the same checks and stale global-readiness plans cannot execute', async (t) => {
|
|
176
|
-
const f = setup(t), request = join(f.root, 'request.json');
|
|
177
|
-
const body = { schemaVersion: 1, baselineSkill: null, candidateSkill: f.skill, bench: f.bench, agent: 'codex', purpose: 'development',
|
|
178
|
-
trials: 1, maxCalls: 2, runsRoot: f.base.runsRoot, runGroup: f.base.runGroup };
|
|
179
|
-
writeFileSync(request, JSON.stringify(body));
|
|
180
|
-
const ordinary = { ...f.base, mode: 'installed', inputMode: 'workspace', skillInstallDir: 'project-skills' };
|
|
181
|
-
const a = await runEvalCli({ ...ordinary, dryRun: true });
|
|
182
|
-
const b = await runEvalComponent(request, { ...f.base, dryRun: true, skillInstallDir: 'project-skills' });
|
|
183
|
-
assert.deepEqual(a.plan.evaluation.agentPreflight, b.plan.evaluation.agentPreflight);
|
|
184
|
-
f.conflict();
|
|
185
|
-
await assert.rejects(runEvalCli(ordinary, a.plan.sha256), /--plan-sha/);
|
|
186
|
-
assert.equal(f.calls(), 0);
|
|
187
|
-
assert.equal(existsSync(f.base.runsRoot), false);
|
|
188
|
-
});
|
|
189
|
-
test('public CLI previews expose blocked readiness and both human/confirmed JSON execution refuse a missing CLI', t => {
|
|
190
|
-
const f = setup(t), env = { ...f.env, PATH: '' }, args = ['eval', f.skill, '--bench', f.bench, '--agent', 'codex', '--trials', '1',
|
|
191
|
-
'--runs-root', f.base.runsRoot, '--run-group', f.base.runGroup, '--json'];
|
|
192
|
-
const preview = spawnSync(process.execPath, [CLI, ...args, '--dry-run'], { env, encoding: 'utf8', timeout: 30_000 });
|
|
193
|
-
assert.equal(preview.status, 0, preview.stderr);
|
|
194
|
-
const plan = JSON.parse(preview.stdout).plan;
|
|
195
|
-
assert.equal(plan.evaluation.agentPreflight.status, 'blocked');
|
|
196
|
-
const live = spawnSync(process.execPath, [CLI, ...args, '--plan-sha', plan.sha256], { env, encoding: 'utf8', timeout: 30_000 });
|
|
197
|
-
assert.equal(live.status, 2);
|
|
198
|
-
assert.equal(JSON.parse(live.stdout).error.code, 'AGENT_PREFLIGHT_FAILED');
|
|
199
|
-
const human = spawnSync(process.execPath, [CLI, ...args.slice(0, -1)], { env, encoding: 'utf8', timeout: 30_000 });
|
|
200
|
-
assert.equal(human.status, 1);
|
|
201
|
-
assert.match(human.stderr, /CLI executable is missing/);
|
|
202
|
-
assert.equal(existsSync(f.base.runsRoot), false);
|
|
203
|
-
const trigger = spawnSync(process.execPath, [CLI, ...args.slice(0, -1), '--mode', 'trigger'], { env, encoding: 'utf8', timeout: 30_000 });
|
|
204
|
-
assert.equal(trigger.status, 1);
|
|
205
|
-
assert.match(trigger.stderr, /CLI executable is missing/);
|
|
206
|
-
assert.equal(existsSync(f.base.runsRoot), false);
|
|
207
|
-
});
|
|
208
|
-
test('a missing judge CLI blocks before spending on the primary injected executor', async (t) => {
|
|
209
|
-
const f = setup(t);
|
|
210
|
-
await assert.rejects(runEval({ ...f.base, judgeExecutor: undefined, judgeAgent: 'claude-code', maxCalls: 4 }), error => {
|
|
211
|
-
assert.ok(error instanceof AgentPreflightFailed);
|
|
212
|
-
assert.equal(error.agentPreflight.checks.find(c => c.role === 'judge' && c.code === 'CLI_AVAILABLE').status, 'FAIL');
|
|
213
|
-
return true;
|
|
214
|
-
});
|
|
215
|
-
assert.equal(f.calls(), 0);
|
|
216
|
-
assert.equal(existsSync(f.base.runsRoot), false);
|
|
217
|
-
});
|
|
218
|
-
test('saved preflight survives changed machine inputs and portable replay without new readiness/auth probes', async (t) => {
|
|
219
|
-
const f = setup(t), preview = await runEvalCli({ ...f.base, dryRun: true });
|
|
220
|
-
const result = await runEvalCli(f.base, preview.plan.sha256);
|
|
221
|
-
assert.ok('agentPreflight' in result);
|
|
222
|
-
assert.ok('costs' in result);
|
|
223
|
-
assert.equal(result.status, 'completed');
|
|
224
|
-
assert.equal(result.evidence.verified, true);
|
|
225
|
-
assert.deepEqual(result.agentPreflight, preview.plan.evaluation.agentPreflight);
|
|
226
|
-
f.conflict();
|
|
227
|
-
rmSync(f.binary);
|
|
228
|
-
rmSync(f.skill, { recursive: true });
|
|
229
|
-
rmSync(f.bench, { recursive: true });
|
|
230
|
-
const run = join(f.base.runsRoot, f.base.runGroup), replay = await reportEvalComponent(run, { replay: true });
|
|
231
|
-
assert.equal(replay.evidence.verified, true);
|
|
232
|
-
assert.deepEqual(replay.agentPreflight, result.agentPreflight);
|
|
233
|
-
const lines = [];
|
|
234
|
-
await runEvalReport(run, line => lines.push(line));
|
|
235
|
-
assert.match(lines.join('\n'), /authentication remains unknown offline/);
|
|
236
|
-
assert.equal(lines.join('\n').includes(f.profile), false);
|
|
237
|
-
const output = join(f.root, 'portable');
|
|
238
|
-
await exportEvaluation(run, output, { yes: true, log: () => { } });
|
|
239
|
-
rmSync(run, { recursive: true });
|
|
240
|
-
const child = spawnSync(process.execPath, [join(output, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000 });
|
|
241
|
-
assert.equal(child.status, 0, child.stderr);
|
|
242
|
-
assert.deepEqual(JSON.parse(child.stdout).agentPreflight, result.agentPreflight);
|
|
243
|
-
assert.deepEqual(JSON.parse(child.stdout).costs, result.costs);
|
|
244
|
-
assert.equal(f.calls(), 2);
|
|
245
|
-
});
|
|
@@ -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
|
-
});
|