skillfit 0.10.0 → 0.11.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.
Files changed (104) hide show
  1. package/README.md +27 -7
  2. package/README.zh-CN.md +27 -7
  3. package/benches/README.md +2 -2
  4. package/dist/cli.js +146 -36
  5. package/dist/cli.test.js +94 -0
  6. package/dist/commands/bench-calibration.js +197 -0
  7. package/dist/commands/bench-calibration.test.js +237 -0
  8. package/dist/commands/bench-check-json.test.js +24 -3
  9. package/dist/commands/bench.js +69 -141
  10. package/dist/commands/calibration-cli.test.js +145 -0
  11. package/dist/commands/eval-agent-preflight.test.js +245 -0
  12. package/dist/commands/eval-cli.js +31 -0
  13. package/dist/commands/eval-component.js +59 -28
  14. package/dist/commands/eval-export-modes.test.js +350 -0
  15. package/dist/commands/eval-export.js +44 -10
  16. package/dist/commands/eval-export.test.js +165 -8
  17. package/dist/commands/eval-interruption.test.js +238 -0
  18. package/dist/commands/eval-plan.js +37 -0
  19. package/dist/commands/eval-preflight.js +61 -0
  20. package/dist/commands/eval-preflight.test.js +382 -0
  21. package/dist/commands/eval-report.js +60 -14
  22. package/dist/commands/eval-report.test.js +2 -2
  23. package/dist/commands/eval-single-arm-replay.js +21 -0
  24. package/dist/commands/eval-single-arm-report.js +223 -0
  25. package/dist/commands/eval.js +184 -112
  26. package/dist/commands/evaluation-report.js +5 -0
  27. package/dist/commands/evaluation-report.test.js +243 -0
  28. package/dist/commands/replay-cancellation.test.js +105 -0
  29. package/dist/commands/workflow-entrypoints.test.js +137 -0
  30. package/dist/harness/agent-preflight.js +180 -0
  31. package/dist/harness/bench.js +2 -1
  32. package/dist/harness/command.js +49 -0
  33. package/dist/harness/eval-audit.js +164 -17
  34. package/dist/harness/eval-budget.js +46 -2
  35. package/dist/harness/eval-budget.test.js +30 -3
  36. package/dist/harness/eval-component.test.js +169 -6
  37. package/dist/harness/eval-contract.js +11 -5
  38. package/dist/harness/executors/api.js +14 -4
  39. package/dist/harness/executors/api.test.js +61 -0
  40. package/dist/harness/executors/cli.js +24 -3
  41. package/dist/harness/experiment-session.js +77 -18
  42. package/dist/harness/experiment-session.test.js +51 -1
  43. package/dist/harness/input-snapshot.js +150 -0
  44. package/dist/harness/interruption.js +48 -0
  45. package/dist/harness/interruption.test.js +31 -0
  46. package/dist/harness/invocation-costs.js +72 -0
  47. package/dist/harness/judge-accounting.test.js +216 -0
  48. package/dist/harness/judge-audit.js +56 -0
  49. package/dist/harness/judge.js +86 -21
  50. package/dist/harness/replay-package.js +71 -5
  51. package/dist/harness/runner.js +92 -44
  52. package/dist/harness/runner.test.js +23 -0
  53. package/dist/harness/single-arm-audit.js +436 -0
  54. package/dist/harness/trigger.js +41 -7
  55. package/dist/harness/trigger.test.js +12 -0
  56. package/dist/harness/verifier-error.js +65 -0
  57. package/dist/harness/verifier.test.js +128 -0
  58. package/docs/bench-authoring.md +34 -9
  59. package/docs/bench-check-json.md +36 -6
  60. package/docs/eval-agent-preflight.md +101 -0
  61. package/docs/eval-case-preflight.md +115 -0
  62. package/docs/eval-component.md +65 -9
  63. package/docs/eval-costs.md +53 -0
  64. package/docs/eval-planning.md +153 -0
  65. package/docs/evaluation-input-snapshots.md +125 -0
  66. package/docs/evaluation-interruption.md +101 -0
  67. package/docs/evaluation-reports.md +143 -0
  68. package/docs/experiment-workflow.md +16 -2
  69. package/docs/first-real-eval.md +55 -5
  70. package/docs/growth-roadmap-2026-10.md +48 -11
  71. package/docs/metrics.md +71 -3
  72. package/docs/plans/2026-10-16-case-workflow-and-release.md +19 -0
  73. package/docs/plans/2026-10-17-workflow-foundations.md +64 -0
  74. package/docs/releases/0.10.0-ci-registry-install.json +140 -0
  75. package/docs/releases/0.10.0-feature-smoke.json +22 -0
  76. package/docs/releases/0.10.0-feature-smoke.mjs +62 -0
  77. package/docs/releases/0.10.0-signatures.txt +7 -0
  78. package/docs/releases/0.10.0-verification.json +76 -0
  79. package/docs/releases/0.10.0.md +44 -8
  80. package/docs/releases/0.10.1-ci-registry-install.json +70 -0
  81. package/docs/releases/0.10.1-feature-smoke.json +28 -0
  82. package/docs/releases/0.10.1-feature-smoke.mjs +95 -0
  83. package/docs/releases/0.10.1-local-registry-install.json +60 -0
  84. package/docs/releases/0.10.1-registry-metadata.json +33 -0
  85. package/docs/releases/0.10.1-signatures.txt +7 -0
  86. package/docs/releases/0.10.1-verification.json +90 -0
  87. package/docs/releases/0.10.1.md +71 -0
  88. package/docs/releases/0.11.0-feature-smoke.mjs +224 -0
  89. package/docs/releases/0.11.0.md +47 -0
  90. package/docs/replay-packages.md +52 -11
  91. package/docs/schemas/agent-preflight.schema.json +31 -0
  92. package/docs/schemas/calibration-plan.schema.json +22 -0
  93. package/docs/schemas/calibration-result.schema.json +17 -0
  94. package/docs/schemas/eval-preflight.schema.json +57 -0
  95. package/docs/schemas/eval-request.schema.json +1 -1
  96. package/docs/schemas/eval-result.schema.json +14 -1
  97. package/docs/schemas/invocation-costs.schema.json +31 -0
  98. package/docs/schemas/judge-call.schema.json +22 -0
  99. package/docs/schemas/single-arm-report.schema.json +20 -0
  100. package/docs/schemas/verifier-error.schema.json +11 -0
  101. package/docs/sharing-results.md +8 -2
  102. package/docs/verifier-contract.md +99 -0
  103. package/package.json +1 -1
  104. package/skills/skillfit/SKILL.md +41 -8
@@ -1,6 +1,6 @@
1
1
  import assert from 'node:assert/strict';
2
2
  import { spawnSync } from 'node:child_process';
3
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
3
+ import { chmodSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
4
4
  import { tmpdir } from 'node:os';
5
5
  import { join } from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
@@ -10,7 +10,8 @@ import { runEval } from './eval.js';
10
10
  import { exportEvaluation } from './eval-export.js';
11
11
  import { reportEvalComponent } from './eval-component.js';
12
12
  import { MockExecutor } from '../harness/executors/mock.js';
13
- import { packageMember, verifyReplayPackage } from '../harness/replay-package.js';
13
+ import { packageFiles, packageMember, verifyReplayPackage } from '../harness/replay-package.js';
14
+ import { sha256File, sha256Text } from '../harness/hash.js';
14
15
  import { loadBench } from '../harness/bench.js';
15
16
  import { collectEvaluationTarget } from '../harness/target.js';
16
17
  import { ExperimentSession } from '../harness/experiment-session.js';
@@ -45,16 +46,21 @@ async function fixture(t, stopped = false) {
45
46
  }
46
47
  test('export previews are read-only and complete packages replay after original paths disappear', async (t) => {
47
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;
48
55
  const plan = await exportEvaluation(f.run, f.output, { log: () => { } });
49
56
  assert.equal(plan.status, 'planned');
50
57
  assert.equal(plan.modelCalls, 0);
51
58
  assert.ok(!existsSync(f.output));
59
+ assert.equal(plan.inputSource, 'sealed-snapshot');
52
60
  await exportEvaluation(f.run, f.output, { yes: true, log: () => { } });
53
61
  assert.equal(readFileSync(join(f.run, '_plan.json'), 'utf8'), originalPlan);
54
62
  const moved = join(f.root, 'received package');
55
63
  renameSync(f.output, moved);
56
- rmSync(f.bench, { recursive: true });
57
- rmSync(f.skill, { recursive: true });
58
64
  rmSync(f.run, { recursive: true });
59
65
  const checksum = spawnSync(process.execPath, [join(moved, 'reproduce.mjs'), '--verify-only'], { encoding: 'utf8' });
60
66
  assert.equal(checksum.status, 0, checksum.stderr);
@@ -64,6 +70,8 @@ test('export previews are read-only and complete packages replay after original
64
70
  const data = JSON.parse(replay.stdout);
65
71
  assert.equal(data.evidence.verified, true);
66
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');
67
75
  const inspected = await reportEvalComponent(moved, { replay: true });
68
76
  assert.ok('portablePackage' in inspected && inspected.portablePackage.integrityVerified);
69
77
  assert.equal(f.calls(), 2);
@@ -71,6 +79,8 @@ test('export previews are read-only and complete packages replay after original
71
79
  test('stopped exports preserve partial costs and cannot become completed evidence', async (t) => {
72
80
  const f = await fixture(t, true), before = await reportEvalComponent(f.run);
73
81
  assert.equal(before.status, 'stopped');
82
+ rmSync(f.bench, { recursive: true });
83
+ rmSync(f.skill, { recursive: true });
74
84
  await exportEvaluation(f.run, f.output, { yes: true, log: () => { } });
75
85
  const replay = spawnSync(process.execPath, [join(f.output, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000 });
76
86
  assert.equal(replay.status, 0, replay.stderr);
@@ -81,15 +91,76 @@ test('stopped exports preserve partial costs and cannot become completed evidenc
81
91
  assert.equal(data.acceptance.eligibleForUpgrade, false);
82
92
  assert.equal(f.calls(), 1);
83
93
  });
84
- test('missing inputs, nested destinations and collisions fail without modifying evidence', async (t) => {
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) => {
85
155
  const f = await fixture(t), original = readFileSync(join(f.run, '_artifacts.json'), 'utf8');
86
156
  await assert.rejects(() => exportEvaluation(f.run, join(f.run, 'bad'), { yes: true, log: () => { } }), /outside/);
87
157
  mkdirSync(f.output);
88
158
  await assert.rejects(() => exportEvaluation(f.run, f.output, { yes: true, log: () => { } }), /already exists/);
89
159
  rmSync(f.output, { recursive: true });
90
160
  writeFileSync(join(f.skill, 'SKILL.md'), 'changed');
91
- await assert.rejects(() => exportEvaluation(f.run, f.output, { yes: true, log: () => { } }), /input changed|unavailable/);
92
- assert.ok(!existsSync(f.output));
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');
93
164
  assert.equal(readFileSync(join(f.run, '_artifacts.json'), 'utf8'), original);
94
165
  });
95
166
  test('portable inspections reject changed files, extra files and unsafe paths', async (t) => {
@@ -102,6 +173,9 @@ test('portable inspections reject changed files, extra files and unsafe paths',
102
173
  rmSync(join(f.output, 'extra'));
103
174
  writeFileSync(join(f.output, 'run/manifest.json'), '{}');
104
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/);
105
179
  const verify = spawnSync(process.execPath, [join(f.output, 'reproduce.mjs'), '--verify-only'], { encoding: 'utf8' });
106
180
  assert.equal(verify.status, 2);
107
181
  assert.equal(f.calls(), 2);
@@ -109,7 +183,7 @@ test('portable inspections reject changed files, extra files and unsafe paths',
109
183
  test('restored input roots still require original fingerprints and CLI exports are plans by default', async (t) => {
110
184
  const f = await fixture(t), restored = join(f.root, 'restored-skill');
111
185
  renameSync(f.skill, restored);
112
- await assert.rejects(() => exportEvaluation(f.run, f.output, { log: () => { } }));
186
+ assert.equal((await exportEvaluation(f.run, f.output, { log: () => { } })).status, 'planned');
113
187
  const cli = fileURLToPath(new URL('../cli.js', import.meta.url));
114
188
  const result = spawnSync(process.execPath, [cli, 'report', 'eval', f.run, '--export', f.output,
115
189
  '--input-root', `target=${restored}`, '--json'], { encoding: 'utf8' });
@@ -120,3 +194,86 @@ test('restored input roots still require original fingerprints and CLI exports a
120
194
  assert.equal(verifyReplayPackage(f.output).hasManifest, true);
121
195
  assert.equal(f.calls(), 2);
122
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
+ });
@@ -0,0 +1,238 @@
1
+ import assert from 'node:assert/strict';
2
+ import { spawn, spawnSync } from 'node:child_process';
3
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
4
+ import { tmpdir } from 'node:os';
5
+ import { join } from 'node:path';
6
+ import { fileURLToPath, pathToFileURL } from 'node:url';
7
+ import { test } from 'node:test';
8
+ import { runBenchInit } from './bench.js';
9
+ import { reportEvalComponent } from './eval-component.js';
10
+ import { exportEvaluation } from './eval-export.js';
11
+ import { sha256File } from '../harness/hash.js';
12
+ import { killTree } from '../harness/kill-tree.js';
13
+ const dist = fileURLToPath(new URL('..', import.meta.url));
14
+ const moduleUrl = (path) => JSON.stringify(pathToFileURL(join(dist, path)).href);
15
+ const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
16
+ const json = (path) => JSON.parse(readFileSync(path, 'utf8'));
17
+ function running(pid) {
18
+ try {
19
+ process.kill(pid, 0);
20
+ // An orphan reaped late by a Linux container's init is dead, despite kill(pid, 0).
21
+ if (process.platform === 'linux' && readFileSync(`/proc/${pid}/stat`, 'utf8').split(')').at(-1).trim().startsWith('Z'))
22
+ return false;
23
+ return true;
24
+ }
25
+ catch {
26
+ return false;
27
+ }
28
+ }
29
+ async function scenario(t, mode, signal = 'SIGINT') {
30
+ const root = mkdtempSync(join(tmpdir(), 'skillfit-interrupt-'));
31
+ let child;
32
+ t.after(async () => {
33
+ if (child?.exitCode === null && child.signalCode === null)
34
+ killTree(child);
35
+ if (existsSync(join(root, 'ready.json')))
36
+ for (const pid of json(join(root, 'ready.json')).pids) {
37
+ if (running(pid))
38
+ try {
39
+ process.kill(pid, 'SIGKILL');
40
+ }
41
+ catch { /* already gone */ }
42
+ }
43
+ await delay(100);
44
+ rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
45
+ });
46
+ const bench = join(root, 'bench'), skill = join(root, 'skill'), old = join(root, 'old');
47
+ await runBenchInit({ dir: bench, yes: true, log: () => { } });
48
+ for (const [dir, version] of [[skill, 'new'], [old, 'old']]) {
49
+ mkdirSync(dir);
50
+ writeFileSync(join(dir, 'SKILL.md'), `---\nname: interrupt-skill\ndescription: Synthetic offline interruption test.\n---\n${version}\n`);
51
+ }
52
+ const raw = json(join(bench, 'bench.json'));
53
+ raw.tasks[0].shouldTrigger = true;
54
+ const leaf = join(root, 'leaf.mjs'), heartbeat = join(root, 'heartbeat'), ready = join(root, 'ready.json');
55
+ writeFileSync(leaf, `import{appendFileSync}from'node:fs';process.on('SIGINT',()=>{});process.on('SIGTERM',()=>{});setInterval(()=>appendFileSync(${JSON.stringify(heartbeat)},'x'),30);setTimeout(()=>process.exit(),30000);`);
56
+ const fakeSource = `import{spawn}from'node:child_process';import{existsSync,writeFileSync}from'node:fs';
57
+ process.stdin.resume();process.on('SIGINT',()=>{});process.on('SIGTERM',()=>{});
58
+ process.stdout.write(${JSON.stringify([
59
+ JSON.stringify({ type: 'item.completed', item: { type: 'agent_message', text: 'retained partial output' } }),
60
+ JSON.stringify({ type: 'turn.completed', usage: { input_tokens: 12, cached_input_tokens: 7, output_tokens: 3 } }),
61
+ ].join('\n') + '\n')});
62
+ const leaf=spawn(process.execPath,[${JSON.stringify(leaf)}],{stdio:'ignore'});
63
+ const timer=setInterval(()=>{if(existsSync(${JSON.stringify(heartbeat)})){clearInterval(timer);writeFileSync(${JSON.stringify(ready)},JSON.stringify({pids:[process.pid,leaf.pid]}));}},20);
64
+ setTimeout(()=>process.exit(),30000);`;
65
+ const fake = join(root, 'fake.mjs');
66
+ writeFileSync(fake, fakeSource);
67
+ if (mode === 'verifier' || mode === 'preflight') {
68
+ writeFileSync(join(bench, 'verifiers/live-block.mjs'), fakeSource);
69
+ // Only the post-agent verifier blocks in the verifier scenario. Preflight
70
+ // still exercises the real missing/empty/oracle gates of the starter.
71
+ writeFileSync(join(bench, 'verifiers/block.mjs'), mode === 'preflight' ? fakeSource :
72
+ "import{existsSync}from'node:fs';import{join}from'node:path';await import(existsSync(join(process.argv[2],'_prompt.txt'))?'./live-block.mjs':'./example-task.mjs');");
73
+ raw.tasks[0].verifier = 'node verifiers/block.mjs';
74
+ }
75
+ writeFileSync(join(bench, 'bench.json'), JSON.stringify(raw));
76
+ const request = join(root, 'request.json');
77
+ writeFileSync(request, JSON.stringify({ schemaVersion: 1, baselineSkill: old, candidateSkill: skill,
78
+ bench, agent: 'codex', purpose: 'development', trials: 2, maxCalls: 4, runsRoot: join(root, 'runs'), runGroup: 'saved' }));
79
+ const harness = join(root, 'harness.mjs');
80
+ writeFileSync(harness, `import{writeFileSync}from'node:fs';
81
+ import{runEval}from ${moduleUrl('commands/eval.js')};
82
+ import{runBenchCheck}from ${moduleUrl('commands/bench.js')};
83
+ import{runEvalComponent}from ${moduleUrl('commands/eval-component.js')};
84
+ import{CliExecutor}from ${moduleUrl('harness/executors/cli.js')};
85
+ import{ApiExecutor}from ${moduleUrl('harness/executors/api.js')};
86
+ const mode=${JSON.stringify(mode)}, root=${JSON.stringify(root)};
87
+ const counts=()=>[process.listenerCount('SIGINT'),process.listenerCount('SIGTERM')],before=counts();
88
+ process.on('message',message=>{process.emit(message.signal);if(message.repeat){process.emit(message.signal);process.emit('SIGTERM');}});
89
+ const fake=new CliExecutor({argv:[process.execPath,${JSON.stringify(fake)}],shell:false,triggerSkillName:'interrupt-skill',timeoutMs:20000});
90
+ let calls=0;const mock={describe:()=>({kind:'mock',model:'offline'}),run:async()=>{calls++;return{output:'offline answer',tokens:{input:20,cachedInput:5,output:4}}}};
91
+ const api=new ApiExecutor({apiKey:'offline-only',fetchImpl:async(_url,options)=>{writeFileSync(${JSON.stringify(ready)},JSON.stringify({pids:[]}));return await new Promise((_,reject)=>options.signal.addEventListener('abort',()=>{writeFileSync(root+'/api-aborted','yes');reject(options.signal.reason);},{once:true}));}});
92
+ const base={skillPath:${JSON.stringify(skill)},bench:${JSON.stringify(bench)},trials:2,maxCalls:4,executor:mode==='verifier'||mode==='preflight'||mode==='judge'||mode==='between'?mock:mode==='api'?api:fake,judgeExecutor:mode==='judge'?fake:null,yes:true,dryRun:false,runsRoot:root+'/runs',runGroup:'saved',log:message=>{if(mode==='between'&&message.includes('/ treatment / trial 1'))process.emit('SIGINT');}};
93
+ try{
94
+ if(mode==='request'){const options={executor:fake,skillInstallDir:'skills',dryRun:true};const preview=await runEvalComponent(${JSON.stringify(request)},options);const result=await runEvalComponent(${JSON.stringify(request)},{...options,dryRun:false,expectedPlanSha256:preview.plan.sha256});writeFileSync(root+'/component.json',JSON.stringify(result));}
95
+ else if(mode==='calibration')await runBenchCheck({dir:base.bench,log:()=>{},calibrate:{executor:fake,trials:2,maxCalls:2,runsRoot:base.runsRoot,runGroup:base.runGroup}});
96
+ else await runEval({...base,...(mode==='trigger'?{mode:'trigger',skillInstallDir:'skills'}:{}),...(mode==='judge'?{maxCalls:8}:{})});
97
+ }catch(error){writeFileSync(root+'/error.txt',error.message);}
98
+ finally{writeFileSync(root+'/done.json',JSON.stringify({before,after:counts(),calls,exitCode:process.exitCode}));process.disconnect();}
99
+ `);
100
+ child = spawn(process.execPath, [harness], { stdio: ['ignore', 'pipe', 'pipe', 'ipc'] });
101
+ let stderr = '';
102
+ child.stdout.resume();
103
+ child.stderr.on('data', chunk => { stderr += chunk; });
104
+ const closed = new Promise(resolve => child.on('exit', (code, signal) => resolve({ code, signal })));
105
+ if (mode !== 'between') {
106
+ for (let i = 0; i < 300 && !existsSync(ready) && child.exitCode === null; i++)
107
+ await delay(50);
108
+ assert.ok(existsSync(ready), `Fake process did not start: ${stderr}`);
109
+ await delay(100);
110
+ // Windows kill('SIGINT') forcibly terminates rather than delivering a console
111
+ // control event. Emit that event in the isolated harness; taskkill /T remains real.
112
+ if (process.platform === 'win32' || mode === 'request')
113
+ child.send({ signal, repeat: mode === 'request' });
114
+ else
115
+ child.kill(signal);
116
+ }
117
+ let timer;
118
+ const exit = await Promise.race([closed, new Promise((_, reject) => { timer = setTimeout(() => reject(new Error(`Interrupted evaluation did not exit: ${stderr}`)), 10_000); })]).finally(() => clearTimeout(timer));
119
+ assert.deepEqual(exit, { code: signal === 'SIGINT' ? 130 : 143, signal: null }, stderr);
120
+ const run = join(root, 'runs/saved'), done = json(join(root, 'done.json'));
121
+ assert.deepEqual(done.after, done.before, 'signal handlers must be removed after sealing');
122
+ if (mode === 'preflight') {
123
+ assert.equal(done.calls, 0);
124
+ assert.ok(!existsSync(run));
125
+ assert.match(readFileSync(join(root, 'error.txt'), 'utf8'), new RegExp(signal));
126
+ for (let i = 0; i < 100 && json(ready).pids.some(running); i++)
127
+ await delay(50);
128
+ assert.ok(json(ready).pids.every((pid) => !running(pid)), 'preflight verifier and grandchild must stop');
129
+ return { root, run, done, session: null, events: [], stderr };
130
+ }
131
+ const session = json(join(run, '_session.json'));
132
+ assert.equal(session.status, 'stopped');
133
+ assert.match(session.stopReason, new RegExp(signal));
134
+ const interruption = json(join(run, '_interruption.json'));
135
+ assert.equal(interruption.signal, signal);
136
+ assert.equal(interruption.automaticRetry, false);
137
+ const index = json(join(run, '_artifacts.json'));
138
+ for (const [path, sha] of Object.entries(index.files))
139
+ assert.equal(sha256File(join(run, path)), sha, path);
140
+ assert.ok(!existsSync(join(run, 'manifest.json')), 'an interrupted prefix must not publish a completed quality verdict');
141
+ const events = readFileSync(join(run, '_calls.jsonl'), 'utf8').trim().split('\n').map(line => JSON.parse(line));
142
+ assert.equal(events.filter(event => event.event === 'started').length, mode === 'judge' ? 5 : 1, 'no automatic retry, partner or extra trial');
143
+ if (mode !== 'between') {
144
+ for (let i = 0; i < 100 && json(ready).pids.some(running); i++)
145
+ await delay(50);
146
+ assert.ok(json(ready).pids.every((pid) => !running(pid)), 'fake CLI and grandchild must both stop');
147
+ if (existsSync(heartbeat)) {
148
+ const before = readFileSync(heartbeat, 'utf8');
149
+ await delay(100);
150
+ assert.equal(readFileSync(heartbeat, 'utf8'), before);
151
+ }
152
+ }
153
+ return { root, run, done, session, events, stderr };
154
+ }
155
+ for (const signal of ['SIGINT', 'SIGTERM'])
156
+ test(`${signal} stops the CLI process tree, retains partial usage and seals stopped records`, { timeout: 30_000 }, async (t) => {
157
+ const f = await scenario(t, 'paired', signal), record = json(join(f.run, 'example-task/baseline/trial-1/_result.json'));
158
+ assert.equal(record.executorInvoked, true);
159
+ assert.equal(record.usageStatus, 'partial');
160
+ assert.equal(record.verifierExitCode, null);
161
+ assert.deepEqual(record.tokens, { input: 12, cachedInput: 7, output: 3 });
162
+ assert.match(readFileSync(join(f.run, 'example-task/baseline/trial-1/_output.md'), 'utf8'), /retained partial output/);
163
+ const report = await reportEvalComponent(f.run);
164
+ assert.equal(report.status, 'stopped');
165
+ assert.equal(report.acceptance.eligibleForUpgrade, false);
166
+ assert.ok('costs' in report && 'startedAgentDispatches' in report.costs && report.costs.startedAgentDispatches === 1);
167
+ if (signal === 'SIGINT') {
168
+ const output = join(f.root, 'export');
169
+ await exportEvaluation(f.run, output, { yes: true, log: () => { } });
170
+ const replay = spawnSync(process.execPath, [join(output, 'reproduce.mjs')], { encoding: 'utf8', timeout: 20_000 });
171
+ assert.equal(replay.status, 0, replay.stderr);
172
+ const saved = JSON.parse(replay.stdout);
173
+ assert.equal(saved.status, 'stopped');
174
+ assert.equal(saved.acceptance.eligibleForUpgrade, false);
175
+ assert.deepEqual(saved.costs, report.costs, 'sealed interruption costs must reproduce unchanged');
176
+ }
177
+ });
178
+ for (const signal of ['SIGINT', 'SIGTERM'])
179
+ test(`${signal} cancels offline preflight without dispatch or a misleading completed run`, { timeout: 30_000 }, async (t) => {
180
+ await scenario(t, 'preflight', signal);
181
+ });
182
+ test('interrupting a verifier kills its tree and preserves final agent usage', { timeout: 30_000 }, async (t) => {
183
+ const f = await scenario(t, 'verifier'), record = json(join(f.run, 'example-task/baseline/trial-1/_result.json'));
184
+ assert.deepEqual(record.tokens, { input: 20, cachedInput: 5, output: 4 });
185
+ assert.equal(record.usageStatus, 'final');
186
+ assert.match(record.error, /SIGINT/);
187
+ assert.equal(record.passed, false);
188
+ });
189
+ test('repeated interrupts keep a request stopped and never launch its partner', { timeout: 30_000 }, async (t) => {
190
+ const f = await scenario(t, 'request'), result = json(join(f.root, 'component.json'));
191
+ assert.equal(result.status, 'stopped');
192
+ assert.equal(result.acceptance.eligibleForUpgrade, false);
193
+ assert.equal(result.acceptance.automaticUpgrade, false);
194
+ });
195
+ test('trigger and calibration evaluations also seal an interrupted prefix', { timeout: 60_000 }, async (t) => {
196
+ for (const mode of ['trigger', 'calibration']) {
197
+ const f = await scenario(t, mode);
198
+ const arm = mode === 'trigger' ? 'installed' : 'baseline';
199
+ const record = json(join(f.run, `example-task/${arm}/trial-1/_result.json`));
200
+ assert.deepEqual(record.tokens, { input: 12, cachedInput: 7, output: 3 });
201
+ assert.equal(record.usageStatus, 'partial');
202
+ assert.match(record.error, /SIGINT/);
203
+ }
204
+ });
205
+ test('an interrupted judge keeps available output and does not run the reverse-order call', { timeout: 30_000 }, async (t) => {
206
+ const f = await scenario(t, 'judge');
207
+ const saved = json(join(f.run, '_interrupted-judge-5.json'));
208
+ assert.match(saved.result.output, /retained partial output/);
209
+ assert.equal(saved.result.usageStatus, 'partial');
210
+ assert.deepEqual(saved.result.tokens, { input: 12, cachedInput: 7, output: 3 });
211
+ });
212
+ test('API interruption aborts the injected fetch and leaves unavailable usage unknown', { timeout: 30_000 }, async (t) => {
213
+ const f = await scenario(t, 'api'), record = json(join(f.run, 'example-task/baseline/trial-1/_result.json'));
214
+ assert.equal(readFileSync(join(f.root, 'api-aborted'), 'utf8'), 'yes');
215
+ assert.equal(record.tokens, null);
216
+ assert.equal(record.usageStatus, 'unknown');
217
+ assert.match(record.error, /SIGINT/);
218
+ });
219
+ test('interrupting between calls preserves the settled receipt without dispatching another call', { timeout: 30_000 }, async (t) => {
220
+ const f = await scenario(t, 'between');
221
+ assert.equal(f.done.calls, 1);
222
+ assert.ok(!existsSync(join(f.run, 'example-task/treatment/trial-1')));
223
+ assert.deepEqual(json(join(f.run, 'example-task/baseline/trial-1/_result.json')).tokens, { input: 20, cachedInput: 5, output: 4 });
224
+ });
225
+ test('CLI plain and JSON errors preserve the interruption exit code instead of replacing it with 1 or 2', () => {
226
+ for (const signal of ['SIGINT', 'SIGTERM'])
227
+ for (const machine of [false, true]) {
228
+ const args = machine ? ['eval', '--request', 'missing-offline-request.json', '--dry-run']
229
+ : ['eval', 'missing-offline-skill', '--bench', 'missing-offline-bench', '--dry-run'];
230
+ const script = `import{withEvaluationInterrupts}from ${moduleUrl('harness/interruption.js')};
231
+ try{await withEvaluationInterrupts(async()=>{process.emit(${JSON.stringify(signal)});});}catch{}
232
+ process.argv=[process.execPath,${JSON.stringify(join(dist, 'cli.js'))},...${JSON.stringify(args)}];await import(${moduleUrl('cli.js')});`;
233
+ const result = spawnSync(process.execPath, ['--input-type=module', '-e', script], { encoding: 'utf8', timeout: 10_000 });
234
+ assert.equal(result.status, signal === 'SIGINT' ? 130 : 143, result.stderr);
235
+ if (machine)
236
+ assert.equal(JSON.parse(result.stdout).kind, 'skillfit.eval-error');
237
+ }
238
+ });
@@ -0,0 +1,37 @@
1
+ import { basename, dirname } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { existsSync } from 'node:fs';
4
+ import { hashFileSet, listFilesRecursive, sha256Text } from '../harness/hash.js';
5
+ import { runEval } from './eval.js';
6
+ /** Shared read-only planning and confirmation for command-line and file requests. */
7
+ export async function prepareEvalPlan(options, context) {
8
+ const implementationDir = fileURLToPath(new URL('../../dist', import.meta.url));
9
+ const implementationSha256 = hashFileSet(implementationDir, listFilesRecursive(implementationDir));
10
+ const lines = [];
11
+ let evaluation;
12
+ await runEval({ ...options, dryRun: true, log: line => lines.push(line), onPlan: preview => { evaluation = preview; } });
13
+ if (!evaluation)
14
+ throw new Error('No paired evaluation plan is available.');
15
+ if (existsSync(evaluation.outputDir))
16
+ throw new Error('Run group already exists; declare a fresh group without overwriting evidence.');
17
+ const describe = (preview) => ({ schemaVersion: 1, kind: 'skillfit.eval-plan',
18
+ ...context, implementationSha256, evaluation: preview });
19
+ const data = describe(evaluation), sha256 = sha256Text(JSON.stringify(data));
20
+ const plan = { ...data, sha256 };
21
+ const resolved = { ...options, runsRoot: dirname(evaluation.outputDir), runGroup: basename(evaluation.outputDir) };
22
+ return { plan, lines, options: resolved,
23
+ assertCurrent: (preview) => {
24
+ if (sha256Text(JSON.stringify(describe(preview))) !== sha256)
25
+ throw new Error('Plan changed before execution; no calls allowed.');
26
+ } };
27
+ }
28
+ export function confirmEvalPlan(expected, actual) {
29
+ if (!expected || !/^[0-9a-f]{64}$/i.test(expected) || expected.toLowerCase() !== actual) {
30
+ throw new Error('Execution requires --plan-sha matching the current dry-run plan; inputs, policy, executor or implementation changed.');
31
+ }
32
+ }
33
+ export function plannedEvalResult(plan) {
34
+ return { schemaVersion: 1, kind: 'skillfit.eval-result', status: 'planned', plan,
35
+ acceptance: { decision: 'inconclusive', eligibleForUpgrade: false, automaticUpgrade: false,
36
+ reasons: [{ code: 'PLAN_ONLY', message: 'No agent call or outcome is available.' }] } };
37
+ }
@@ -0,0 +1,61 @@
1
+ import { loadBench } from '../harness/bench.js';
2
+ import { collectInstalledSkillTarget } from '../harness/installed-skill.js';
3
+ import { throwIfEvaluationInterrupted } from '../harness/interruption.js';
4
+ import { collectEvaluationTarget } from '../harness/target.js';
5
+ import { runBenchCheck } from './bench.js';
6
+ export const CASE_PREFLIGHT_POLICY = { schemaVersion: 1, scope: 'offline-case-integrity', required: true };
7
+ export class CasePreflightFailed extends Error {
8
+ preflight;
9
+ constructor(preflight) {
10
+ super('Offline case preflight blocked evaluation; no agent or judge calls were made.\n' +
11
+ preflight.checks.filter(c => c.status === 'FAIL').map(c => `[FAIL] ${c.code}${c.taskId ? ` (${c.taskId})` : ''}: ${c.message}${c.remediation ? ` Remedy: ${c.remediation}` : ''}`).join('\n'));
12
+ this.preflight = preflight;
13
+ this.name = 'CasePreflightFailed';
14
+ }
15
+ }
16
+ function globalCheck(code, status, message) {
17
+ return { code, status, message, taskId: null, location: { path: 'bench.json', field: null },
18
+ remediation: status === 'FAIL' ? 'Fix the inputs or check error and run a fresh preview before executing.' : null, evidence: null };
19
+ }
20
+ /** Runs only trusted local bench commands in disposable directories; never an executor. */
21
+ export async function checkEvalCases(bench, targets, installed, log) {
22
+ const started = performance.now();
23
+ let checks;
24
+ try {
25
+ const result = await runBenchCheck({ dir: bench.dir, taskIds: bench.tasks.map(t => t.id), calibrate: false, log: () => { } });
26
+ checks = result.checks.map(check => {
27
+ const unknown = (check.code === 'ORACLE' && check.status === 'WARN') ||
28
+ ((check.code === 'MOCK_BASELINE' || check.code === 'MOCK_TREATMENT') && check.status === 'INFO' && check.evidence === null) ||
29
+ (check.code === 'MOCK_COVERAGE' && check.status === 'INFO' &&
30
+ bench.tasks.some(t => t.id === check.taskId && (t.verifierKind ?? 'output') === 'output'));
31
+ return { ...check, status: unknown ? 'UNKNOWN' : check.status };
32
+ });
33
+ }
34
+ catch (error) {
35
+ throwIfEvaluationInterrupted();
36
+ checks = [globalCheck('CHECK_ERROR', 'FAIL', error instanceof Error ? error.message : String(error))];
37
+ }
38
+ throwIfEvaluationInterrupted();
39
+ // Verifiers are executable local code. Never freeze inputs mutated during a probe
40
+ // as if those were the inputs approved in the preview.
41
+ try {
42
+ if (loadBench(bench.dir).contentSha256 !== bench.contentSha256 || targets.some(target => (installed ? collectInstalledSkillTarget(target.sourceDir) : collectEvaluationTarget(target.sourceDir)).sha256 !== target.sha256)) {
43
+ checks.push(globalCheck('INPUT_CHANGED', 'FAIL', 'Bench or target content changed during offline preflight.'));
44
+ }
45
+ }
46
+ catch (error) {
47
+ checks.push(globalCheck('INPUT_CHANGED', 'FAIL', `Inputs became unreadable during offline preflight: ${String(error)}`));
48
+ }
49
+ checks.push(globalCheck('LIVE_DIFFICULTY', 'UNKNOWN', 'Offline probes do not measure live agent difficulty, Skill benefit, or generalization. No calibration or model call was performed.'));
50
+ const count = (status) => checks.filter(c => c.status === status).length;
51
+ const report = { schemaVersion: 1, kind: 'skillfit.eval-preflight', scope: 'offline-case-integrity',
52
+ status: count('FAIL') ? 'blocked' : 'ready', bench: { dir: bench.dir, sha256: bench.contentSha256, taskIds: bench.tasks.map(t => t.id) },
53
+ checks, summary: { failures: count('FAIL'), warnings: count('WARN'), unknown: count('UNKNOWN'), passed: count('PASS'), info: count('INFO') },
54
+ cost: { modelCalls: 0, durationMs: Math.round(performance.now() - started) } };
55
+ log(`Case preflight: ${report.status}; ${report.summary.failures} failure(s), ${report.summary.warnings} warning(s), ${report.summary.unknown} unknown(s); ${report.cost.durationMs}ms offline, 0 model calls`);
56
+ for (const c of checks.filter(c => c.status !== 'PASS' && c.status !== 'INFO'))
57
+ log(`[${c.status}] ${c.code}: ${c.message}`);
58
+ if (report.status === 'blocked')
59
+ throw new CasePreflightFailed(report);
60
+ return report;
61
+ }