skillfit 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +60 -119
  2. package/README.zh-CN.md +60 -116
  3. package/dist/commands/bench-check-report.js +1 -34
  4. package/dist/commands/bench.js +6 -239
  5. package/dist/commands/eval-preflight-error.js +9 -0
  6. package/dist/commands/eval-preflight.js +4 -11
  7. package/dist/commands/eval-report.js +6 -459
  8. package/dist/commands/install.js +14 -98
  9. package/dist/harness/bench-check.js +277 -0
  10. package/dist/harness/bench-diagnostics.js +34 -0
  11. package/dist/harness/eval-acceptance.js +1 -1
  12. package/dist/harness/eval-audit.js +1 -1
  13. package/dist/harness/eval-manifest.js +456 -0
  14. package/dist/install/constants.js +1 -0
  15. package/dist/install/transaction.js +112 -0
  16. package/docs/README.md +65 -0
  17. package/docs/architecture.md +86 -0
  18. package/docs/archive-delivery.md +83 -0
  19. package/docs/archive-inventory.md +91 -0
  20. package/docs/evaluation-reports.md +1 -1
  21. package/docs/growth-roadmap-2026-10.md +14 -18
  22. package/docs/package-contents.md +73 -0
  23. package/docs/plans/2026-10-20-archive-replay-verification.json +125 -0
  24. package/docs/plans/2026-10-20-archive-source-verification.json +256 -0
  25. package/docs/plans/2026-10-20-delivery-verification.json +146 -0
  26. package/docs/plans/2026-10-20-docs-architecture-cleanup.md +233 -0
  27. package/docs/plans/2026-10-20-install-transactions-and-archive-delivery.md +233 -0
  28. package/docs/plans/2026-10-21-npm-0.13.0-release.md +41 -0
  29. package/docs/releases/0.12.0-attestation-check.json +22 -0
  30. package/docs/releases/0.12.0-attestations.json +155 -0
  31. package/docs/releases/0.12.0-ci-registry-install.json +90 -0
  32. package/docs/releases/0.12.0-feature-smoke.json +34 -0
  33. package/docs/releases/0.12.0-foundations-smoke.json +1576 -0
  34. package/docs/releases/0.12.0-local-registry-install.json +75 -0
  35. package/docs/releases/0.12.0-preparation-attempt-1.json +22 -0
  36. package/docs/releases/0.12.0-registry-metadata.json +96 -0
  37. package/docs/releases/0.12.0-signatures.txt +6 -0
  38. package/docs/releases/0.12.0-verification.json +99 -0
  39. package/docs/releases/0.12.0.md +14 -0
  40. package/docs/releases/0.13.0-feature-smoke.mjs +114 -0
  41. package/docs/releases/0.13.0-preparation.json +102 -0
  42. package/docs/releases/0.13.0.md +61 -0
  43. package/docs/releases/archive-delivery-smoke.mjs +37 -0
  44. package/docs/reproducible-offline-example.md +1 -1
  45. package/evidence/README.md +24 -1
  46. package/evidence/archive-catalog.v1.json +8044 -0
  47. package/evidence/fetch-archives.mjs +211 -0
  48. package/package.json +9 -2
  49. package/dist/cli.test.js +0 -193
  50. package/dist/commands/bench-calibration.test.js +0 -237
  51. package/dist/commands/bench-check-json.test.js +0 -242
  52. package/dist/commands/bench-manage.test.js +0 -87
  53. package/dist/commands/bench.test.js +0 -1166
  54. package/dist/commands/bundle.test.js +0 -142
  55. package/dist/commands/calibration-cli.test.js +0 -145
  56. package/dist/commands/doctor.test.js +0 -280
  57. package/dist/commands/eval-agent-preflight.test.js +0 -269
  58. package/dist/commands/eval-cli-usage.test.js +0 -75
  59. package/dist/commands/eval-export-modes.test.js +0 -350
  60. package/dist/commands/eval-export.test.js +0 -279
  61. package/dist/commands/eval-interruption.test.js +0 -263
  62. package/dist/commands/eval-preflight.test.js +0 -382
  63. package/dist/commands/eval-report.test.js +0 -367
  64. package/dist/commands/eval.test.js +0 -503
  65. package/dist/commands/evaluation-report.test.js +0 -243
  66. package/dist/commands/install.test.js +0 -555
  67. package/dist/commands/npm-first-run.test.js +0 -74
  68. package/dist/commands/replay-cancellation.test.js +0 -105
  69. package/dist/commands/report.test.js +0 -110
  70. package/dist/commands/setup.test.js +0 -150
  71. package/dist/commands/upstream.test.js +0 -139
  72. package/dist/commands/workflow-entrypoints.test.js +0 -137
  73. package/dist/docs.test.js +0 -154
  74. package/dist/frontmatter.test.js +0 -49
  75. package/dist/harness/bench.test.js +0 -109
  76. package/dist/harness/bundle.test.js +0 -71
  77. package/dist/harness/codex-usage.test.js +0 -87
  78. package/dist/harness/costs.test.js +0 -92
  79. package/dist/harness/eval-budget.test.js +0 -237
  80. package/dist/harness/eval-component.test.js +0 -770
  81. package/dist/harness/eval-efficiency.test.js +0 -56
  82. package/dist/harness/execution-timing.test.js +0 -61
  83. package/dist/harness/executors/api.test.js +0 -175
  84. package/dist/harness/executors/cli.test.js +0 -541
  85. package/dist/harness/executors/mock.test.js +0 -43
  86. package/dist/harness/experiment-session.test.js +0 -317
  87. package/dist/harness/installed-skill.test.js +0 -162
  88. package/dist/harness/interruption.test.js +0 -31
  89. package/dist/harness/judge-accounting.test.js +0 -216
  90. package/dist/harness/judge.test.js +0 -181
  91. package/dist/harness/kimi-usage.test.js +0 -62
  92. package/dist/harness/native-diff.test.js +0 -53
  93. package/dist/harness/oss-lru-cache.test.js +0 -79
  94. package/dist/harness/oss-normalize-url.test.js +0 -64
  95. package/dist/harness/oss-regression-witness.test.js +0 -89
  96. package/dist/harness/oss-skill-followup.test.js +0 -59
  97. package/dist/harness/prompt.test.js +0 -48
  98. package/dist/harness/receipts.test.js +0 -148
  99. package/dist/harness/report.test.js +0 -297
  100. package/dist/harness/runner.test.js +0 -635
  101. package/dist/harness/skill-revision.test.js +0 -148
  102. package/dist/harness/stats.test.js +0 -124
  103. package/dist/harness/target.test.js +0 -60
  104. package/dist/harness/trigger.test.js +0 -261
  105. package/dist/harness/verifier-summary.test.js +0 -99
  106. package/dist/harness/verifier.test.js +0 -128
  107. package/dist/harness/waza-behavior.test.js +0 -139
  108. package/dist/mcp/probe.test.js +0 -139
  109. package/evidence/artifacts/2026-10-12-diagnosing-revision/calibration-records.tar.gz +0 -0
  110. package/evidence/artifacts/2026-10-12-diagnosing-revision/interrupted-records.tar.gz +0 -0
  111. package/evidence/artifacts/2026-10-12-diagnosing-revision/validation-records.tar.gz +0 -0
  112. package/evidence/artifacts/2026-10-12-diagnosing-v2/regression-records.tar.gz +0 -0
  113. package/evidence/artifacts/2026-10-12-diagnosing-v2/transfer-records.tar.gz +0 -0
  114. package/evidence/artifacts/2026-10-12-normalize-url-v2-available/readiness-records.tar.gz +0 -0
  115. package/evidence/artifacts/2026-10-12-normalize-url-v2-comparison/records.tar.gz +0 -0
  116. package/evidence/artifacts/2026-10-12-normalize-url-v2-recovery/records.tar.gz +0 -0
  117. package/evidence/artifacts/2026-10-12-normalize-url-v2-validated/records.tar.gz +0 -0
  118. package/evidence/artifacts/2026-10-13-debugging-completed-development/package.tar.gz +0 -0
  119. package/evidence/artifacts/2026-10-13-debugging-controls-and-sleep-stop/package.tar.gz +0 -0
  120. package/evidence/artifacts/2026-10-13-debugging-development-stops/package.tar.gz +0 -0
  121. package/evidence/artifacts/2026-10-14-debugging-followup-routing-stop/package.tar.gz +0 -0
  122. package/evidence/artifacts/2026-10-14-debugging-independent-validation/package.tar.gz +0 -0
  123. package/evidence/artifacts/2026-10-14-debugging-reading-pilot-and-cost-review/package.tar.gz +0 -0
  124. package/evidence/artifacts/2026-10-14-debugging-spending-stop/package.tar.gz +0 -0
  125. package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
  126. package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
  127. package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/package.tar.gz +0 -0
@@ -1,635 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { cpSync, existsSync, mkdtempSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
3
- import { tmpdir } from 'node:os';
4
- import { join } from 'node:path';
5
- import { fileURLToPath } from 'node:url';
6
- import { test } from 'node:test';
7
- import { loadBench } from './bench.js';
8
- import { collectSkillBundle } from './bundle.js';
9
- import { MockExecutor } from './executors/mock.js';
10
- import { gitInit, runExperiment, runTrial } from './runner.js';
11
- import { ExecutorFailure } from './types.js';
12
- import { parseEvalReport, renderEvalMarkdown } from '../commands/eval-report.js';
13
- const PACKAGE_ROOT = fileURLToPath(new URL('../..', import.meta.url));
14
- const BUNDLED_CODE_REVIEW = join(PACKAGE_ROOT, 'benches', 'code-review');
15
- function tmp(t, prefix) {
16
- const dir = mkdtempSync(join(tmpdir(), prefix));
17
- t.after(() => rmSync(dir, { recursive: true, force: true }));
18
- return dir;
19
- }
20
- function makeSkill(t) {
21
- const dir = tmp(t, 'skillfit-skill-');
22
- writeFileSync(join(dir, 'SKILL.md'), '# review discipline\ncheck boundaries and error codes\n');
23
- return dir;
24
- }
25
- function plan(overrides) {
26
- return {
27
- bench: loadBench(BUNDLED_CODE_REVIEW),
28
- target: collectSkillBundle(makeSkillSync(overrides.runsRoot), 'review-skill'),
29
- executor: new MockExecutor(),
30
- trials: 3,
31
- runGroup: 'test-group',
32
- ...overrides,
33
- };
34
- }
35
- let skillCounter = 0;
36
- function makeSkillSync(runsRoot) {
37
- const dir = join(runsRoot, `skill-${process.pid}-${skillCounter++}`);
38
- mkdirSync(dir, { recursive: true });
39
- writeFileSync(join(dir, 'SKILL.md'), '# review discipline\ncheck boundaries and error codes\n');
40
- return dir;
41
- }
42
- test('runExperiment pairs baseline/treatment and records everything', async (t) => {
43
- const runsRoot = tmp(t, 'skillfit-runs-');
44
- const skillDir = makeSkill(t);
45
- const manifest = await runExperiment({
46
- bench: loadBench(BUNDLED_CODE_REVIEW),
47
- target: collectSkillBundle(skillDir, 'review-skill'),
48
- executor: new MockExecutor(),
49
- trials: 3,
50
- runsRoot,
51
- runGroup: 'test-group',
52
- });
53
- assert.equal(manifest.schemaVersion, 4);
54
- assert.equal(manifest.tasks.length, 5);
55
- const task = manifest.tasks[0];
56
- assert.ok(task);
57
- assert.equal(task.id, 'review-r1');
58
- assert.deepEqual({ passes: task.conditions.baseline.passes, trials: task.conditions.baseline.trials }, { passes: 0, trials: 3 });
59
- assert.deepEqual({ passes: task.conditions.treatment.passes, trials: task.conditions.treatment.trials }, { passes: 3, trials: 3 });
60
- assert.deepEqual(task.outcomes.baseline, [false, false, false]);
61
- assert.deepEqual(task.outcomes.treatment, [true, true, true]);
62
- assert.equal(task.verdict, 'inconclusive');
63
- assert.match(task.verdictReason, /only 3 discordant pair/);
64
- assert.deepEqual(task.tokenDelta, { input: 2400, output: 240 });
65
- assert.equal(task.conditions.treatment.meanScore, 1);
66
- assert.ok(task.conditions.baseline.meanScore !== null);
67
- // The mock baseline finds the bare-Error bug but reports the C-style-loop decoy, so it scores 1 of
68
- // 4 checks: bare-error only. `no-false-positives` is what costs it the fourth.
69
- assert.ok(Math.abs(task.conditions.baseline.meanScore - 0.25) < 1e-9);
70
- assert.ok(task.scoreDelta !== null);
71
- assert.ok(Math.abs(task.scoreDelta - 0.75) < 1e-9);
72
- assert.deepEqual(task.scores.baseline, [0.25, 0.25, 0.25]);
73
- assert.deepEqual(task.scores.treatment, [1, 1, 1]);
74
- assert.deepEqual(task.facets.find((facet) => facet.name === 'discount-boundary'), {
75
- name: 'discount-boundary',
76
- baselinePassRate: 0,
77
- treatmentPassRate: 1,
78
- baselineTrials: 3,
79
- treatmentTrials: 3,
80
- });
81
- assert.deepEqual(task.facets.find((facet) => facet.name === 'no-false-positives'), {
82
- name: 'no-false-positives',
83
- baselinePassRate: 0,
84
- treatmentPassRate: 1,
85
- baselineTrials: 3,
86
- treatmentTrials: 3,
87
- }, 'reporting a decoy must cost the review a facet, not just get recorded');
88
- assert.equal(task.verifierNotes.length, 0);
89
- // summarize-s1 is a negative control whose mock treatment arm slips into review framing and fails,
90
- // so the pooled run regresses on 3 pairs. Nine improved against three regressed is not significant
91
- // at this sample size — which is the honest reading, and the point of the task being in the bench.
92
- assert.equal(manifest.overall.verdict, 'inconclusive');
93
- assert.deepEqual(manifest.overall.stats.discordant, { improved: 9, regressed: 3 });
94
- assert.equal(manifest.overall.stats.mcnemarP, 0.14599609375);
95
- const scoreDeltaCi = manifest.overall.stats.scoreDeltaCi;
96
- assert.ok(scoreDeltaCi !== null);
97
- // pooled treatment mean 0.9333 minus pooled baseline mean 0.55 (r1 .25, r2 .5, r3 0, x1 1, s1 1)
98
- assert.ok(Math.abs(scoreDeltaCi.point - 23 / 60) < 1e-9);
99
- assert.equal(manifest.target.bundleSha256.length, 64);
100
- assert.ok(manifest.warnings.some((w) => w.includes('synthetic')));
101
- assert.ok(manifest.warnings.some((w) => w.includes('"review-r3"') && w.includes('too hard or broken')));
102
- assert.ok(manifest.warnings.some((w) => w.includes('"explain-x1"') && w.includes('facet "states-purpose"')));
103
- const trialDir = join(runsRoot, 'test-group', 'review-r1', 'treatment', 'trial-1');
104
- assert.ok(existsSync(join(runsRoot, 'test-group', 'manifest.json')));
105
- assert.ok(existsSync(join(trialDir, '_prompt.txt')));
106
- assert.ok(existsSync(join(trialDir, '_output.md')));
107
- assert.ok(existsSync(join(trialDir, '_verifier.txt')));
108
- assert.ok(existsSync(join(trialDir, '_result.json')));
109
- assert.ok(existsSync(join(trialDir, '.git')), 'run directory is a git repository');
110
- const treatmentPrompt = readFileSync(join(trialDir, '_prompt.txt'), 'utf8');
111
- assert.match(treatmentPrompt, /<skill name="review-skill">/);
112
- assert.match(treatmentPrompt, /--- repository file: src\/order\.js ---/);
113
- assert.ok(!treatmentPrompt.includes('skillfit-mock'));
114
- const baselinePrompt = readFileSync(join(runsRoot, 'test-group', 'review-r1', 'baseline', 'trial-1', '_prompt.txt'), 'utf8');
115
- assert.ok(!baselinePrompt.includes('<skill name='));
116
- const result = JSON.parse(readFileSync(join(trialDir, '_result.json'), 'utf8'));
117
- assert.equal(result.schemaVersion, 2);
118
- assert.equal(result.passed, true);
119
- assert.equal(result.score, 1);
120
- assert.equal(result.checks?.length, 4);
121
- assert.equal(result.gitInitialized, true);
122
- assert.equal(result.target.bundleSha256, manifest.target.bundleSha256);
123
- const verifierLog = readFileSync(join(runsRoot, 'test-group', 'review-r1', 'baseline', 'trial-1', '_verifier.txt'), 'utf8');
124
- assert.match(verifierLog, /"missed":\["discount-boundary","missing-tests"\]/);
125
- // The mock baseline reports the C-style-loop decoy; it is now scored, not merely recorded.
126
- assert.match(verifierLog, /"decoys":\["c-style-loop"\]/);
127
- assert.match(verifierLog, /"name":"no-false-positives","pass":false/);
128
- assert.match(verifierLog, /"decoys":\["c-style-loop"\]/);
129
- });
130
- test('trial receipts retain monotonic and executor timing without changing paired quality', async (t) => {
131
- const runsRoot = tmp(t, 'skillfit-timing-receipts-');
132
- const timing = { clock: 'performance.now', timeoutMs: 600000, heartbeatMs: 1000, anomalyThresholdMs: 5000,
133
- elapsedMs: 25, wallElapsedMs: 25, maxObservationGapMs: 25, maxClockSkewMs: 0,
134
- timeoutFiredAfterMs: null, terminationDelayMs: null, anomaly: null };
135
- const mock = new MockExecutor();
136
- const clocks = { wall: 100000, mono: 0 };
137
- const executor = { describe: () => mock.describe(), run: async (...args) => {
138
- clocks.wall -= 50000;
139
- clocks.mono += 250;
140
- return { ...await mock.run(...args), executionTiming: timing };
141
- } };
142
- const outcome = await runTrial(plan({ runsRoot, executor, trials: 1,
143
- clock: { wallNow: () => clocks.wall, monotonicNow: () => clocks.mono } }), 'review-r1', 'baseline', 1);
144
- const receipt = JSON.parse(readFileSync(join(runsRoot, 'test-group', 'review-r1', 'baseline', 'trial-1', '_result.json'), 'utf8'));
145
- assert.equal(receipt.timing.clock, 'performance.now');
146
- assert.deepEqual(receipt.timing.execution, timing);
147
- assert.equal(receipt.durationSeconds, 0.25);
148
- assert.equal(receipt.timing.wallDurationSeconds, -50);
149
- assert.equal(outcome.error, null);
150
- });
151
- test('workspace pairs inspect identical disk inputs without inlining text or binary files', async (t) => {
152
- const runsRoot = tmp(t, 'skillfit-workspace-');
153
- const benchDir = join(runsRoot, 'bench');
154
- for (const rel of ['fixtures/task', 'prompts', 'verifiers'])
155
- mkdirSync(join(benchDir, rel), { recursive: true });
156
- writeFileSync(join(benchDir, 'fixtures/task/source.txt'), 'source sentinel: broken');
157
- writeFileSync(join(benchDir, 'fixtures/task/asset.bin'), Buffer.from([0, 255, 128, 17]));
158
- writeFileSync(join(benchDir, 'prompts/task.md'), 'Repair source.txt and preserve the asset.');
159
- writeFileSync(join(benchDir, 'verifiers/check.mjs'), "import {readFileSync} from 'node:fs'; process.exit(readFileSync(process.argv[2]+'/source.txt','utf8')==='fixed' ? 0 : 1);");
160
- writeFileSync(join(benchDir, 'bench.json'), JSON.stringify({ schemaVersion: 1, name: 'disk-task', tasks: [{
161
- id: 'task', fixture: 'fixtures/task', prompt: 'prompts/task.md', verifier: 'node verifiers/check.mjs', verifierKind: 'command',
162
- }] }));
163
- const prompts = [];
164
- const executor = {
165
- describe: () => ({ kind: 'cli', model: 'offline-disk-probe' }),
166
- run: (prompt, workdir) => {
167
- prompts.push(prompt);
168
- assert.equal(readFileSync(join(workdir, 'source.txt'), 'utf8'), 'source sentinel: broken');
169
- assert.deepEqual(readFileSync(join(workdir, 'asset.bin')), Buffer.from([0, 255, 128, 17]));
170
- assert.ok(!prompt.includes('source sentinel'));
171
- assert.ok(!prompt.includes('Repository snapshot:'));
172
- assert.ok(!prompt.includes('Your final message is the deliverable'));
173
- writeFileSync(join(workdir, 'source.txt'), 'fixed');
174
- return Promise.resolve({ output: 'Repaired and checked.' });
175
- },
176
- };
177
- const target = collectSkillBundle(makeSkill(t), 'disk-skill');
178
- const manifest = await runExperiment({ bench: loadBench(benchDir), target, executor, inputMode: 'workspace',
179
- trials: 1, runsRoot, runGroup: 'disk-pair' });
180
- assert.equal(manifest.inputMode, 'workspace');
181
- assert.equal(manifest.overall.conditions.baseline.passes, 1);
182
- assert.equal(manifest.overall.conditions.treatment.passes, 1);
183
- assert.equal(prompts[1], `${prompts[0].trimEnd()}\n\n${target.payload}\n`);
184
- for (const condition of ['baseline', 'treatment']) {
185
- const receipt = JSON.parse(readFileSync(join(runsRoot, 'disk-pair/task', condition, 'trial-1/_result.json'), 'utf8'));
186
- assert.equal(receipt.inputMode, 'workspace');
187
- }
188
- });
189
- test('workspace runner rejects API access before creating the run group', async (t) => {
190
- const runsRoot = tmp(t, 'skillfit-workspace-api-');
191
- const executor = { describe: () => ({ kind: 'api', model: 'offline' }), run: () => { throw new Error('must not run'); } };
192
- await assert.rejects(() => runExperiment(plan({ runsRoot, inputMode: 'workspace', executor })), /requires a CLI executor/);
193
- assert.ok(!existsSync(join(runsRoot, 'test-group')));
194
- });
195
- test('token coverage counts usage fields only on surviving graded pairs', async (t) => {
196
- const runsRoot = tmp(t, 'skillfit-token-coverage-');
197
- const bench = loadBench(BUNDLED_CODE_REVIEW);
198
- bench.tasks = bench.tasks.slice(0, 1);
199
- let calls = 0;
200
- const executor = {
201
- describe: () => ({ kind: 'mock', model: 'offline-usage' }),
202
- run: () => Promise.resolve({ output: 'No findings', tokens: ++calls === 1 ? { input: 10 } : undefined }),
203
- };
204
- const manifest = await runExperiment(plan({ runsRoot, bench, executor, trials: 1 }));
205
- assert.deepEqual(manifest.overall.conditions.baseline.tokenCoverage, { input: 1, output: 0 });
206
- assert.deepEqual(manifest.overall.conditions.treatment.tokenCoverage, { input: 0, output: 0 });
207
- });
208
- test('runExperiment preserves failure costs and distinguishes invocations from guard refusals', async (t) => {
209
- const runsRoot = tmp(t, 'skillfit-failure-costs-');
210
- const benchDir = join(runsRoot, 'bench');
211
- for (const dir of ['fixtures/t1', 'prompts', 'verifiers'])
212
- mkdirSync(join(benchDir, dir), { recursive: true });
213
- writeFileSync(join(benchDir, 'fixtures/t1/input.txt'), 'input');
214
- writeFileSync(join(benchDir, 'prompts/t1.md'), 'Solve the task.');
215
- writeFileSync(join(benchDir, 'verifiers/t1.mjs'), 'import { readFileSync } from "node:fs"; process.exit(readFileSync(process.argv[2]+"/_output.md","utf8")==="pass"?0:1);');
216
- writeFileSync(join(benchDir, 'bench.json'), JSON.stringify({ schemaVersion: 1, tasks: [{ id: 't1', fixture: 'fixtures/t1', prompt: 'prompts/t1.md', verifier: 'node verifiers/t1.mjs', verifierKind: 'output' }] }));
217
- let calls = 0;
218
- const executor = { describe: () => ({ kind: 'mock', model: 'cost-fixture' }), run: async () => {
219
- calls++;
220
- if (calls === 4)
221
- throw new ExecutorFailure('timeout', { output: 'unfinished', rawOutput: 'public partial transcript', tokens: { input: 3, cachedInput: 2, output: 1 }, usageStatus: 'partial' });
222
- if (calls >= 5)
223
- throw new ExecutorFailure('stopped before call', { output: '' }, false);
224
- return { output: calls === 2 ? 'fail' : 'pass', tokens: { input: 10, cachedInput: 8, output: 2 } };
225
- } };
226
- const manifest = await runExperiment(plan({ runsRoot, bench: loadBench(benchDir), executor, trials: 3 }));
227
- const costs = manifest.overall.costs;
228
- assert.equal(manifest.overall.conditions.baseline.trials, 1);
229
- assert.equal(manifest.overall.conditions.treatment.passes, 0);
230
- assert.equal(costs.attempts.baseline.passes, 2);
231
- assert.equal(costs.attempts.treatment.runs, 2);
232
- assert.equal(costs.attempts.treatment.metrics.input.knownTotal, 13);
233
- assert.deepEqual(costs.attempts.treatment.metrics.input.coverage, { final: 1, partial: 1, unknown: 0 });
234
- assert.deepEqual(costs.notInvoked, { baseline: 1, treatment: 1 });
235
- const receipt = JSON.parse(readFileSync(join(runsRoot, 'test-group/t1/treatment/trial-2/_result.json'), 'utf8'));
236
- assert.equal(receipt.executorInvoked, true);
237
- assert.equal(receipt.usageStatus, 'partial');
238
- assert.deepEqual(receipt.tokens, { input: 3, cachedInput: 2, output: 1 });
239
- assert.equal(readFileSync(join(runsRoot, 'test-group/t1/treatment/trial-2/_transcript.jsonl'), 'utf8'), 'public partial transcript');
240
- assert.match(renderEvalMarkdown(parseEvalReport(manifest)), /All agent executor invocations/);
241
- });
242
- test('runExperiment applies workspace config after snapshotting so prompts stay identical', async (t) => {
243
- const runsRoot = tmp(t, 'skillfit-config-runs-');
244
- const benchDir = join(runsRoot, 'bench');
245
- mkdirSync(join(benchDir, 'fixtures', 't1'), { recursive: true });
246
- mkdirSync(join(benchDir, 'prompts'), { recursive: true });
247
- mkdirSync(join(benchDir, 'verifiers'), { recursive: true });
248
- writeFileSync(join(benchDir, 'fixtures', 't1', 'input.txt'), 'same task input\n');
249
- writeFileSync(join(benchDir, 'prompts', 't1.md'), 'Use the available project tools and say whether config was active.\n');
250
- writeFileSync(join(benchDir, 'verifiers', 't1.mjs'), "import { readFileSync } from 'node:fs'; process.exit(readFileSync(process.argv[2] + '/_output.md', 'utf8').includes('configured') ? 0 : 1);\n");
251
- writeFileSync(join(benchDir, 'bench.json'), JSON.stringify({
252
- schemaVersion: 1,
253
- tasks: [{ id: 't1', fixture: 'fixtures/t1', prompt: 'prompts/t1.md', verifier: 'node verifiers/t1.mjs', verifierKind: 'output' }],
254
- }));
255
- const treatment = join(runsRoot, 'experiment', 'treatment');
256
- mkdirSync(join(treatment, '.codex'), { recursive: true });
257
- writeFileSync(join(treatment, '.codex', 'config.toml'), '[mcp_servers.demo]\ncommand = "demo"\n');
258
- const target = {
259
- kind: 'mcp',
260
- name: 'demo-mcp',
261
- sourceDir: join(runsRoot, 'experiment'),
262
- files: ['treatment/.codex/config.toml'],
263
- sha256: 'c'.repeat(64),
264
- payload: null,
265
- overlays: { treatment },
266
- };
267
- const executor = {
268
- describe: () => ({ kind: 'cli', model: 'workspace-probe' }),
269
- run: (_prompt, workdir) => Promise.resolve({
270
- output: existsSync(join(workdir, '.codex', 'config.toml')) ? 'configured' : 'plain',
271
- }),
272
- };
273
- const manifest = await runExperiment({
274
- bench: loadBench(benchDir),
275
- target,
276
- executor,
277
- trials: 1,
278
- runsRoot,
279
- runGroup: 'config-group',
280
- });
281
- assert.equal(manifest.target.kind, 'mcp');
282
- assert.equal(manifest.tasks[0]?.conditions.baseline.passes, 0);
283
- assert.equal(manifest.tasks[0]?.conditions.treatment.passes, 1);
284
- const baselineDir = join(runsRoot, 'config-group', 't1', 'baseline', 'trial-1');
285
- const treatmentDir = join(runsRoot, 'config-group', 't1', 'treatment', 'trial-1');
286
- assert.ok(!existsSync(join(baselineDir, '.codex', 'config.toml')));
287
- assert.ok(existsSync(join(treatmentDir, '.codex', 'config.toml')));
288
- assert.equal(readFileSync(join(baselineDir, '_prompt.txt'), 'utf8'), readFileSync(join(treatmentDir, '_prompt.txt'), 'utf8'), 'only workspace configuration may differ between paired arms');
289
- const prompt = readFileSync(join(treatmentDir, '_prompt.txt'), 'utf8');
290
- assert.ok(!prompt.includes('mcp_servers.demo'));
291
- assert.match(prompt, /inspect, edit, and run things there directly/);
292
- assert.ok(!prompt.includes('Do not use tools'));
293
- });
294
- test('runExperiment keeps executor errors as failed trials instead of crashing', async (t) => {
295
- const runsRoot = tmp(t, 'skillfit-runs-');
296
- const failing = {
297
- describe: () => ({ kind: 'cli', model: 'broken' }),
298
- run: () => Promise.reject(new Error('agent exploded')),
299
- };
300
- const manifest = await runExperiment({
301
- bench: loadBench(BUNDLED_CODE_REVIEW),
302
- target: collectSkillBundle(makeSkill(t)),
303
- executor: failing,
304
- trials: 1,
305
- runsRoot,
306
- runGroup: 'test-group',
307
- });
308
- const task = manifest.tasks[0];
309
- assert.ok(task);
310
- assert.equal(task.conditions.baseline.passes, 0);
311
- assert.equal(task.conditions.treatment.passes, 0);
312
- assert.equal(manifest.overall.verdict, 'inconclusive');
313
- const errorFile = join(runsRoot, 'test-group', 'review-r1', 'baseline', 'trial-1', '_executor-error.txt');
314
- assert.match(readFileSync(errorFile, 'utf8'), /agent exploded/);
315
- });
316
- test('runExperiment marks verdicts inconclusive when discordant pairs are too few', async (t) => {
317
- const runsRoot = tmp(t, 'skillfit-runs-');
318
- const manifest = await runExperiment(plan({ runsRoot, trials: 1 }));
319
- const task = manifest.tasks[0];
320
- assert.ok(task);
321
- assert.equal(task.verdict, 'inconclusive');
322
- assert.match(task.verdictReason, /only 1 discordant pair/);
323
- });
324
- test('runExperiment warns when the baseline already passes (bench too easy)', async (t) => {
325
- const runsRoot = tmp(t, 'skillfit-runs-');
326
- const benchDir = join(runsRoot, 'easy-bench');
327
- mkdirSync(join(benchDir, 'fixtures', 't1'), { recursive: true });
328
- mkdirSync(join(benchDir, 'prompts'), { recursive: true });
329
- mkdirSync(join(benchDir, 'verifiers'), { recursive: true });
330
- writeFileSync(join(benchDir, 'fixtures', 't1', 'index.txt'), 'x\n');
331
- writeFileSync(join(benchDir, 'fixtures', 't1', '.skillfit-mock.json'), JSON.stringify({ baseline: { output: 'ok' }, treatment: { output: 'ok' } }));
332
- writeFileSync(join(benchDir, 'prompts', 't1.md'), 'do it\n');
333
- writeFileSync(join(benchDir, 'verifiers', 't1.mjs'), 'console.log("{\\"passed\\":true}");\n');
334
- writeFileSync(join(benchDir, 'bench.json'), JSON.stringify({
335
- schemaVersion: 1,
336
- tasks: [{ id: 't1', fixture: 'fixtures/t1', prompt: 'prompts/t1.md', verifier: 'node verifiers/t1.mjs' }],
337
- }));
338
- const manifest = await runExperiment({
339
- bench: loadBench(benchDir),
340
- target: collectSkillBundle(makeSkill(t)),
341
- executor: new MockExecutor(),
342
- trials: 3,
343
- runsRoot,
344
- runGroup: 'test-group',
345
- });
346
- assert.equal(manifest.overall.verdict, 'inconclusive');
347
- assert.ok(manifest.warnings.some((w) => w.includes('"t1"') && w.includes('too easy')));
348
- });
349
- test('runExperiment refuses to reuse an existing run group', async (t) => {
350
- const runsRoot = tmp(t, 'skillfit-runs-');
351
- const base = plan({ runsRoot });
352
- await runExperiment(base);
353
- await assert.rejects(() => runExperiment(base), /already exists/);
354
- });
355
- test('runExperiment validates the run group name', async (t) => {
356
- const runsRoot = tmp(t, 'skillfit-runs-');
357
- await assert.rejects(() => runExperiment(plan({ runsRoot, runGroup: '../evil' })), /Invalid run group/);
358
- });
359
- test('runExperiment validates trials', async (t) => {
360
- const runsRoot = tmp(t, 'skillfit-runs-');
361
- await assert.rejects(() => runExperiment(plan({ runsRoot, trials: 0 })), /trials must be/);
362
- });
363
- test('runExperiment aggregates blind judge scores per task', async (t) => {
364
- const runsRoot = tmp(t, 'skillfit-runs-');
365
- const judge = {
366
- describe: () => ({ kind: 'api', model: 'judge-model' }),
367
- run: () => Promise.resolve({
368
- output: '{"A": {"correct":true,"complete":true,"grounded":true}, "B": {"correct":false,"complete":false,"grounded":false}}',
369
- }),
370
- };
371
- const manifest = await runExperiment({ ...plan({ runsRoot }), judge });
372
- const task = manifest.tasks[0];
373
- assert.ok(task);
374
- assert.ok(task.judge);
375
- assert.equal(task.judge?.judgedTrials, 3);
376
- assert.equal(task.judge?.consistentTrials, 0, 'a judge that always favors A is inconsistent');
377
- assert.equal(task.judge?.baselineMean, null);
378
- assert.equal(task.judge?.treatmentMean, null);
379
- assert.equal(manifest.judge?.model, 'judge-model');
380
- assert.ok(existsSync(join(runsRoot, 'test-group', 'review-r1', 'judge-trial-1.json')));
381
- });
382
- test('runExperiment never runs the judge inside the run group', async (t) => {
383
- const runsRoot = tmp(t, 'skillfit-runs-judgecwd-');
384
- const cwds = [];
385
- const listings = [];
386
- const judge = {
387
- describe: () => ({ kind: 'api', model: 'judge-model' }),
388
- run: (_prompt, workdir) => {
389
- cwds.push(workdir);
390
- listings.push(readdirSync(workdir).sort());
391
- return Promise.resolve({
392
- output: '{"A": {"correct":true,"complete":true,"grounded":true}, "B": {"correct":false,"complete":false,"grounded":false}}',
393
- });
394
- },
395
- };
396
- await runExperiment({ ...plan({ runsRoot }), judge, trials: 1 });
397
- const groupDir = join(runsRoot, 'test-group');
398
- assert.ok(cwds.length > 0, 'the judge ran');
399
- cwds.forEach((cwd, index) => {
400
- assert.ok(!cwd.startsWith(groupDir), `judge call ${index} ran inside the run group (${cwd}), where both arms and their _result.json live`);
401
- assert.deepEqual(listings[index], ['answerA.md', 'answerB.md']);
402
- });
403
- // The transcript is still written to the task directory, after the call rather than around it.
404
- assert.ok(existsSync(join(groupDir, 'review-r1', 'judge-trial-1.json')));
405
- });
406
- test('runExperiment averages judge scores only over consistent trials', async (t) => {
407
- const runsRoot = tmp(t, 'skillfit-runs-');
408
- const judge = {
409
- describe: () => ({ kind: 'api', model: 'judge-model' }),
410
- run: (prompt) => {
411
- const aIndex = prompt.indexOf('Answer A:');
412
- const bIndex = prompt.indexOf('Answer B:');
413
- const aIsTreatment = prompt.slice(aIndex, bIndex).includes('bulk discount');
414
- const win = '{"correct":true,"complete":true,"grounded":true}';
415
- const partial = '{"correct":true,"complete":false,"grounded":true}';
416
- return Promise.resolve({ output: aIsTreatment ? `{"A": ${win}, "B": ${partial}}` : `{"A": ${partial}, "B": ${win}}` });
417
- },
418
- };
419
- const manifest = await runExperiment({ ...plan({ runsRoot }), judge });
420
- const task = manifest.tasks[0];
421
- assert.ok(task?.judge);
422
- assert.equal(task.judge?.judgedTrials, 3);
423
- assert.equal(task.judge?.consistentTrials, 3);
424
- assert.equal(task.judge?.baselineMean, 2);
425
- assert.equal(task.judge?.treatmentMean, 3);
426
- });
427
- test('runExperiment strips the mock marker for non-mock executors', async (t) => {
428
- const runsRoot = tmp(t, 'skillfit-runs-');
429
- const fake = {
430
- describe: () => ({ kind: 'api', model: 'fake' }),
431
- run: () => Promise.resolve({ output: 'nothing useful' }),
432
- };
433
- await runExperiment({ ...plan({ runsRoot, trials: 1 }), executor: fake });
434
- const runDir = join(runsRoot, 'test-group', 'review-r1', 'baseline', 'trial-1');
435
- assert.ok(!existsSync(join(runDir, '.skillfit-mock.json')));
436
- });
437
- test('gitInit initializes a real repository', async (t) => {
438
- const dir = tmp(t, 'skillfit-git-');
439
- writeFileSync(join(dir, 'file.txt'), 'x\n');
440
- const ok = await gitInit(dir);
441
- assert.equal(ok, true);
442
- assert.ok(existsSync(join(dir, '.git')));
443
- });
444
- test('runExperiment drops an errored trial from both arms instead of scoring it as a failure', async (t) => {
445
- const runsRoot = tmp(t, 'skillfit-runs-errored-');
446
- const inner = new MockExecutor();
447
- const flaky = {
448
- // Must report kind 'mock': runTrial deletes .skillfit-mock.json for any other kind, which
449
- // would starve the delegate and fail both arms for the wrong reason.
450
- describe: () => inner.describe(),
451
- run: (prompt, workdir) => {
452
- const tail = workdir.split(/[\\/]/).slice(-2).join('/');
453
- if (tail === 'baseline/trial-2') {
454
- return Promise.reject(new Error('simulated API timeout'));
455
- }
456
- return inner.run(prompt, workdir);
457
- },
458
- };
459
- const manifest = await runExperiment(plan({ runsRoot, executor: flaky }));
460
- const task = manifest.tasks[0];
461
- assert.ok(task);
462
- assert.equal(task.id, 'review-r1');
463
- assert.equal(task.conditions.baseline.errors, 1);
464
- assert.equal(task.conditions.treatment.errors, 0);
465
- assert.equal(task.conditions.baseline.trials, 2);
466
- assert.equal(task.conditions.treatment.trials, 2, 'the paired treatment trial is dropped too');
467
- assert.equal(task.outcomes.baseline.length, 2);
468
- assert.equal(task.outcomes.treatment.length, 2);
469
- assert.equal(task.scores.baseline.length, 2);
470
- assert.equal(task.scores.treatment.length, 2);
471
- // Five tasks x two surviving pairs. review-r1/r2/r3 improve (6 discordant), explain-x1 passes in
472
- // both arms so its 2 pairs are concordant, and summarize-s1 regresses (2 more). Before the fix the
473
- // errored baseline trial counted as a failure, which also flipped explain-x1's pairs to "improved"
474
- // and inflated the count — a timeout masquerading as a result.
475
- assert.deepEqual(manifest.overall.stats.discordant, { improved: 6, regressed: 2 });
476
- assert.equal(manifest.overall.conditions.baseline.errors, 5);
477
- assert.equal(manifest.overall.conditions.baseline.trials, 10);
478
- assert.equal(manifest.overall.conditions.treatment.trials, 10);
479
- assert.equal(manifest.overall.verdict, 'inconclusive', 'the hole must not manufacture the significance a real effect would need');
480
- assert.ok(manifest.warnings.some((w) => w.includes('"review-r1" (baseline)') && w.includes('executor, verifier, or engagement error')), 'the exclusion is surfaced, not silent');
481
- });
482
- test('runExperiment excludes a trial whose verifier could not be spawned', async (t) => {
483
- const runsRoot = tmp(t, 'skillfit-runs-nospawn-');
484
- const benchDir = tmp(t, 'skillfit-bench-nospawn-');
485
- cpSync(BUNDLED_CODE_REVIEW, benchDir, { recursive: true });
486
- const benchJson = JSON.parse(readFileSync(join(benchDir, 'bench.json'), 'utf8'));
487
- const broken = benchJson.tasks[0];
488
- assert.ok(broken);
489
- // Swap only the executable, so the path token still resolves: this is the shape a Windows author
490
- // hits with `"verifier": "npm test"` (ENOENT) or a `.cmd` wrapper (EINVAL). There is no exit code,
491
- // so there is no verdict — and "no verdict" used to be recorded as the agent failing the task.
492
- broken.verifier = `no-such-verifier-binary ${broken.verifier.split(/\s+/).slice(1).join(' ')}`;
493
- writeFileSync(join(benchDir, 'bench.json'), `${JSON.stringify(benchJson, null, 2)}\n`);
494
- const manifest = await runExperiment({
495
- bench: loadBench(benchDir),
496
- target: collectSkillBundle(makeSkillSync(runsRoot), 'review-skill'),
497
- executor: new MockExecutor(),
498
- trials: 1,
499
- runsRoot,
500
- runGroup: 'test-group',
501
- });
502
- const task = manifest.tasks[0];
503
- assert.ok(task);
504
- assert.equal(task.id, broken.id);
505
- assert.equal(task.conditions.baseline.errors, 1);
506
- assert.equal(task.conditions.baseline.passes, 0);
507
- assert.equal(task.conditions.baseline.trials, 0, 'an unrunnable verifier grades nothing');
508
- assert.equal(task.conditions.treatment.trials, 0, 'and its paired arm is dropped with it');
509
- assert.ok(manifest.warnings.some((w) => w.includes(`"${broken.id}" (baseline)`) && w.includes('executor, verifier, or engagement error')), 'the exclusion is surfaced, not silent');
510
- const result = JSON.parse(readFileSync(join(runsRoot, 'test-group', broken.id, 'baseline', 'trial-1', '_result.json'), 'utf8'));
511
- assert.equal(result.passed, false);
512
- assert.equal(result.verifierExitCode, null);
513
- assert.match(result.error ?? '', /verifier could not be started/);
514
- assert.match(result.error ?? '', /spawned without a shell/);
515
- });
516
- test('a grader exception excludes its pair while normal graded failures and all invocation costs survive', async (t) => {
517
- const root = tmp(t, 'skillfit-grader-errors-');
518
- mkdirSync(join(root, 'fixture'));
519
- writeFileSync(join(root, 'fixture/input.txt'), 'input');
520
- writeFileSync(join(root, 'prompt.md'), 'Return an answer.');
521
- writeFileSync(join(root, 'verifier.mjs'), "import{readFileSync}from'node:fs';import{join}from'node:path';const text=readFileSync(join(process.argv[2],'_output.md'),'utf8');if(text==='crash')throw new Error('grader unavailable');console.log(JSON.stringify({passed:false}));process.exit(1);");
522
- writeFileSync(join(root, 'bench.json'), JSON.stringify({ schemaVersion: 1, tasks: [{ id: 't', fixture: 'fixture', prompt: 'prompt.md', verifier: 'node verifier.mjs' }] }));
523
- let calls = 0;
524
- const executor = { describe: () => ({ kind: 'mock', model: 'offline-grader-pairs' }), run: async () => ({ output: ++calls === 1 ? 'crash' : 'normal failure', tokens: { input: 10, cachedInput: 4, output: 2 } }) };
525
- const manifest = await runExperiment({ bench: loadBench(root), target: collectSkillBundle(makeSkill(t)), executor,
526
- trials: 2, runsRoot: join(root, 'runs'), runGroup: 'grade' });
527
- const task = manifest.tasks[0];
528
- assert.equal(calls, 4);
529
- assert.equal(task.conditions.baseline.errors, 1);
530
- assert.equal(task.conditions.treatment.errors, 0);
531
- assert.deepEqual(task.outcomes, { baseline: [false], treatment: [false] });
532
- assert.equal(manifest.overall.costs.attempts.baseline.metrics.input.knownTotal, 20);
533
- assert.equal(manifest.overall.costs.attempts.treatment.metrics.input.knownTotal, 20);
534
- assert.equal(manifest.overall.costs.paired.baseline.metrics.input.knownTotal, 10);
535
- const receipt = JSON.parse(readFileSync(join(root, 'runs/grade/t/baseline/trial-1/_result.json'), 'utf8'));
536
- assert.equal(receipt.verifierExitCode, 1);
537
- assert.match(receipt.error, /VERIFIER_RUNTIME_ERROR/);
538
- });
539
- test('runExperiment interleaves conditions within each trial and records sampling', async (t) => {
540
- const runsRoot = tmp(t, 'skillfit-runs-order-');
541
- const inner = new MockExecutor();
542
- const order = [];
543
- const spy = {
544
- describe: () => inner.describe(),
545
- run: (prompt, workdir) => {
546
- order.push(workdir.split(/[\\/]/).slice(-3).join('/'));
547
- return inner.run(prompt, workdir);
548
- },
549
- };
550
- const manifest = await runExperiment(plan({ runsRoot, executor: spy, trials: 2 }));
551
- assert.deepEqual(order.slice(0, 4), [
552
- 'review-r1/baseline/trial-1',
553
- 'review-r1/treatment/trial-1',
554
- 'review-r1/baseline/trial-2',
555
- 'review-r1/treatment/trial-2',
556
- ], 'the two arms of a pair must run adjacently; all-baselines-first confounds condition with elapsed time');
557
- assert.equal(manifest.executor.sampling, null, 'the matrix CLIs expose no seed or temperature knob, and the manifest says so rather than implying one');
558
- });
559
- function outputBench(root, kind) {
560
- for (const rel of ['fixtures/task', 'prompts', 'verifiers'])
561
- mkdirSync(join(root, rel), { recursive: true });
562
- writeFileSync(join(root, 'fixtures/task/source.txt'), 'broken');
563
- writeFileSync(join(root, 'prompts/task.md'), 'Fix it.');
564
- const verifier = kind === 'output'
565
- ? "import {readFileSync} from 'node:fs'; const out = readFileSync(process.argv[2]+'/_output.md','utf8'); const scored = out.includes('score'); const high = out.includes('high'); if (!scored) { console.log('unscored'); process.exit(out.includes('ok') ? 0 : 1); } console.log(JSON.stringify({passed: high, checks:[{name:'a',pass:high},{name:'b',pass:high}]})); process.exit(high ? 0 : 1);"
566
- : "import {readFileSync} from 'node:fs'; process.exit(readFileSync(process.argv[2]+'/source.txt','utf8')==='fixed' ? 0 : 1);";
567
- writeFileSync(join(root, 'verifiers/check.mjs'), verifier);
568
- writeFileSync(join(root, 'bench.json'), JSON.stringify({
569
- schemaVersion: 1, name: 'engagement', tasks: [{
570
- id: 'task', fixture: 'fixtures/task', prompt: 'prompts/task.md', verifier: 'node verifiers/check.mjs', verifierKind: kind,
571
- }],
572
- }));
573
- }
574
- test('empty output is an engagement error for an output task', async (t) => {
575
- const runsRoot = tmp(t, 'skillfit-engage-');
576
- const benchDir = join(runsRoot, 'bench');
577
- outputBench(benchDir, 'output');
578
- const executor = { describe: () => ({ kind: 'cli', model: 'silent' }), run: () => Promise.resolve({ output: ' \n' }) };
579
- const manifest = await runExperiment({
580
- bench: loadBench(benchDir), target: collectSkillBundle(makeSkill(t), 's'), executor, trials: 1, runsRoot, runGroup: 'silent',
581
- });
582
- assert.equal(manifest.overall.conditions.baseline.trials, 0);
583
- assert.equal(manifest.overall.conditions.baseline.errors, 1);
584
- assert.equal(manifest.overall.conditions.baseline.passes, 0);
585
- const receipt = JSON.parse(readFileSync(join(runsRoot, 'silent/task/baseline/trial-1/_result.json'), 'utf8'));
586
- assert.match(receipt.error, /engagement error/);
587
- assert.equal(existsSync(join(runsRoot, 'silent/task/baseline/trial-1/_verifier.txt')), false);
588
- });
589
- test('a command task with an empty message still counts when the fixture changed', async (t) => {
590
- const runsRoot = tmp(t, 'skillfit-engage-edit-');
591
- const benchDir = join(runsRoot, 'bench');
592
- outputBench(benchDir, 'command');
593
- const executor = {
594
- describe: () => ({ kind: 'cli', model: 'editor' }),
595
- run: (_prompt, workdir) => {
596
- writeFileSync(join(workdir, 'source.txt'), 'fixed');
597
- return Promise.resolve({ output: '' });
598
- },
599
- };
600
- const manifest = await runExperiment({
601
- bench: loadBench(benchDir), target: collectSkillBundle(makeSkill(t), 's'), executor, trials: 1, runsRoot, runGroup: 'edited',
602
- });
603
- assert.equal(manifest.overall.conditions.baseline.passes, 1);
604
- assert.equal(manifest.overall.conditions.baseline.errors, 0);
605
- });
606
- test('a command task that changes nothing is an engagement error', async (t) => {
607
- const runsRoot = tmp(t, 'skillfit-engage-idle-');
608
- const benchDir = join(runsRoot, 'bench');
609
- outputBench(benchDir, 'command');
610
- const executor = { describe: () => ({ kind: 'cli', model: 'idle' }), run: () => Promise.resolve({ output: '' }) };
611
- const manifest = await runExperiment({
612
- bench: loadBench(benchDir), target: collectSkillBundle(makeSkill(t), 's'), executor, trials: 1, runsRoot, runGroup: 'idle',
613
- });
614
- assert.equal(manifest.overall.conditions.baseline.trials, 0);
615
- assert.equal(manifest.overall.conditions.baseline.errors, 1);
616
- });
617
- test('Δscore drops a trial unless both arms produced a score', async (t) => {
618
- const runsRoot = tmp(t, 'skillfit-score-pair-');
619
- const benchDir = join(runsRoot, 'bench');
620
- outputBench(benchDir, 'output');
621
- let call = 0;
622
- const executor = {
623
- describe: () => ({ kind: 'cli', model: 'scorer' }),
624
- run: () => {
625
- call += 1;
626
- const output = call === 1 ? 'score low' : call === 4 ? 'score high' : 'plain';
627
- return Promise.resolve({ output });
628
- },
629
- };
630
- const manifest = await runExperiment({
631
- bench: loadBench(benchDir), target: collectSkillBundle(makeSkill(t), 's'), executor, trials: 2, runsRoot, runGroup: 'scores',
632
- });
633
- assert.equal(manifest.tasks[0]?.scoreDelta, null);
634
- assert.equal(manifest.overall.scoreDelta, null);
635
- });