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.
Files changed (172) hide show
  1. package/README.md +68 -104
  2. package/README.zh-CN.md +68 -101
  3. package/benches/README.md +6 -2
  4. package/dist/cli.js +28 -16
  5. package/dist/commands/bench-calibration.js +5 -1
  6. package/dist/commands/bench-check-report.js +1 -34
  7. package/dist/commands/bench-draft.js +167 -0
  8. package/dist/commands/bench-draft.test.js +168 -0
  9. package/dist/commands/bench-manage.js +5 -4
  10. package/dist/commands/bench-source.js +101 -0
  11. package/dist/commands/bench-source.test.js +84 -0
  12. package/dist/commands/bench.js +157 -328
  13. package/dist/commands/eval-api-failure.test.js +46 -0
  14. package/dist/commands/eval-layout.test.js +126 -0
  15. package/dist/commands/eval-preflight-error.js +9 -0
  16. package/dist/commands/eval-preflight.js +4 -11
  17. package/dist/commands/eval-report.js +6 -459
  18. package/dist/commands/eval.js +7 -32
  19. package/dist/commands/install.js +14 -98
  20. package/dist/harness/agent-preflight.js +18 -2
  21. package/dist/harness/bench-check.js +277 -0
  22. package/dist/harness/bench-diagnostics.js +34 -0
  23. package/dist/harness/bench-location.js +29 -0
  24. package/dist/harness/bench-location.test.js +33 -0
  25. package/dist/harness/bench.js +8 -3
  26. package/dist/harness/eval-acceptance.js +1 -1
  27. package/dist/harness/eval-audit.js +2 -2
  28. package/dist/harness/eval-manifest.js +456 -0
  29. package/dist/harness/evaluation-layout.js +30 -0
  30. package/dist/harness/executors/api.js +20 -7
  31. package/dist/harness/executors/cli.js +15 -25
  32. package/dist/harness/experiment-session.js +5 -15
  33. package/dist/harness/hash.js +3 -1
  34. package/dist/harness/runner.js +5 -4
  35. package/dist/harness/single-arm-audit.js +1 -1
  36. package/dist/harness/trigger.js +1 -1
  37. package/dist/harness/verifier-timeout.js +8 -0
  38. package/dist/harness/verifier-timeout.test.js +76 -0
  39. package/dist/install/constants.js +1 -0
  40. package/dist/install/transaction.js +112 -0
  41. package/docs/README.md +65 -0
  42. package/docs/architecture.md +86 -0
  43. package/docs/archive-delivery.md +83 -0
  44. package/docs/archive-inventory.md +91 -0
  45. package/docs/bench-authoring.md +23 -3
  46. package/docs/bench-drafting.md +75 -0
  47. package/docs/case-management.md +12 -1
  48. package/docs/eval-agent-preflight.md +15 -2
  49. package/docs/eval-costs.md +28 -2
  50. package/docs/eval-planning.md +14 -0
  51. package/docs/evaluation-input-snapshots.md +20 -4
  52. package/docs/evaluation-reports.md +1 -1
  53. package/docs/first-real-eval.md +28 -3
  54. package/docs/growth-roadmap-2026-10.md +23 -18
  55. package/docs/package-contents.md +73 -0
  56. package/docs/plans/2026-10-17-workflow-foundations.md +37 -2
  57. package/docs/plans/2026-10-20-archive-replay-verification.json +125 -0
  58. package/docs/plans/2026-10-20-archive-source-verification.json +256 -0
  59. package/docs/plans/2026-10-20-delivery-verification.json +146 -0
  60. package/docs/plans/2026-10-20-docs-architecture-cleanup.md +233 -0
  61. package/docs/plans/2026-10-20-install-transactions-and-archive-delivery.md +233 -0
  62. package/docs/plans/2026-10-21-npm-0.13.0-release.md +41 -0
  63. package/docs/releases/0.11.0-ci-registry-install.json +130 -0
  64. package/docs/releases/0.11.0-feature-smoke.json +1576 -0
  65. package/docs/releases/0.11.0-local-attempt-1.json +24 -0
  66. package/docs/releases/0.11.0-local-attempt-1.log +19 -0
  67. package/docs/releases/0.11.0-local-registry-install.json +25 -0
  68. package/docs/releases/0.11.0-registry-metadata.json +33 -0
  69. package/docs/releases/0.11.0-signatures.txt +12 -0
  70. package/docs/releases/0.11.0-verification.json +95 -0
  71. package/docs/releases/0.11.0.md +54 -11
  72. package/docs/releases/0.12.0-attestation-check.json +22 -0
  73. package/docs/releases/0.12.0-attestations.json +155 -0
  74. package/docs/releases/0.12.0-ci-registry-install.json +90 -0
  75. package/docs/releases/0.12.0-feature-smoke.json +34 -0
  76. package/docs/releases/0.12.0-feature-smoke.mjs +73 -0
  77. package/docs/releases/0.12.0-foundations-smoke.json +1576 -0
  78. package/docs/releases/0.12.0-local-registry-install.json +75 -0
  79. package/docs/releases/0.12.0-preparation-attempt-1.json +22 -0
  80. package/docs/releases/0.12.0-registry-metadata.json +96 -0
  81. package/docs/releases/0.12.0-signatures.txt +6 -0
  82. package/docs/releases/0.12.0-verification.json +99 -0
  83. package/docs/releases/0.12.0.md +82 -0
  84. package/docs/releases/0.13.0-feature-smoke.mjs +114 -0
  85. package/docs/releases/0.13.0-preparation.json +102 -0
  86. package/docs/releases/0.13.0.md +61 -0
  87. package/docs/releases/archive-delivery-smoke.mjs +37 -0
  88. package/docs/reproducible-offline-example.md +1 -1
  89. package/docs/schemas/agent-preflight.schema.json +1 -1
  90. package/docs/verifier-contract.md +9 -0
  91. package/evidence/README.md +24 -1
  92. package/evidence/archive-catalog.v1.json +8044 -0
  93. package/evidence/fetch-archives.mjs +211 -0
  94. package/package.json +9 -2
  95. package/skills/skillfit/SKILL.md +25 -5
  96. package/dist/cli.test.js +0 -193
  97. package/dist/commands/bench-calibration.test.js +0 -237
  98. package/dist/commands/bench-check-json.test.js +0 -242
  99. package/dist/commands/bench-manage.test.js +0 -87
  100. package/dist/commands/bench.test.js +0 -1162
  101. package/dist/commands/bundle.test.js +0 -142
  102. package/dist/commands/calibration-cli.test.js +0 -145
  103. package/dist/commands/doctor.test.js +0 -280
  104. package/dist/commands/eval-agent-preflight.test.js +0 -245
  105. package/dist/commands/eval-export-modes.test.js +0 -350
  106. package/dist/commands/eval-export.test.js +0 -279
  107. package/dist/commands/eval-interruption.test.js +0 -238
  108. package/dist/commands/eval-preflight.test.js +0 -382
  109. package/dist/commands/eval-report.test.js +0 -367
  110. package/dist/commands/eval.test.js +0 -503
  111. package/dist/commands/evaluation-report.test.js +0 -243
  112. package/dist/commands/install.test.js +0 -555
  113. package/dist/commands/replay-cancellation.test.js +0 -105
  114. package/dist/commands/report.test.js +0 -110
  115. package/dist/commands/setup.test.js +0 -150
  116. package/dist/commands/upstream.test.js +0 -139
  117. package/dist/commands/workflow-entrypoints.test.js +0 -137
  118. package/dist/docs.test.js +0 -154
  119. package/dist/frontmatter.test.js +0 -49
  120. package/dist/harness/bench.test.js +0 -109
  121. package/dist/harness/bundle.test.js +0 -71
  122. package/dist/harness/codex-usage.test.js +0 -87
  123. package/dist/harness/costs.test.js +0 -92
  124. package/dist/harness/eval-budget.test.js +0 -237
  125. package/dist/harness/eval-component.test.js +0 -770
  126. package/dist/harness/eval-efficiency.test.js +0 -56
  127. package/dist/harness/execution-timing.test.js +0 -61
  128. package/dist/harness/executors/api.test.js +0 -136
  129. package/dist/harness/executors/cli.test.js +0 -510
  130. package/dist/harness/executors/mock.test.js +0 -43
  131. package/dist/harness/experiment-session.test.js +0 -317
  132. package/dist/harness/installed-skill.test.js +0 -162
  133. package/dist/harness/interruption.test.js +0 -31
  134. package/dist/harness/judge-accounting.test.js +0 -216
  135. package/dist/harness/judge.test.js +0 -181
  136. package/dist/harness/kimi-usage.test.js +0 -62
  137. package/dist/harness/native-diff.test.js +0 -53
  138. package/dist/harness/oss-lru-cache.test.js +0 -79
  139. package/dist/harness/oss-normalize-url.test.js +0 -64
  140. package/dist/harness/oss-regression-witness.test.js +0 -89
  141. package/dist/harness/oss-skill-followup.test.js +0 -59
  142. package/dist/harness/prompt.test.js +0 -48
  143. package/dist/harness/receipts.test.js +0 -148
  144. package/dist/harness/report.test.js +0 -297
  145. package/dist/harness/runner.test.js +0 -635
  146. package/dist/harness/skill-revision.test.js +0 -148
  147. package/dist/harness/stats.test.js +0 -124
  148. package/dist/harness/target.test.js +0 -60
  149. package/dist/harness/trigger.test.js +0 -261
  150. package/dist/harness/verifier-summary.test.js +0 -99
  151. package/dist/harness/verifier.test.js +0 -128
  152. package/dist/harness/waza-behavior.test.js +0 -139
  153. package/dist/mcp/probe.test.js +0 -139
  154. package/evidence/artifacts/2026-10-12-diagnosing-revision/calibration-records.tar.gz +0 -0
  155. package/evidence/artifacts/2026-10-12-diagnosing-revision/interrupted-records.tar.gz +0 -0
  156. package/evidence/artifacts/2026-10-12-diagnosing-revision/validation-records.tar.gz +0 -0
  157. package/evidence/artifacts/2026-10-12-diagnosing-v2/regression-records.tar.gz +0 -0
  158. package/evidence/artifacts/2026-10-12-diagnosing-v2/transfer-records.tar.gz +0 -0
  159. package/evidence/artifacts/2026-10-12-normalize-url-v2-available/readiness-records.tar.gz +0 -0
  160. package/evidence/artifacts/2026-10-12-normalize-url-v2-comparison/records.tar.gz +0 -0
  161. package/evidence/artifacts/2026-10-12-normalize-url-v2-recovery/records.tar.gz +0 -0
  162. package/evidence/artifacts/2026-10-12-normalize-url-v2-validated/records.tar.gz +0 -0
  163. package/evidence/artifacts/2026-10-13-debugging-completed-development/package.tar.gz +0 -0
  164. package/evidence/artifacts/2026-10-13-debugging-controls-and-sleep-stop/package.tar.gz +0 -0
  165. package/evidence/artifacts/2026-10-13-debugging-development-stops/package.tar.gz +0 -0
  166. package/evidence/artifacts/2026-10-14-debugging-followup-routing-stop/package.tar.gz +0 -0
  167. package/evidence/artifacts/2026-10-14-debugging-independent-validation/package.tar.gz +0 -0
  168. package/evidence/artifacts/2026-10-14-debugging-reading-pilot-and-cost-review/package.tar.gz +0 -0
  169. package/evidence/artifacts/2026-10-14-debugging-spending-stop/package.tar.gz +0 -0
  170. package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
  171. package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
  172. package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/package.tar.gz +0 -0
@@ -1,317 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
3
- import { tmpdir } from 'node:os';
4
- import { join } from 'node:path';
5
- import { test } from 'node:test';
6
- import { loadBench } from './bench.js';
7
- import { collectInstalledSkillTarget } from './installed-skill.js';
8
- import { ExperimentSession, normalizeProjectTrust, validateCallBudget } from './experiment-session.js';
9
- import { sha256File } from './hash.js';
10
- import { runEval } from '../commands/eval.js';
11
- import { runBenchCheck } from '../commands/bench.js';
12
- import { packageFiles } from './replay-package.js';
13
- function setup(t) {
14
- const root = mkdtempSync(join(tmpdir(), 'skillfit-session-'));
15
- t.after(() => rmSync(root, { recursive: true, force: true }));
16
- const benchDir = join(root, 'bench');
17
- const skill = join(root, 'skill');
18
- mkdirSync(join(benchDir, 'fixture'), { recursive: true });
19
- mkdirSync(skill);
20
- writeFileSync(join(skill, 'SKILL.md'), '---\nname: candidate\ndescription: offline fixture\n---\nInspect boundaries.\n');
21
- writeFileSync(join(benchDir, 'fixture', 'index.js'), 'module.exports = 1;\n');
22
- writeFileSync(join(benchDir, 'prompt.md'), 'Fix the cache.\n');
23
- writeFileSync(join(benchDir, 'verify.mjs'), "import{existsSync,readFileSync}from'node:fs';import{join}from'node:path';const output=join(process.argv[2],'_output.md');process.exit(existsSync(output)&&readFileSync(output,'utf8').trim()?0:1);\n");
24
- writeFileSync(join(benchDir, 'bench.json'), JSON.stringify({ schemaVersion: 1, name: 'session-test', tasks: [
25
- { id: 'one', fixture: 'fixture', prompt: 'prompt.md', verifier: 'node verify.mjs', shouldTrigger: true },
26
- ] }));
27
- const bench = loadBench(benchDir);
28
- const target = collectInstalledSkillTarget(skill);
29
- const groupDir = join(root, 'runs', 'test');
30
- const options = { bench, target, groupDir, workspaces: [join(groupDir, 'one', 'baseline', 'trial-1')],
31
- plannedCalls: 2, injected: true, details: { mode: 'test' } };
32
- const executor = { describe: () => ({ kind: 'cli', model: 'offline' }), run: async () => ({ output: 'done', rawOutput: 'raw\n' }) };
33
- return { root, benchDir, skill, bench, groupDir, options, executor };
34
- }
35
- test('budget rejects unsafe values and underfunded plans before writes or probes', async (t) => {
36
- const s = setup(t);
37
- for (const n of [0, -1, 1.5, NaN, Number.MAX_SAFE_INTEGER + 1])
38
- assert.throws(() => validateCallBudget(2, n), /positive safe integer/);
39
- assert.throws(() => new ExperimentSession({ ...s.options, maxCalls: 1, versionProbe: () => { throw new Error('must not probe'); } }), /exceeding --max-calls/);
40
- assert.equal(existsSync(s.groupDir), false);
41
- await assert.rejects(() => runEval({ skillPath: s.skill, bench: s.benchDir, trials: 1, executor: s.executor,
42
- judgeExecutor: s.executor, maxCalls: 3, dryRun: false, yes: true, runsRoot: join(s.root, 'eval'), log: () => { } }), /needs 4 model calls/);
43
- assert.equal(existsSync(join(s.root, 'eval')), false);
44
- });
45
- test('dry run includes judge budget and never probes a real CLI or writes', async (t) => {
46
- const s = setup(t);
47
- const lines = [];
48
- await runEval({ skillPath: s.skill, bench: s.benchDir, trials: 1, executor: s.executor, judgeExecutor: s.executor,
49
- agent: 'codex', maxCalls: 4, dryRun: true, yes: true, runsRoot: join(s.root, 'eval'), log: line => lines.push(line),
50
- sessionOptions: { homeDir: s.root, versionProbe: () => { throw new Error('must not probe'); } } });
51
- assert.match(lines.join('\n'), /4 planned; ceiling 4/);
52
- assert.equal(existsSync(join(s.root, 'eval')), false);
53
- });
54
- test('call ledger and index retain completed calls; a larger ceiling never adds samples', async (t) => {
55
- const s = setup(t);
56
- let calls = 0;
57
- const session = new ExperimentSession({ ...s.options, maxCalls: 10 });
58
- const guarded = session.wrap({ ...s.executor, run: async () => { calls++; return { output: 'ok' }; } }, 'agent');
59
- await guarded.run('a', s.root);
60
- await guarded.run('b', s.root);
61
- await assert.rejects(() => guarded.run('replacement', s.root), /ceiling reached/);
62
- assert.equal(calls, 2);
63
- const linkTarget = process.platform === 'win32' ? 'missing-unfollowed-target' : '/missing-unfollowed-target';
64
- symlinkSync(linkTarget, join(s.groupDir, 'agent-link'));
65
- session.finish();
66
- assert.equal(session.summary().status, 'stopped');
67
- const ledger = readFileSync(join(s.groupDir, '_calls.jsonl'), 'utf8').trim().split('\n').map(line => JSON.parse(line));
68
- assert.deepEqual(ledger.map(row => row.event), ['started', 'finished', 'started', 'finished']);
69
- const index = JSON.parse(readFileSync(join(s.groupDir, '_artifacts.json'), 'utf8'));
70
- assert.equal(index.files['_plan.json'], sha256File(join(s.groupDir, '_plan.json')));
71
- assert.equal(index.files['_session.json'], sha256File(join(s.groupDir, '_session.json')));
72
- assert.equal(index.links['agent-link'], linkTarget);
73
- });
74
- test('a changed frozen input retains returned output but blocks subsequent calls', async (t) => {
75
- const s = setup(t);
76
- let calls = 0;
77
- const session = new ExperimentSession(s.options);
78
- const guarded = session.wrap({ ...s.executor, run: async () => {
79
- calls++;
80
- writeFileSync(join(s.benchDir, 'prompt.md'), 'changed');
81
- return { output: 'returned', rawOutput: 'retained' };
82
- } }, 'agent');
83
- const result = await guarded.run('first', s.root);
84
- assert.match(result.guardError, /Frozen bench input changed/);
85
- assert.equal(result.output, 'returned');
86
- assert.equal(result.rawOutput, 'retained');
87
- await assert.rejects(() => guarded.run('second', s.root), /Frozen bench input changed/);
88
- session.finish();
89
- assert.equal(calls, 1);
90
- assert.equal(session.summary().status, 'stopped');
91
- });
92
- test('input snapshots exist and are bound before dispatch; modifying one stops further calls with usage retained', async (t) => {
93
- const s = setup(t), session = new ExperimentSession(s.options);
94
- const plan = JSON.parse(readFileSync(join(s.groupDir, '_plan.json'), 'utf8'));
95
- const snapshot = JSON.parse(readFileSync(join(s.groupDir, '_inputs.json'), 'utf8'));
96
- assert.equal(plan.inputSnapshot.sha256, sha256File(join(s.groupDir, '_inputs.json')));
97
- assert.deepEqual(snapshot.entries.map((entry) => entry.label).sort(), ['bench', 'implementation', 'target']);
98
- const files = packageFiles(join(s.groupDir, '_inputs'));
99
- assert.equal(plan.inputSnapshot.cost.files, files.length + 1);
100
- assert.equal(plan.inputSnapshot.cost.bytes, files.reduce((sum, file) => sum + readFileSync(join(s.groupDir, '_inputs', file)).length, 0) + readFileSync(join(s.groupDir, '_inputs.json')).length);
101
- assert.equal(plan.inputSnapshot.cost.modelCalls, 0);
102
- assert.ok(plan.inputSnapshot.cost.durationMs >= 0);
103
- let calls = 0;
104
- const guarded = session.wrap({ ...s.executor, run: async () => {
105
- calls++;
106
- assert.equal(readFileSync(join(s.groupDir, '_inputs/target/SKILL.md'), 'utf8'), readFileSync(join(s.skill, 'SKILL.md'), 'utf8'));
107
- writeFileSync(join(s.groupDir, '_inputs/target/SKILL.md'), 'changed snapshot');
108
- return { output: 'retained', tokens: { input: 12, output: 3 } };
109
- } }, 'agent');
110
- const result = await guarded.run('first', s.root);
111
- assert.match(result.guardError, /snapshot hash mismatch/);
112
- assert.deepEqual(result.tokens, { input: 12, output: 3 });
113
- await assert.rejects(guarded.run('partner', s.root), /snapshot hash mismatch/);
114
- assert.equal(calls, 1);
115
- session.finish();
116
- assert.equal(session.summary().status, 'stopped');
117
- });
118
- test('source drift during snapshot setup fails before dispatch and removes only its fresh output', async (t) => {
119
- const s = setup(t);
120
- let calls = 0;
121
- const runsRoot = join(s.root, 'drift'), group = join(runsRoot, 'saved');
122
- mkdirSync(runsRoot);
123
- writeFileSync(join(runsRoot, 'kept'), 'existing sibling');
124
- await assert.rejects(runEval({ skillPath: s.skill, bench: s.benchDir, executor: { ...s.executor, run: async () => { calls++; return { output: 'done' }; } },
125
- judgeExecutor: null, agent: 'codex', trials: 1, dryRun: false, yes: true, runsRoot, runGroup: 'saved', log: () => { },
126
- sessionOptions: { homeDir: s.root, env: {}, versionProbe: () => { writeFileSync(join(s.benchDir, 'prompt.md'), 'changed after fingerprinting'); return 'fake 1.0'; } } }), /changed.*snapshot|snapshot.*changed/i);
127
- assert.equal(calls, 0);
128
- assert.ok(!existsSync(group));
129
- assert.equal(readFileSync(join(runsRoot, 'kept'), 'utf8'), 'existing sibling');
130
- });
131
- test('executor failure stops further actual calls and keeps a failure receipt without secrets', async (t) => {
132
- const s = setup(t);
133
- let calls = 0;
134
- const session = new ExperimentSession(s.options);
135
- const guarded = session.wrap({ ...s.executor, run: async () => { calls++; throw new Error('PRIVATE_SECRET'); } }, 'agent');
136
- await assert.rejects(() => guarded.run('first', s.root), /PRIVATE_SECRET/);
137
- await assert.rejects(() => guarded.run('second', s.root), /executor failed/);
138
- session.finish();
139
- assert.equal(calls, 1);
140
- assert.equal(readFileSync(join(s.groupDir, '_session.json'), 'utf8').includes('PRIVATE_SECRET'), false);
141
- assert.match(readFileSync(join(s.groupDir, '_calls.jsonl'), 'utf8'), /"event":"failed"/);
142
- });
143
- test('finalizing arbitrary errors keeps generic session diagnostics instead of copying secret-bearing messages', t => {
144
- const s = setup(t), session = new ExperimentSession(s.options);
145
- session.finish(new Error('secret-bearing untrusted executor error'));
146
- const saved = readFileSync(join(s.groupDir, '_session.json'), 'utf8');
147
- assert.doesNotMatch(saved, /secret-bearing/);
148
- assert.equal(session.summary().stopCode, undefined);
149
- assert.match(session.summary().stopReason, /Experiment setup or execution stopped/);
150
- });
151
- test('trust normalization covers declared pure blocks only and preserves other configuration bytes', () => {
152
- const trust = { table: 'projects', field: 'trust_level', value: 'trusted' };
153
- const base = 'model = "m"\n';
154
- const block = '[projects."/tmp/trial"]\ntrust_level = "trusted"\n';
155
- assert.equal(normalizeProjectTrust(base + '\n' + block, trust, ['/tmp/trial']), base);
156
- for (const altered of [block.replace('/tmp/trial', '/tmp/other'), block.replace('"trusted"', '"untrusted"'), block + 'model = "other"\n']) {
157
- assert.notEqual(normalizeProjectTrust(base + altered, trust, ['/tmp/trial']), base);
158
- }
159
- assert.notEqual(normalizeProjectTrust('model = "m" \n', trust, []), base);
160
- });
161
- test('temporary profile config is pinned, planned trust additions are allowed, model changes stop', t => {
162
- const s = setup(t);
163
- const profile = join(s.root, 'profile');
164
- mkdirSync(profile);
165
- const config = join(profile, 'config.toml');
166
- writeFileSync(config, 'model = "offline"\nmodel_reasoning_effort = "high"\napi_key = "PRIVATE_SECRET"\n');
167
- const session = new ExperimentSession({ ...s.options, agent: 'codex', homeDir: join(s.root, 'home'),
168
- env: { CODEX_HOME: profile }, versionProbe: () => 'codex-cli 1.2.3' });
169
- const plan = readFileSync(join(s.groupDir, '_plan.json'), 'utf8');
170
- assert.equal(plan.includes('PRIVATE_SECRET'), false);
171
- assert.match(plan, /"model_reasoning_effort": "high"/);
172
- const snapshot = JSON.parse(readFileSync(join(s.groupDir, '_inputs.json'), 'utf8'));
173
- assert.deepEqual(snapshot.entries.map((entry) => entry.label).sort(), ['bench', 'implementation', 'target'], 'private agent configuration remains fingerprint-only');
174
- writeFileSync(config, readFileSync(config, 'utf8') + `\n[projects.${JSON.stringify(s.options.workspaces[0])}]\ntrust_level = "trusted"\n`);
175
- session.check();
176
- writeFileSync(config, readFileSync(config, 'utf8').replace('"offline"', '"changed"'));
177
- assert.throws(() => session.check(), /Agent configuration changed/);
178
- session.finish();
179
- });
180
- test('canonical trust names for frozen workspace aliases are allowed, unrelated names and overrides are not', t => {
181
- const s = setup(t);
182
- const profile = join(s.root, 'profile');
183
- mkdirSync(profile);
184
- const real = join(s.root, 'physical');
185
- mkdirSync(real);
186
- const alias = join(s.root, 'alias');
187
- symlinkSync(real, alias, 'junction');
188
- const logical = join(alias, 'new', 'task', 'trial-1');
189
- const physical = join(realpathSync(real), 'new', 'task', 'trial-1');
190
- const config = join(profile, 'config.toml');
191
- writeFileSync(config, 'model = "offline"\n');
192
- const options = { ...s.options, agent: 'codex', homeDir: join(s.root, 'home'), env: { CODEX_HOME: profile },
193
- versionProbe: () => 'offline 1.0', workspaces: [logical] };
194
- const session = new ExperimentSession(options);
195
- writeFileSync(config, `model = "offline"\n[projects.${JSON.stringify(physical)}]\ntrust_level = "trusted"\n`);
196
- mkdirSync(logical, { recursive: true });
197
- session.check();
198
- const plan = JSON.parse(readFileSync(join(s.groupDir, '_plan.json'), 'utf8'));
199
- assert.deepEqual(plan.workspaceAliases, [{ logical, physical }]);
200
- writeFileSync(config, readFileSync(config, 'utf8') + 'model = "overridden"\n');
201
- assert.throws(() => session.check(), /Agent configuration changed/);
202
- session.finish();
203
- writeFileSync(config, 'model = "offline"\n');
204
- const other = new ExperimentSession({ ...options, groupDir: join(s.root, 'other-run') });
205
- writeFileSync(config, `model = "offline"\n[projects.${JSON.stringify(join(real, 'other'))}]\ntrust_level = "trusted"\n`);
206
- assert.throws(() => other.check(), /Agent configuration changed/);
207
- other.finish();
208
- });
209
- test('retargeting a declared workspace alias cannot expand its frozen trust allowlist', t => {
210
- const s = setup(t);
211
- const real = join(s.root, 'physical');
212
- const other = join(s.root, 'other');
213
- mkdirSync(real);
214
- mkdirSync(other);
215
- const alias = join(s.root, 'alias');
216
- symlinkSync(real, alias, 'junction');
217
- const session = new ExperimentSession({ ...s.options, workspaces: [join(alias, 'trial')] });
218
- session.check();
219
- rmSync(alias);
220
- symlinkSync(other, alias, 'junction');
221
- assert.throws(() => session.check(), /workspace alias changed/);
222
- session.finish();
223
- });
224
- test('global Skill directory aliases are pinned and candidate aliases reject contamination', t => {
225
- const s = setup(t);
226
- const home = join(s.root, 'home');
227
- const skills = join(home, '.agents', 'skills');
228
- mkdirSync(skills, { recursive: true });
229
- const other = join(s.root, 'other');
230
- mkdirSync(other);
231
- writeFileSync(join(other, 'SKILL.md'), '---\nname: other\n---\n');
232
- symlinkSync(other, join(skills, 'alias'));
233
- const options = { ...s.options, agent: 'codex', homeDir: home, env: {}, versionProbe: () => 'offline 1.0' };
234
- const session = new ExperimentSession(options);
235
- session.check();
236
- writeFileSync(join(other, 'SKILL.md'), 'changed');
237
- assert.throws(() => session.check(), /global Skill input changed/);
238
- session.finish();
239
- symlinkSync(s.skill, join(skills, 'candidate-alias'));
240
- assert.throws(() => new ExperimentSession({ ...options, groupDir: join(s.root, 'new') }), /Baseline contamination/);
241
- assert.equal(existsSync(join(s.root, 'new')), false);
242
- });
243
- test('installed read observations exclude errored pairs and managed eval retains receipts', async (t) => {
244
- const s = setup(t);
245
- let calls = 0;
246
- const result = await runEval({ skillPath: s.skill, bench: s.benchDir, trials: 2, mode: 'installed',
247
- agent: 'codex', dryRun: false, yes: true, runsRoot: join(s.root, 'eval'), runGroup: 'reads', log: () => { },
248
- executor: { ...s.executor, run: async () => {
249
- calls++;
250
- if (calls === 3)
251
- throw new Error('offline failure');
252
- return { output: 'done', skillTriggered: calls === 2, rawOutput: 'offline transcript' };
253
- } } });
254
- assert.ok(result && 'overall' in result);
255
- assert.equal(calls, 3);
256
- assert.equal(result.experiment.status, 'stopped');
257
- assert.deepEqual(result.overall.conditions.treatment.skillReads, { observed: 1, unobserved: 0, unknown: 0 });
258
- assert.deepEqual(result.overall.conditions.baseline.skillReads, { observed: 0, unobserved: 1, unknown: 0 });
259
- assert.equal(result.overall.conditions.baseline.trials, 1);
260
- assert.equal(existsSync(join(s.root, 'eval', 'reads', '_artifacts.json')), true);
261
- });
262
- test('calibration rejects insufficient budget before creating its run group', async (t) => {
263
- const s = setup(t);
264
- await assert.rejects(() => runBenchCheck({ dir: s.benchDir, log: () => { }, calibrate: {
265
- executor: s.executor, trials: 2, maxCalls: 1, runsRoot: join(s.root, 'calibrate')
266
- } }), /needs 2 model calls/);
267
- assert.equal(existsSync(join(s.root, 'calibrate')), false);
268
- });
269
- test('final verification backs up and reconciles the manifest when drift occurs after aggregation', t => {
270
- const s = setup(t);
271
- const session = new ExperimentSession(s.options);
272
- const result = { experiment: session.summary(), warnings: [] };
273
- const path = join(s.groupDir, 'manifest.json');
274
- const bytes = JSON.stringify(result) + '\n';
275
- writeFileSync(path, bytes);
276
- writeFileSync(join(s.benchDir, 'prompt.md'), 'late drift');
277
- session.finish(undefined, result);
278
- assert.equal(result.experiment.status, 'stopped');
279
- assert.equal(JSON.parse(readFileSync(path, 'utf8')).experiment.status, 'stopped');
280
- assert.equal(readFileSync(join(s.groupDir, '_before-finalize-manifest.json'), 'utf8'), bytes);
281
- });
282
- test('trigger delivery uses the same cap and managed receipts without real CLI calls', async (t) => {
283
- const s = setup(t);
284
- let calls = 0;
285
- const result = await runEval({ skillPath: s.skill, bench: s.benchDir, trials: 1, mode: 'trigger',
286
- agent: 'codex', dryRun: false, yes: true, runsRoot: join(s.root, 'trigger'), runGroup: 'one', maxCalls: 1, log: () => { },
287
- executor: { ...s.executor, run: async () => { calls++; return { output: 'done', skillTriggered: true }; } } });
288
- assert.ok(result && 'metrics' in result);
289
- assert.equal(calls, 1);
290
- assert.equal(result.experiment.status, 'completed');
291
- assert.equal(existsSync(join(s.root, 'trigger', 'one', '_artifacts.json')), true);
292
- });
293
- test('matrix override instructions are watched at default and overridden homes, including creation', t => {
294
- const s = setup(t);
295
- for (const redirected of [false, true])
296
- for (const present of [false, true]) {
297
- const home = join(s.root, `home-${redirected}-${present}`);
298
- const profile = redirected ? join(s.root, `profile-${present}`) : join(home, '.codex');
299
- mkdirSync(profile, { recursive: true });
300
- const override = join(profile, 'AGENTS.override.md');
301
- if (present)
302
- writeFileSync(override, 'original effective instructions\n');
303
- const session = new ExperimentSession({ ...s.options, groupDir: join(s.root, `run-${redirected}-${present}`),
304
- agent: 'codex', homeDir: home, env: redirected ? { CODEX_HOME: profile } : {} });
305
- session.check();
306
- writeFileSync(override, 'changed effective instructions\n');
307
- assert.throws(() => session.check(), /Agent configuration changed/);
308
- session.finish();
309
- }
310
- });
311
- test('an output parent alias into a fixture is rejected before any input writes', t => {
312
- const s = setup(t);
313
- const alias = join(s.root, 'output-alias');
314
- symlinkSync(join(s.benchDir, 'fixture'), alias);
315
- assert.throws(() => new ExperimentSession({ ...s.options, groupDir: join(alias, 'new-group') }), /output must be outside/);
316
- assert.equal(existsSync(join(s.benchDir, 'fixture', 'new-group')), false);
317
- });
@@ -1,162 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
3
- import { tmpdir } from 'node:os';
4
- import { join } from 'node:path';
5
- import { spawnSync } from 'node:child_process';
6
- import { test } from 'node:test';
7
- import { loadBench } from './bench.js';
8
- import { collectSkillBundle } from './bundle.js';
9
- import { assertInstalledSkillFixtures, collectInstalledSkillTarget, installSkillResources, validateSkillInstallDir } from './installed-skill.js';
10
- import { runExperiment } from './runner.js';
11
- import { runEval } from '../commands/eval.js';
12
- import { parseEvalReport, renderEvalMarkdown } from '../commands/eval-report.js';
13
- import { getAgent } from '../agents.js';
14
- function setup(t) {
15
- const root = mkdtempSync(join(tmpdir(), 'skillfit-installed-'));
16
- t.after(() => rmSync(root, { recursive: true, force: true }));
17
- const skill = join(root, 'arbitrary-source-folder');
18
- mkdirSync(join(skill, 'scripts'), { recursive: true });
19
- mkdirSync(join(skill, 'assets'));
20
- writeFileSync(join(skill, 'SKILL.md'), '---\nname: resource-demo\ndescription: Uses a bundled local calculation helper.\n---\nUse scripts/answer.cjs when relevant.\n');
21
- writeFileSync(join(skill, 'assets', 'value.bin'), Buffer.from([42, 0, 255]));
22
- writeFileSync(join(skill, 'scripts', 'answer.cjs'), "const fs=require('node:fs'); const path=require('node:path'); fs.writeFileSync('answer.txt', String(fs.readFileSync(path.join(__dirname,'../assets/value.bin'))[0]));\n");
23
- const bench = join(root, 'bench');
24
- mkdirSync(join(bench, 'fixture'), { recursive: true });
25
- writeFileSync(join(bench, 'fixture', 'answer.txt'), 'pending');
26
- writeFileSync(join(bench, 'prompt.md'), 'Compute the local answer and save it in answer.txt.');
27
- writeFileSync(join(bench, 'verify.mjs'), "import {readFileSync} from 'node:fs'; import {join} from 'node:path'; process.exit(readFileSync(join(process.argv[2],'answer.txt'),'utf8')==='42'?0:1);\n");
28
- writeFileSync(join(bench, 'bench.json'), JSON.stringify({ schemaVersion: 1, name: 'resource-fixture', tasks: [
29
- { id: 'answer', fixture: 'fixture', prompt: 'prompt.md', verifier: 'node verify.mjs', verifierKind: 'command' },
30
- ] }));
31
- return { root, skill, bench };
32
- }
33
- test('installed target fingerprints scripts and binary assets and uses manifest name', (t) => {
34
- const { skill } = setup(t);
35
- const before = collectInstalledSkillTarget(skill);
36
- const textHash = collectSkillBundle(skill).sha256;
37
- assert.equal(before.name, 'resource-demo');
38
- assert.equal(before.payload, null);
39
- assert.ok(before.files.includes('scripts/answer.cjs'));
40
- assert.ok(before.files.includes('assets/value.bin'));
41
- writeFileSync(join(skill, 'assets', 'value.bin'), Buffer.from([43, 0, 255]));
42
- assert.notEqual(collectInstalledSkillTarget(skill).sha256, before.sha256);
43
- assert.equal(collectSkillBundle(skill).sha256, textHash, 'legacy injection identity stays text-only');
44
- });
45
- test('installed Skill paths reject traversal, drive roots and Git metadata', () => {
46
- for (const dir of ['../skills', '/outside', 'C:\\outside', 'C:relative', '.git/skills', '.', '']) {
47
- assert.throws(() => validateSkillInstallDir(dir), /relative project path/);
48
- }
49
- assert.equal(validateSkillInstallDir('project\\skills'), 'project/skills');
50
- });
51
- test('installed source and destination reject symbolic links without touching their targets', (t) => {
52
- const { root, skill, bench } = setup(t);
53
- const target = collectInstalledSkillTarget(skill);
54
- const outside = join(root, 'outside');
55
- mkdirSync(outside);
56
- symlinkSync(outside, join(bench, 'fixture', 'project-skills'), 'junction');
57
- assert.throws(() => assertInstalledSkillFixtures(loadBench(bench), target, 'project-skills'), /symbolic links/);
58
- assert.deepEqual(readFileSync(join(skill, 'assets', 'value.bin')), Buffer.from([42, 0, 255]));
59
- symlinkSync(outside, join(skill, 'linked-resource'), 'junction');
60
- assert.throws(() => collectInstalledSkillTarget(skill), /Symbolic links/);
61
- });
62
- test('installation rejects source drift and existing target directories', (t) => {
63
- const { root, skill } = setup(t);
64
- const target = collectInstalledSkillTarget(skill);
65
- mkdirSync(join(root, 'trial'));
66
- writeFileSync(join(skill, 'scripts', 'answer.cjs'), 'changed');
67
- assert.throws(() => installSkillResources(target, join(root, 'trial'), 'project-skills'), /changed after planning/);
68
- assert.ok(!existsSync(join(root, 'trial', 'project-skills')));
69
- const current = collectInstalledSkillTarget(skill);
70
- mkdirSync(join(root, 'trial', 'project-skills', current.name), { recursive: true });
71
- assert.throws(() => installSkillResources(current, join(root, 'trial'), 'project-skills'), /overwrite/);
72
- });
73
- test('paired installed delivery preserves prompts, executes copied resources and retains receipts', async (t) => {
74
- const { root, skill, bench } = setup(t);
75
- const prompts = [];
76
- const executor = {
77
- describe: () => ({ kind: 'mock', model: 'offline-resource-probe' }),
78
- run: async (prompt, workdir) => {
79
- prompts.push(prompt);
80
- const helper = join(workdir, 'project-skills', 'resource-demo', 'scripts', 'answer.cjs');
81
- if (existsSync(helper)) {
82
- const result = spawnSync(process.execPath, [helper], { cwd: workdir, encoding: 'utf8' });
83
- assert.equal(result.status, 0, result.stderr);
84
- }
85
- return { output: 'done', rawOutput: '{"offline":true}\n', ...(existsSync(helper) ? { skillTriggered: true } : {}) };
86
- },
87
- };
88
- const manifest = await runExperiment({ bench: loadBench(bench), target: collectInstalledSkillTarget(skill),
89
- executor, inputMode: 'workspace', skillInstallDir: 'project-skills', trials: 1, runsRoot: root, runGroup: 'pair' });
90
- assert.deepEqual(prompts, [prompts[0], prompts[0]]);
91
- assert.ok(!prompts[0]?.includes('Use scripts/answer.cjs'));
92
- assert.equal(manifest.overall.conditions.baseline.passes, 0);
93
- assert.equal(manifest.overall.conditions.treatment.passes, 1);
94
- assert.deepEqual(manifest.skillDelivery, { mode: 'installed', installDir: 'project-skills' });
95
- const baseline = join(root, 'pair', 'answer', 'baseline', 'trial-1');
96
- const treatment = join(root, 'pair', 'answer', 'treatment', 'trial-1');
97
- assert.ok(!existsSync(join(baseline, 'project-skills')));
98
- assert.deepEqual(readFileSync(join(treatment, 'project-skills', 'resource-demo', 'assets', 'value.bin')), Buffer.from([42, 0, 255]));
99
- assert.equal(JSON.parse(readFileSync(join(baseline, '_result.json'), 'utf8')).skillTriggered, null);
100
- assert.equal(JSON.parse(readFileSync(join(treatment, '_result.json'), 'utf8')).skillTriggered, true);
101
- assert.equal(readFileSync(join(treatment, '_transcript.jsonl'), 'utf8'), '{"offline":true}\n');
102
- const report = renderEvalMarkdown(parseEvalReport(manifest));
103
- assert.match(report, /Delivery: complete Skill installed in treatment/);
104
- assert.match(report, /Synthetic harness run/);
105
- assert.ok(!report.includes('Skill content was force-injected'));
106
- const cliReport = renderEvalMarkdown(parseEvalReport({ ...manifest, executor: { kind: 'cli', model: 'offline-report-fixture' } }));
107
- assert.match(cliReport, /Complete Skill resources were installed/);
108
- assert.ok(!cliReport.includes('Skill content was force-injected'));
109
- const invalid = structuredClone(manifest);
110
- invalid.skillDelivery.installDir = '../outside';
111
- assert.throws(() => parseEvalReport(invalid), /relative project path/);
112
- });
113
- test('installed dry run uses matrix location and writes nothing', async (t) => {
114
- const { root, skill, bench } = setup(t);
115
- const lines = [];
116
- const executor = { describe: () => ({ kind: 'mock', model: 'offline' }), run: async () => { throw new Error('must not run'); } };
117
- await runEval({ skillPath: skill, bench, agent: 'codex', mode: 'installed', dryRun: true, yes: true,
118
- executor, runsRoot: join(root, 'runs'), log: (line) => lines.push(line) });
119
- assert.ok(!existsSync(join(root, 'runs')));
120
- assert.match(lines.join('\n'), /complete Skill resources installed only in treatment/);
121
- assert.match(lines.join('\n'), /workspace files on disk/);
122
- await assert.rejects(runEval({ skillPath: skill, bench, agent: 'codex', mode: 'installed', inputMode: 'snapshot',
123
- dryRun: true, yes: true, executor, log: () => { } }), /requires workspace/);
124
- const api = { describe: () => ({ kind: 'api', model: 'offline' }), run: async () => { throw new Error('must not run'); } };
125
- await assert.rejects(runEval({ skillPath: skill, bench, agent: 'codex', mode: 'installed', dryRun: true,
126
- yes: true, executor: api, log: () => { } }), /filesystem access|workspace input/);
127
- });
128
- test('fixture contamination blocks all calls at plan time', async (t) => {
129
- const { root, skill, bench } = setup(t);
130
- mkdirSync(join(bench, 'fixture', 'project-skills', 'resource-demo'), { recursive: true });
131
- let calls = 0;
132
- const executor = { describe: () => ({ kind: 'mock', model: 'offline' }), run: async () => { calls++; return { output: '' }; } };
133
- await assert.rejects(runExperiment({ bench: loadBench(bench), target: collectInstalledSkillTarget(skill),
134
- executor, inputMode: 'workspace', skillInstallDir: 'project-skills', trials: 1, runsRoot: root, runGroup: 'blocked' }), /baseline contamination/);
135
- assert.equal(calls, 0);
136
- assert.ok(!existsSync(join(root, 'blocked')));
137
- });
138
- test('installed mode rejects contamination in every matrix project search path before calls', async (t) => {
139
- const { root, skill, bench } = setup(t);
140
- const [primary, alternate] = getAgent('kimi-code').skills.projectDirs;
141
- assert.ok(primary && alternate && primary !== alternate);
142
- mkdirSync(join(bench, 'fixture', alternate, 'resource-demo'), { recursive: true });
143
- let calls = 0;
144
- const executor = { describe: () => ({ kind: 'mock', model: 'offline' }), run: async () => { calls++; return { output: 'done' }; } };
145
- for (const dryRun of [true, false]) {
146
- await assert.rejects(runEval({ skillPath: skill, bench, agent: 'kimi-code', mode: 'installed', dryRun,
147
- yes: true, executor, runsRoot: join(root, 'runs'), log: () => { } }), /baseline contamination/);
148
- }
149
- assert.equal(calls, 0);
150
- assert.ok(!existsSync(join(root, 'runs')));
151
- });
152
- test('programmatic installed runner rejects alternate project paths too', async (t) => {
153
- const { root, skill, bench } = setup(t);
154
- mkdirSync(join(bench, 'fixture', 'alternate-skills', 'resource-demo'), { recursive: true });
155
- let calls = 0;
156
- const executor = { describe: () => ({ kind: 'mock', model: 'offline' }), run: async () => { calls++; return { output: '' }; } };
157
- await assert.rejects(runExperiment({ bench: loadBench(bench), target: collectInstalledSkillTarget(skill),
158
- executor, inputMode: 'workspace', skillInstallDir: 'project-skills', skillSearchDirs: ['alternate-skills'],
159
- trials: 1, runsRoot: root, runGroup: 'blocked' }), /baseline contamination/);
160
- assert.equal(calls, 0);
161
- assert.ok(!existsSync(join(root, 'blocked')));
162
- });
@@ -1,31 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { test } from 'node:test';
3
- import { evaluationSignal, withEvaluationInterrupts } from './interruption.js';
4
- const counts = () => [process.listenerCount('SIGINT'), process.listenerCount('SIGTERM')];
5
- test('normal and failed operations restore signal handlers and asynchronous context', async () => {
6
- const before = counts();
7
- assert.equal(evaluationSignal(), undefined);
8
- assert.equal(await withEvaluationInterrupts(async () => {
9
- assert.ok(evaluationSignal());
10
- await Promise.resolve();
11
- assert.ok(evaluationSignal());
12
- return 'done';
13
- }), 'done');
14
- assert.deepEqual(counts(), before);
15
- assert.equal(evaluationSignal(), undefined);
16
- await assert.rejects(withEvaluationInterrupts(async () => { throw new Error('offline setup failed'); }), /offline setup failed/);
17
- assert.deepEqual(counts(), before);
18
- assert.equal(evaluationSignal(), undefined);
19
- });
20
- test('concurrent operations keep distinct cancellation contexts and clean up all handlers', async () => {
21
- const before = counts();
22
- const signals = await Promise.all([1, 2].map(() => withEvaluationInterrupts(async () => {
23
- const signal = evaluationSignal();
24
- await new Promise(resolve => setImmediate(resolve));
25
- assert.equal(evaluationSignal(), signal);
26
- return signal;
27
- })));
28
- assert.notEqual(signals[0], signals[1]);
29
- assert.deepEqual(counts(), before);
30
- assert.equal(evaluationSignal(), undefined);
31
- });