skillfit 0.12.0 → 0.13.1

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 (147) 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/first-real-eval.md +12 -10
  22. package/docs/growth-roadmap-2026-10.md +17 -18
  23. package/docs/package-contents.md +80 -0
  24. package/docs/plans/2026-10-20-archive-replay-verification.json +125 -0
  25. package/docs/plans/2026-10-20-archive-source-verification.json +256 -0
  26. package/docs/plans/2026-10-20-delivery-verification.json +146 -0
  27. package/docs/plans/2026-10-20-docs-architecture-cleanup.md +233 -0
  28. package/docs/plans/2026-10-20-install-transactions-and-archive-delivery.md +233 -0
  29. package/docs/plans/2026-10-21-npm-0.13.0-release.md +74 -0
  30. package/docs/plans/2026-10-21-npm-0.13.1-release.md +38 -0
  31. package/docs/releases/0.12.0-attestation-check.json +22 -0
  32. package/docs/releases/0.12.0-attestations.json +155 -0
  33. package/docs/releases/0.12.0-ci-registry-install.json +90 -0
  34. package/docs/releases/0.12.0-feature-smoke.json +34 -0
  35. package/docs/releases/0.12.0-foundations-smoke.json +1576 -0
  36. package/docs/releases/0.12.0-local-registry-install.json +75 -0
  37. package/docs/releases/0.12.0-preparation-attempt-1.json +22 -0
  38. package/docs/releases/0.12.0-registry-metadata.json +96 -0
  39. package/docs/releases/0.12.0-signatures.txt +6 -0
  40. package/docs/releases/0.12.0-verification.json +99 -0
  41. package/docs/releases/0.12.0.md +14 -0
  42. package/docs/releases/0.13.0-archive-replays.json +266 -0
  43. package/docs/releases/0.13.0-archive-restoration.json +168 -0
  44. package/docs/releases/0.13.0-attestation-check.json +22 -0
  45. package/docs/releases/0.13.0-attestations.json +147 -0
  46. package/docs/releases/0.13.0-ci-registry-install.json +60 -0
  47. package/docs/releases/0.13.0-feature-smoke.json +41 -0
  48. package/docs/releases/0.13.0-feature-smoke.mjs +114 -0
  49. package/docs/releases/0.13.0-foundations-smoke.json +1576 -0
  50. package/docs/releases/0.13.0-local-registry-install.json +40 -0
  51. package/docs/releases/0.13.0-preparation.json +102 -0
  52. package/docs/releases/0.13.0-preview-review.json +16 -0
  53. package/docs/releases/0.13.0-registry-metadata.json +92 -0
  54. package/docs/releases/0.13.0-signatures.txt +12 -0
  55. package/docs/releases/0.13.0-verification.json +136 -0
  56. package/docs/releases/0.13.0.md +112 -0
  57. package/docs/releases/0.13.1-feature-smoke.mjs +116 -0
  58. package/docs/releases/0.13.1-preparation-failure-1.json +25 -0
  59. package/docs/releases/0.13.1-preparation.json +149 -0
  60. package/docs/releases/0.13.1.md +62 -0
  61. package/docs/releases/archive-delivery-smoke.mjs +37 -0
  62. package/docs/releases/release-docs-smoke.mjs +37 -0
  63. package/docs/reproducible-offline-example.md +1 -1
  64. package/evidence/README.md +24 -1
  65. package/evidence/archive-catalog.v1.json +8044 -0
  66. package/evidence/fetch-archives.mjs +211 -0
  67. package/package.json +9 -2
  68. package/skills/skillfit/SKILL.md +20 -6
  69. package/dist/cli.test.js +0 -193
  70. package/dist/commands/bench-calibration.test.js +0 -237
  71. package/dist/commands/bench-check-json.test.js +0 -242
  72. package/dist/commands/bench-manage.test.js +0 -87
  73. package/dist/commands/bench.test.js +0 -1166
  74. package/dist/commands/bundle.test.js +0 -142
  75. package/dist/commands/calibration-cli.test.js +0 -145
  76. package/dist/commands/doctor.test.js +0 -280
  77. package/dist/commands/eval-agent-preflight.test.js +0 -269
  78. package/dist/commands/eval-cli-usage.test.js +0 -75
  79. package/dist/commands/eval-export-modes.test.js +0 -350
  80. package/dist/commands/eval-export.test.js +0 -279
  81. package/dist/commands/eval-interruption.test.js +0 -263
  82. package/dist/commands/eval-preflight.test.js +0 -382
  83. package/dist/commands/eval-report.test.js +0 -367
  84. package/dist/commands/eval.test.js +0 -503
  85. package/dist/commands/evaluation-report.test.js +0 -243
  86. package/dist/commands/install.test.js +0 -555
  87. package/dist/commands/npm-first-run.test.js +0 -74
  88. package/dist/commands/replay-cancellation.test.js +0 -105
  89. package/dist/commands/report.test.js +0 -110
  90. package/dist/commands/setup.test.js +0 -150
  91. package/dist/commands/upstream.test.js +0 -139
  92. package/dist/commands/workflow-entrypoints.test.js +0 -137
  93. package/dist/docs.test.js +0 -154
  94. package/dist/frontmatter.test.js +0 -49
  95. package/dist/harness/bench.test.js +0 -109
  96. package/dist/harness/bundle.test.js +0 -71
  97. package/dist/harness/codex-usage.test.js +0 -87
  98. package/dist/harness/costs.test.js +0 -92
  99. package/dist/harness/eval-budget.test.js +0 -237
  100. package/dist/harness/eval-component.test.js +0 -770
  101. package/dist/harness/eval-efficiency.test.js +0 -56
  102. package/dist/harness/execution-timing.test.js +0 -61
  103. package/dist/harness/executors/api.test.js +0 -175
  104. package/dist/harness/executors/cli.test.js +0 -541
  105. package/dist/harness/executors/mock.test.js +0 -43
  106. package/dist/harness/experiment-session.test.js +0 -317
  107. package/dist/harness/installed-skill.test.js +0 -162
  108. package/dist/harness/interruption.test.js +0 -31
  109. package/dist/harness/judge-accounting.test.js +0 -216
  110. package/dist/harness/judge.test.js +0 -181
  111. package/dist/harness/kimi-usage.test.js +0 -62
  112. package/dist/harness/native-diff.test.js +0 -53
  113. package/dist/harness/oss-lru-cache.test.js +0 -79
  114. package/dist/harness/oss-normalize-url.test.js +0 -64
  115. package/dist/harness/oss-regression-witness.test.js +0 -89
  116. package/dist/harness/oss-skill-followup.test.js +0 -59
  117. package/dist/harness/prompt.test.js +0 -48
  118. package/dist/harness/receipts.test.js +0 -148
  119. package/dist/harness/report.test.js +0 -297
  120. package/dist/harness/runner.test.js +0 -635
  121. package/dist/harness/skill-revision.test.js +0 -148
  122. package/dist/harness/stats.test.js +0 -124
  123. package/dist/harness/target.test.js +0 -60
  124. package/dist/harness/trigger.test.js +0 -261
  125. package/dist/harness/verifier-summary.test.js +0 -99
  126. package/dist/harness/verifier.test.js +0 -128
  127. package/dist/harness/waza-behavior.test.js +0 -139
  128. package/dist/mcp/probe.test.js +0 -139
  129. package/evidence/artifacts/2026-10-12-diagnosing-revision/calibration-records.tar.gz +0 -0
  130. package/evidence/artifacts/2026-10-12-diagnosing-revision/interrupted-records.tar.gz +0 -0
  131. package/evidence/artifacts/2026-10-12-diagnosing-revision/validation-records.tar.gz +0 -0
  132. package/evidence/artifacts/2026-10-12-diagnosing-v2/regression-records.tar.gz +0 -0
  133. package/evidence/artifacts/2026-10-12-diagnosing-v2/transfer-records.tar.gz +0 -0
  134. package/evidence/artifacts/2026-10-12-normalize-url-v2-available/readiness-records.tar.gz +0 -0
  135. package/evidence/artifacts/2026-10-12-normalize-url-v2-comparison/records.tar.gz +0 -0
  136. package/evidence/artifacts/2026-10-12-normalize-url-v2-recovery/records.tar.gz +0 -0
  137. package/evidence/artifacts/2026-10-12-normalize-url-v2-validated/records.tar.gz +0 -0
  138. package/evidence/artifacts/2026-10-13-debugging-completed-development/package.tar.gz +0 -0
  139. package/evidence/artifacts/2026-10-13-debugging-controls-and-sleep-stop/package.tar.gz +0 -0
  140. package/evidence/artifacts/2026-10-13-debugging-development-stops/package.tar.gz +0 -0
  141. package/evidence/artifacts/2026-10-14-debugging-followup-routing-stop/package.tar.gz +0 -0
  142. package/evidence/artifacts/2026-10-14-debugging-independent-validation/package.tar.gz +0 -0
  143. package/evidence/artifacts/2026-10-14-debugging-reading-pilot-and-cost-review/package.tar.gz +0 -0
  144. package/evidence/artifacts/2026-10-14-debugging-spending-stop/package.tar.gz +0 -0
  145. package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
  146. package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
  147. 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
- });