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,463 +1,13 @@
1
1
  import { readFileSync, statSync } from 'node:fs';
2
+ import { readEvaluationReport } from './evaluation-report.js';
2
3
  import { agentEnvironmentReportLines } from '../harness/agent-preflight.js';
3
4
  import { renderSingleArmReport } from './eval-single-arm-report.js';
4
- import { CONCLUSIVE_TASKS, CONCLUSIVE_TRIALS, formatP, formatPp1, verdictFor } from '../harness/report.js';
5
- import { mcnemarExactP } from '../harness/stats.js';
6
- import { validateSkillInstallDir } from '../harness/installed-skill.js';
7
- import { assertCostTotals, COST_METRICS, renderCostLines } from '../harness/costs.js';
8
- import { parseInvocationCosts, renderInvocationCostLines } from '../harness/invocation-costs.js';
5
+ import { CONCLUSIVE_TASKS, CONCLUSIVE_TRIALS, formatP, formatPp1 } from '../harness/report.js';
6
+ import { renderCostLines } from '../harness/costs.js';
7
+ import { renderInvocationCostLines } from '../harness/invocation-costs.js';
8
+ import { parseEvalReport } from '../harness/eval-manifest.js';
9
+ export { parseEvalReport } from '../harness/eval-manifest.js';
9
10
  const MAX_MANIFEST_BYTES = 16 * 1024 * 1024;
10
- function object(value, label) {
11
- if (typeof value !== 'object' || value === null || Array.isArray(value)) {
12
- throw new Error(`${label} must be an object`);
13
- }
14
- return value;
15
- }
16
- function string(value, label) {
17
- if (typeof value !== 'string' || value.trim() === '')
18
- throw new Error(`${label} must be a non-empty string`);
19
- return value;
20
- }
21
- function number(value, label, min = -Infinity, max = Infinity) {
22
- if (typeof value !== 'number' || !Number.isFinite(value) || value < min || value > max) {
23
- throw new Error(`${label} must be a finite number between ${min} and ${max}`);
24
- }
25
- return value;
26
- }
27
- function integer(value, label, min = 0) {
28
- const result = number(value, label, min);
29
- if (!Number.isInteger(result))
30
- throw new Error(`${label} must be an integer`);
31
- return result;
32
- }
33
- function hash(value, label) {
34
- const result = string(value, label);
35
- if (!/^[0-9a-f]{64}$/i.test(result))
36
- throw new Error(`${label} must be a SHA-256 hex digest`);
37
- return result;
38
- }
39
- function verdict(value, label) {
40
- if (value !== 'effective' && value !== 'ineffective' && value !== 'inconclusive') {
41
- throw new Error(`${label} must be effective, ineffective, or inconclusive`);
42
- }
43
- return value;
44
- }
45
- function experiment(value) {
46
- if (value === undefined)
47
- return null;
48
- const item = object(value, 'experiment');
49
- if (item['schemaVersion'] !== 1)
50
- throw new Error('experiment.schemaVersion must be 1');
51
- const status = item['status'];
52
- if (status !== 'completed' && status !== 'stopped' && status !== 'incomplete')
53
- throw new Error('experiment.status must be completed, stopped, or incomplete');
54
- const plannedCalls = integer(item['plannedCalls'], 'experiment.plannedCalls', 1);
55
- const maxCalls = integer(item['maxCalls'], 'experiment.maxCalls', 1);
56
- const callsStarted = integer(item['callsStarted'], 'experiment.callsStarted');
57
- const callsFinished = integer(item['callsFinished'], 'experiment.callsFinished');
58
- const stopReason = item['stopReason'] === null ? null : string(item['stopReason'], 'experiment.stopReason');
59
- if (item['stopCode'] !== undefined && !['EXECUTION_FAILED', 'FINAL_USAGE_MISSING', 'SPENDING_BUDGET_REACHED'].includes(String(item['stopCode'])))
60
- throw new Error('Invalid experiment.stopCode');
61
- if (![plannedCalls, maxCalls, callsStarted, callsFinished].every(Number.isSafeInteger) ||
62
- maxCalls < plannedCalls || callsStarted > plannedCalls || callsFinished > callsStarted ||
63
- (status === 'completed' && (stopReason !== null || callsFinished !== plannedCalls)) ||
64
- (status === 'stopped' && stopReason === null) ||
65
- (status === 'incomplete' && (stopReason !== null || callsFinished === plannedCalls))) {
66
- throw new Error('experiment status, call counts, ceiling, and stop reason contradict each other');
67
- }
68
- return { schemaVersion: 1, status, plannedCalls, maxCalls, callsStarted, callsFinished, stopReason,
69
- planSha256: hash(item['planSha256'], 'experiment.planSha256'),
70
- ...(item['stopCode'] === undefined ? {} : { stopCode: item['stopCode'] }) };
71
- }
72
- function counts(value, label) {
73
- const item = object(value, label);
74
- const passes = integer(item['passes'], `${label}.passes`);
75
- const trials = integer(item['trials'], `${label}.trials`);
76
- const errors = integer(item['errors'], `${label}.errors`);
77
- if (passes > trials)
78
- throw new Error(`${label}.passes cannot exceed trials`);
79
- const meanScore = item['meanScore'] === undefined || item['meanScore'] === null
80
- ? null : number(item['meanScore'], `${label}.meanScore`, 0, 1);
81
- const rawTokens = item['tokens'] === undefined || item['tokens'] === null
82
- ? null : object(item['tokens'], `${label}.tokens`);
83
- const tokens = rawTokens === null ? null : {
84
- input: number(rawTokens['input'], `${label}.tokens.input`, 0),
85
- output: number(rawTokens['output'], `${label}.tokens.output`, 0),
86
- };
87
- const rawCoverage = item['tokenCoverage'] === undefined
88
- ? null : object(item['tokenCoverage'], `${label}.tokenCoverage`);
89
- const tokenCoverage = rawCoverage === null ? null : {
90
- input: integer(rawCoverage['input'], `${label}.tokenCoverage.input`),
91
- output: integer(rawCoverage['output'], `${label}.tokenCoverage.output`),
92
- };
93
- if (tokenCoverage && (tokenCoverage.input > trials || tokenCoverage.output > trials)) {
94
- throw new Error(`${label}.tokenCoverage cannot exceed graded trials`);
95
- }
96
- if (tokenCoverage) {
97
- for (const field of ['input', 'output']) {
98
- if ((tokenCoverage[field] > 0 && tokens === null) ||
99
- (tokenCoverage[field] === 0 && tokens !== null && tokens[field] !== 0)) {
100
- throw new Error(`${label}.tokenCoverage contradicts its recorded tokens`);
101
- }
102
- }
103
- }
104
- if (meanScore !== null && trials === 0)
105
- throw new Error(`${label}.meanScore requires graded trials`);
106
- const rawReads = item['skillReads'] === undefined ? null : object(item['skillReads'], `${label}.skillReads`);
107
- const skillReads = rawReads === null ? null : {
108
- observed: integer(rawReads['observed'], `${label}.skillReads.observed`),
109
- unobserved: integer(rawReads['unobserved'], `${label}.skillReads.unobserved`),
110
- unknown: integer(rawReads['unknown'], `${label}.skillReads.unknown`),
111
- };
112
- if (skillReads && skillReads.observed + skillReads.unobserved + skillReads.unknown !== trials) {
113
- throw new Error(`${label}.skillReads must total the surviving graded trials`);
114
- }
115
- return { passes, trials, errors, meanScore, tokens, tokenCoverage, skillReads };
116
- }
117
- function facets(value, label) {
118
- if (value === undefined)
119
- return [];
120
- if (!Array.isArray(value))
121
- throw new Error(`${label} must be an array`);
122
- return value.map((raw, index) => {
123
- const item = object(raw, `${label}[${index}]`);
124
- return {
125
- name: string(item['name'], `${label}[${index}].name`),
126
- baselinePassRate: number(item['baselinePassRate'], `${label}[${index}].baselinePassRate`, 0, 1),
127
- treatmentPassRate: number(item['treatmentPassRate'], `${label}[${index}].treatmentPassRate`, 0, 1),
128
- baselineTrials: integer(item['baselineTrials'], `${label}[${index}].baselineTrials`),
129
- treatmentTrials: integer(item['treatmentTrials'], `${label}[${index}].treatmentTrials`),
130
- };
131
- });
132
- }
133
- function row(value, label, id) {
134
- const item = object(value, label);
135
- const conditions = object(item['conditions'], `${label}.conditions`);
136
- return {
137
- costs: item['costs'] === undefined ? null : parseCosts(item['costs'], `${label}.costs`),
138
- id,
139
- baseline: counts(conditions['baseline'], `${label}.conditions.baseline`),
140
- treatment: counts(conditions['treatment'], `${label}.conditions.treatment`),
141
- deltaPassRate: number(item['deltaPassRate'], `${label}.deltaPassRate`, -1, 1),
142
- verdict: verdict(item['verdict'], `${label}.verdict`),
143
- scoreDelta: item['scoreDelta'] === undefined || item['scoreDelta'] === null
144
- ? null : number(item['scoreDelta'], `${label}.scoreDelta`, -1, 1),
145
- facets: facets(item['facets'], `${label}.facets`),
146
- };
147
- }
148
- function parseCosts(value, label) {
149
- const item = object(value, label);
150
- if (item['schemaVersion'] !== 1)
151
- throw new Error(`${label}.schemaVersion must be 1`);
152
- const scope = (name) => {
153
- const arms = object(item[name], `${label}.${name}`);
154
- const population = (arm) => {
155
- const path = `${label}.${name}.${arm}`;
156
- const raw = object(arms[arm], path);
157
- const runs = integer(raw['runs'], `${path}.runs`);
158
- const passes = integer(raw['passes'], `${path}.passes`);
159
- if (passes > runs)
160
- throw new Error(`${path}.passes cannot exceed runs`);
161
- const rawMetrics = object(raw['metrics'], `${path}.metrics`);
162
- const metrics = Object.fromEntries(COST_METRICS.map(metric => {
163
- const measure = object(rawMetrics[metric], `${path}.metrics.${metric}`);
164
- const coverage = object(measure['coverage'], `${path}.metrics.${metric}.coverage`);
165
- const parsed = {
166
- knownTotal: number(measure['knownTotal'], `${path}.metrics.${metric}.knownTotal`, 0),
167
- coverage: {
168
- final: integer(coverage['final'], `${path}.metrics.${metric}.coverage.final`),
169
- partial: integer(coverage['partial'], `${path}.metrics.${metric}.coverage.partial`),
170
- unknown: integer(coverage['unknown'], `${path}.metrics.${metric}.coverage.unknown`),
171
- },
172
- };
173
- const c = parsed.coverage;
174
- if (c.final + c.partial + c.unknown !== runs ||
175
- (c.final + c.partial === 0 && parsed.knownTotal !== 0))
176
- throw new Error(`${path}.metrics.${metric} contradicts coverage`);
177
- if (metric === 'durationSeconds' && (c.partial !== 0 || c.unknown !== 0))
178
- throw new Error(`${path} elapsed time must cover every invocation`);
179
- return [metric, parsed];
180
- }));
181
- const cache = metrics.cachedInput;
182
- const uncached = metrics.uncachedInput;
183
- if (JSON.stringify(cache.coverage) !== JSON.stringify(uncached.coverage))
184
- throw new Error(`${path} cache partition coverage must match`);
185
- if (cache.coverage.final + cache.coverage.partial > metrics.input.coverage.final + metrics.input.coverage.partial ||
186
- cache.coverage.final > metrics.input.coverage.final ||
187
- cache.knownTotal + uncached.knownTotal > metrics.input.knownTotal + 1e-6)
188
- throw new Error(`${path} cache partition contradicts input`);
189
- if (cache.coverage.final + cache.coverage.partial === metrics.input.coverage.final + metrics.input.coverage.partial &&
190
- Math.abs(cache.knownTotal + uncached.knownTotal - metrics.input.knownTotal) > 1e-6)
191
- throw new Error(`${path} cache partition disagrees with input`);
192
- return { runs, passes, metrics };
193
- };
194
- return { baseline: population('baseline'), treatment: population('treatment') };
195
- };
196
- const notInvoked = object(item['notInvoked'], `${label}.notInvoked`);
197
- return { schemaVersion: 1, paired: scope('paired'), attempts: scope('attempts'), notInvoked: {
198
- baseline: integer(notInvoked['baseline'], `${label}.notInvoked.baseline`),
199
- treatment: integer(notInvoked['treatment'], `${label}.notInvoked.treatment`),
200
- } };
201
- }
202
- function checkCostCounts(row, declaredRuns, label) {
203
- const costs = row.costs;
204
- if (!costs)
205
- return;
206
- for (const arm of ['baseline', 'treatment']) {
207
- const paired = costs.paired[arm];
208
- const attempts = costs.attempts[arm];
209
- if (paired.runs !== row[arm].trials || paired.passes !== row[arm].passes ||
210
- attempts.runs + costs.notInvoked[arm] !== declaredRuns ||
211
- paired.runs > attempts.runs || paired.passes > attempts.passes ||
212
- attempts.passes - paired.passes > attempts.runs - paired.runs)
213
- throw new Error(`${label}.costs disagree with declared/graded counts`);
214
- for (const metric of COST_METRICS) {
215
- if (paired.metrics[metric].knownTotal > attempts.metrics[metric].knownTotal + 1e-6)
216
- throw new Error(`${label}.costs paired spending exceeds all invocations`);
217
- for (const status of ['final', 'partial', 'unknown']) {
218
- if (paired.metrics[metric].coverage[status] > attempts.metrics[metric].coverage[status])
219
- throw new Error(`${label}.costs paired coverage exceeds all invocations`);
220
- }
221
- }
222
- }
223
- }
224
- function checkDelta(value, label) {
225
- if (value.baseline.trials !== value.treatment.trials) {
226
- throw new Error(`${label} must contain equal numbers of graded paired trials`);
227
- }
228
- const seen = new Set();
229
- for (const facet of value.facets) {
230
- if (seen.has(facet.name))
231
- throw new Error(`${label}.facets contains a duplicate check name`);
232
- seen.add(facet.name);
233
- for (const condition of ['baseline', 'treatment']) {
234
- const trials = condition === 'baseline' ? facet.baselineTrials : facet.treatmentTrials;
235
- const rate = condition === 'baseline' ? facet.baselinePassRate : facet.treatmentPassRate;
236
- if (trials > value[condition].trials || (trials === 0 && rate !== 0) ||
237
- Math.abs(rate * trials - Math.round(rate * trials)) > 1e-9) {
238
- throw new Error(`${label}.facets has an invalid ${condition} check denominator or rate`);
239
- }
240
- }
241
- }
242
- const rate = (counts) => counts.trials === 0 ? 0 : counts.passes / counts.trials;
243
- const expected = rate(value.treatment) - rate(value.baseline);
244
- if (Math.abs(value.deltaPassRate - expected) > 1e-9) {
245
- throw new Error(`${label}.deltaPassRate disagrees with its pass counts`);
246
- }
247
- if (value.baseline.meanScore !== null && value.treatment.meanScore !== null &&
248
- value.scoreDelta !== null && Math.abs(value.scoreDelta -
249
- (value.treatment.meanScore - value.baseline.meanScore)) > 1e-9 && label !== 'overall') {
250
- throw new Error(`${label}.scoreDelta disagrees with its mean scores`);
251
- }
252
- if (value.scoreDelta !== null && (value.baseline.meanScore === null || value.treatment.meanScore === null)) {
253
- throw new Error(`${label}.scoreDelta requires graded scores in both conditions`);
254
- }
255
- }
256
- /** Read only the v4 fields the Markdown report actually uses. Never reinterpret older metrics. */
257
- export function parseEvalReport(value) {
258
- const manifest = object(value, 'Manifest');
259
- if (manifest['schemaVersion'] !== 4) {
260
- throw new Error(`Only evaluation manifest schemaVersion 4 can be rendered (found ${JSON.stringify(manifest['schemaVersion'])})`);
261
- }
262
- const target = object(manifest['target'], 'target');
263
- const kind = string(target['kind'], 'target.kind');
264
- if (!['skill', 'rules', 'mcp'].includes(kind))
265
- throw new Error('target.kind must be skill, rules, or mcp');
266
- const bench = object(manifest['bench'], 'bench');
267
- const executor = object(manifest['executor'], 'executor');
268
- const inputMode = manifest['inputMode'];
269
- if (inputMode !== undefined && inputMode !== 'snapshot' && inputMode !== 'workspace') {
270
- throw new Error('inputMode must be snapshot or workspace');
271
- }
272
- let skillDelivery = null;
273
- if (manifest['skillDelivery'] !== undefined) {
274
- const delivery = object(manifest['skillDelivery'], 'skillDelivery');
275
- if (delivery['mode'] !== 'installed' || kind !== 'skill' || inputMode !== 'workspace') {
276
- throw new Error('skillDelivery requires installed mode, a Skill target and workspace input');
277
- }
278
- const installDir = string(delivery['installDir'], 'skillDelivery.installDir');
279
- validateSkillInstallDir(installDir);
280
- if (!Array.isArray(target['files']) || !target['files'].includes('SKILL.md') ||
281
- target['files'].some((file) => typeof file !== 'string' || !file)) {
282
- throw new Error('Installed Skill target.files must list the complete resources including SKILL.md');
283
- }
284
- skillDelivery = { mode: 'installed', installDir };
285
- }
286
- let baselineTarget = null;
287
- if (manifest['baselineTarget'] !== undefined) {
288
- const previous = object(manifest['baselineTarget'], 'baselineTarget');
289
- if (!skillDelivery || previous['kind'] !== 'skill') {
290
- throw new Error('baselineTarget requires two installed Skill versions.');
291
- }
292
- const name = string(previous['name'], 'baselineTarget.name');
293
- if (name !== target['name'])
294
- throw new Error('baselineTarget.name must match the target Skill name.');
295
- const sha256 = hash(previous['bundleSha256'], 'baselineTarget.bundleSha256');
296
- if (sha256.toLowerCase() === hash(target['bundleSha256'], 'target.bundleSha256').toLowerCase()) {
297
- throw new Error('baselineTarget and target must have different complete-resource fingerprints.');
298
- }
299
- string(previous['sourceDir'], 'baselineTarget.sourceDir');
300
- if (!Array.isArray(previous['files']) || !previous['files'].includes('SKILL.md') ||
301
- previous['files'].some(file => typeof file !== 'string' || !file)) {
302
- throw new Error('baselineTarget.files must list the complete resources including SKILL.md.');
303
- }
304
- baselineTarget = { name, sha256 };
305
- }
306
- const rawTasks = manifest['tasks'];
307
- if (!Array.isArray(rawTasks))
308
- throw new Error('tasks must be an array');
309
- const tasks = rawTasks.map((task, index) => {
310
- const item = object(task, `tasks[${index}]`);
311
- return row(item, `tasks[${index}]`, string(item['id'], `tasks[${index}].id`));
312
- });
313
- const overall = object(manifest['overall'], 'overall');
314
- const stats = object(overall['stats'], 'overall.stats');
315
- const discordant = object(stats['discordant'], 'overall.stats.discordant');
316
- const rawCi = stats['deltaCi'];
317
- const ci = rawCi === null ? null : object(rawCi, 'overall.stats.deltaCi');
318
- const warnings = manifest['warnings'];
319
- if (!Array.isArray(warnings) || warnings.some((item) => typeof item !== 'string')) {
320
- throw new Error('warnings must be an array of strings');
321
- }
322
- const createdAt = string(manifest['createdAt'], 'createdAt');
323
- if (!Number.isFinite(Date.parse(createdAt)))
324
- throw new Error('createdAt must be a date-time');
325
- const taskCount = integer(bench['taskCount'], 'bench.taskCount');
326
- if (tasks.length !== taskCount)
327
- throw new Error('bench.taskCount must match tasks.length');
328
- const ciValue = ci === null ? null : {
329
- lo: number(ci['lo'], 'overall.stats.deltaCi.lo', -1, 1),
330
- hi: number(ci['hi'], 'overall.stats.deltaCi.hi', -1, 1),
331
- resamples: integer(ci['resamples'], 'overall.stats.deltaCi.resamples', 1),
332
- };
333
- if (ciValue && ciValue.lo > ciValue.hi)
334
- throw new Error('overall.stats.deltaCi.lo cannot exceed hi');
335
- const rawScoreCi = stats['scoreDeltaCi'];
336
- const scoreCi = rawScoreCi === undefined || rawScoreCi === null ? null
337
- : object(rawScoreCi, 'overall.stats.scoreDeltaCi');
338
- const scoreDeltaCi = scoreCi === null ? null : {
339
- lo: number(scoreCi['lo'], 'overall.stats.scoreDeltaCi.lo', -1, 1),
340
- hi: number(scoreCi['hi'], 'overall.stats.scoreDeltaCi.hi', -1, 1),
341
- resamples: integer(scoreCi['resamples'], 'overall.stats.scoreDeltaCi.resamples', 1),
342
- };
343
- if (scoreDeltaCi && scoreDeltaCi.lo > scoreDeltaCi.hi)
344
- throw new Error('overall.stats.scoreDeltaCi.lo cannot exceed hi');
345
- const overallRow = row(overall, 'overall', 'Overall');
346
- const declaredTrials = integer(manifest['trials'], 'trials', 1);
347
- for (const [index, task] of tasks.entries())
348
- checkCostCounts(task, declaredTrials, `tasks[${index}]`);
349
- checkCostCounts(overallRow, declaredTrials * tasks.length, 'overall');
350
- if (overallRow.costs) {
351
- if (tasks.some(t => !t.costs))
352
- throw new Error('overall.costs requires costs for every task');
353
- assertCostTotals(overallRow.costs, tasks.map(t => t.costs));
354
- }
355
- else if (tasks.some(t => t.costs))
356
- throw new Error('Task costs require corresponding overall costs');
357
- for (const [index, task] of tasks.entries())
358
- checkDelta(task, `tasks[${index}]`);
359
- checkDelta(overallRow, 'overall');
360
- if (scoreDeltaCi) {
361
- if (overallRow.scoreDelta === null || overallRow.baseline.meanScore === null ||
362
- overallRow.treatment.meanScore === null || !tasks.some(t => t.baseline.trials > 0 && t.baseline.meanScore !== null &&
363
- t.treatment.meanScore !== null && t.scoreDelta !== null)) {
364
- throw new Error('overall.stats.scoreDeltaCi requires paired graded score observations and overall scoreDelta');
365
- }
366
- if (scoreCi['point'] !== undefined && Math.abs(number(scoreCi['point'], 'overall.stats.scoreDeltaCi.point', -1, 1) - overallRow.scoreDelta) > 1e-9) {
367
- throw new Error('overall.stats.scoreDeltaCi.point disagrees with overall.scoreDelta');
368
- }
369
- }
370
- for (const condition of ['baseline', 'treatment']) {
371
- for (const field of ['passes', 'trials', 'errors']) {
372
- const total = tasks.reduce((sum, task) => sum + task[condition][field], 0);
373
- if (total !== overallRow[condition][field]) {
374
- throw new Error(`overall.conditions.${condition}.${field} disagrees with task totals`);
375
- }
376
- }
377
- const aggregate = overallRow[condition];
378
- if (aggregate.skillReads) {
379
- if (!skillDelivery || tasks.some(t => t[condition].skillReads === null))
380
- throw new Error('skillReads requires installed delivery and recorded observations for every task');
381
- for (const field of ['observed', 'unobserved', 'unknown']) {
382
- if (aggregate.skillReads[field] !== tasks.reduce((sum, t) => sum + t[condition].skillReads[field], 0)) {
383
- throw new Error(`overall.conditions.${condition}.skillReads.${field} disagrees with task totals`);
384
- }
385
- }
386
- }
387
- else if (tasks.some(t => t[condition].skillReads !== null))
388
- throw new Error('Task skillReads requires corresponding overall observations');
389
- if (aggregate.tokenCoverage) {
390
- if (tasks.some(t => t[condition].tokenCoverage === null)) {
391
- throw new Error(`overall.conditions.${condition}.tokenCoverage requires recorded coverage for every task`);
392
- }
393
- for (const field of ['input', 'output']) {
394
- const coverage = tasks.reduce((sum, t) => sum + t[condition].tokenCoverage[field], 0);
395
- if (coverage !== aggregate.tokenCoverage[field]) {
396
- throw new Error(`overall.conditions.${condition}.tokenCoverage.${field} disagrees with task totals`);
397
- }
398
- const total = tasks.reduce((sum, t) => sum + (t[condition].tokens?.[field] ?? 0), 0);
399
- if (total !== (aggregate.tokens?.[field] ?? 0)) {
400
- throw new Error(`overall.conditions.${condition}.tokens.${field} disagrees with task totals`);
401
- }
402
- }
403
- }
404
- }
405
- const improved = integer(discordant['improved'], 'overall.stats.discordant.improved');
406
- const regressed = integer(discordant['regressed'], 'overall.stats.discordant.regressed');
407
- if (improved + regressed > overallRow.baseline.trials) {
408
- throw new Error('overall.stats.discordant exceeds the number of paired trials');
409
- }
410
- if (improved - regressed !== overallRow.treatment.passes - overallRow.baseline.passes) {
411
- throw new Error('overall.stats.discordant.improved - regressed disagrees with treatment.passes - baseline.passes');
412
- }
413
- const sharedSuccess = overallRow.baseline.passes - regressed;
414
- if (sharedSuccess < 0) {
415
- throw new Error('overall.stats.discordant implies a negative shared success count');
416
- }
417
- const sharedFailure = overallRow.baseline.trials - improved - regressed - sharedSuccess;
418
- if (sharedFailure < 0) {
419
- throw new Error('overall.stats.discordant implies a negative shared failure count');
420
- }
421
- const mcnemarP = number(stats['mcnemarP'], 'overall.stats.mcnemarP', 0, 1);
422
- if (Math.abs(mcnemarP - mcnemarExactP(improved, regressed)) > 1e-9) {
423
- throw new Error('overall.stats.mcnemarP disagrees with discordant counts');
424
- }
425
- const expectedVerdict = verdictFor({ improved, regressed, deltaPassRate: overallRow.deltaPassRate }).verdict;
426
- if (overallRow.verdict !== expectedVerdict)
427
- throw new Error('overall.verdict disagrees with the metrics protocol');
428
- const managed = experiment(manifest['experiment']);
429
- if (managed && managed.plannedCalls !== taskCount * integer(manifest['trials'], 'trials', 1) * (manifest['judge'] == null ? 2 : 4)) {
430
- throw new Error('experiment.plannedCalls contradicts the declared tasks, trials, conditions, and judge');
431
- }
432
- return {
433
- runGroup: string(manifest['runGroup'], 'runGroup'),
434
- ...(manifest['invocationCosts'] === undefined ? {} : { invocationCosts: parseInvocationCosts(manifest['invocationCosts']) }),
435
- createdAt,
436
- target: { kind, name: string(target['name'], 'target.name'), sha256: hash(target['bundleSha256'], 'target.bundleSha256') },
437
- baselineTarget,
438
- bench: {
439
- name: string(bench['name'], 'bench.name'),
440
- sha256: hash(bench['contentSha256'], 'bench.contentSha256'),
441
- taskCount,
442
- },
443
- executor: { kind: string(executor['kind'], 'executor.kind'), model: string(executor['model'], 'executor.model') },
444
- trials: integer(manifest['trials'], 'trials', 1),
445
- inputMode: inputMode ?? null,
446
- skillDelivery,
447
- experiment: managed,
448
- tasks,
449
- overall: {
450
- ...overallRow,
451
- verdictReason: string(overall['verdictReason'], 'overall.verdictReason'),
452
- improved,
453
- regressed,
454
- mcnemarP,
455
- deltaCi: ciValue,
456
- scoreDeltaCi,
457
- },
458
- warnings: warnings,
459
- };
460
- }
461
11
  function escapeMarkdown(value) {
462
12
  return value.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
463
13
  .replaceAll('\\', '\\\\').replaceAll('`', '\\`').replaceAll('*', '\\*')
@@ -602,9 +152,6 @@ export function renderEvalMarkdown(report) {
602
152
  return lines.join('\n');
603
153
  }
604
154
  export async function runEvalReport(inputPath, log = console.log, options = {}) {
605
- // Import after module initialization: component assessment itself uses this
606
- // module's manifest parser. Both CLI formats must share the same assessment.
607
- const { readEvaluationReport } = await import('./evaluation-report.js');
608
155
  const result = await readEvaluationReport(inputPath, options);
609
156
  if ('evaluationType' in result) {
610
157
  log(renderSingleArmReport(result));
@@ -1,9 +1,9 @@
1
- import { existsSync, readdirSync, statSync } from 'node:fs';
1
+ import { existsSync, statSync } from 'node:fs';
2
2
  import { homedir } from 'node:os';
3
3
  import { join, resolve } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
4
  import { getAgent } from '../agents.js';
6
5
  import { loadBench, selectBenchTasks } from '../harness/bench.js';
6
+ import { resolveBenchDir } from '../harness/bench-location.js';
7
7
  import { RUN_GROUP_PATTERN } from '../harness/constants.js';
8
8
  import { ExperimentSession, validateCallBudget } from '../harness/experiment-session.js';
9
9
  import { ApiExecutor, DEFAULT_API_TIMEOUT_MS } from '../harness/executors/api.js';
@@ -23,38 +23,9 @@ import { parseSpendingBudget } from '../harness/eval-budget.js';
23
23
  import { withEvaluationInterrupts, throwIfEvaluationInterrupted } from '../harness/interruption.js';
24
24
  import { CASE_PREFLIGHT_POLICY, checkEvalCases } from './eval-preflight.js';
25
25
  import { INPUT_SNAPSHOT_POLICY } from '../harness/input-snapshot.js';
26
+ import { assertEvaluationOutputLayout } from '../harness/evaluation-layout.js';
26
27
  import { inspectAgentEnvironment, assertAgentEnvironment, assertAgentEnvironmentUnchanged, renderAgentEnvironment } from '../harness/agent-preflight.js';
27
28
  export const DEFAULT_EVAL_TRIALS = 5;
28
- function bundledBenchesRoot() {
29
- return fileURLToPath(new URL('../../benches', import.meta.url));
30
- }
31
- function resolveBenchDir(bench) {
32
- const root = bundledBenchesRoot();
33
- const candidates = existsSync(root)
34
- ? readdirSync(root)
35
- .map((entry) => join(root, entry))
36
- .filter((dir) => statSync(dir).isDirectory() && existsSync(join(dir, 'bench.json')))
37
- : [];
38
- if (bench) {
39
- const dir = resolve(bench);
40
- if (existsSync(join(dir, 'bench.json'))) {
41
- return dir;
42
- }
43
- const byName = candidates.find((candidate) => candidate.split(/[\\/]/).pop() === bench);
44
- if (byName) {
45
- return byName;
46
- }
47
- throw new Error(`Not a bench directory (missing bench.json): ${dir}`);
48
- }
49
- if (candidates.length === 1 && candidates[0]) {
50
- return candidates[0];
51
- }
52
- if (candidates.length === 0) {
53
- throw new Error(`No bundled benches found under ${root}; pass --bench <path>`);
54
- }
55
- const names = candidates.map((dir) => ` --bench ${dir.split(/[\\/]/).pop() ?? dir}`).join('\n');
56
- throw new Error(`More than one bundled bench is available; pick one explicitly:\n${names}`);
57
- }
58
29
  function resolveExecutor(agent, target, installed = false, executorTimeoutSeconds) {
59
30
  if (agent) {
60
31
  const definition = getAgent(agent);
@@ -113,6 +84,7 @@ function inspectEvalAgent(options, target, executor, judge, capabilityError, res
113
84
  roles.push({ role: 'judge', definition: options.judgeAgent ? getAgent(options.judgeAgent) : undefined,
114
85
  executor: judge?.describe() ?? null, injected: options.judgeExecutor != null, resolutionError: judgeError });
115
86
  return inspectAgentEnvironment({ roles, mode: options.mode ?? 'inject', target, capabilityError,
87
+ spendingBudget: options.spendingBudget !== undefined,
116
88
  homeDir: options.sessionOptions?.homeDir, env: options.sessionOptions?.env });
117
89
  }
118
90
  function sessionFor(options, bench, target, trials, runsRoot, runGroup, armNames, plannedCalls, details, baselineTarget) {
@@ -242,6 +214,7 @@ async function runEvalTrigger(options, bench, skill, trials, log) {
242
214
  const agentPreflight = inspect();
243
215
  if (!RUN_GROUP_PATTERN.test(runGroup))
244
216
  throw new Error(`Invalid run group: ${runGroup}`);
217
+ assertEvaluationOutputLayout(join(runsRoot, runGroup), { benchDir: bench.dir, targetDirs: [skill.sourceDir] });
245
218
  const competitors = options.competeInstalled && options.agent
246
219
  ? installedUserSkills(getAgent(options.agent), options.sessionOptions?.homeDir ?? homedir(), options.sessionOptions?.env ?? process.env)
247
220
  .filter((entry) => entry.name !== skill.name)
@@ -445,6 +418,8 @@ export async function runEval(options) {
445
418
  const pairOrder = parsePairOrder(options.pairOrder);
446
419
  if (!RUN_GROUP_PATTERN.test(runGroup))
447
420
  throw new Error(`Invalid run group: ${runGroup}`);
421
+ assertEvaluationOutputLayout(join(runsRoot, runGroup), { benchDir: bench.dir,
422
+ targetDirs: [target.sourceDir, ...(baselineTarget ? [baselineTarget.sourceDir] : [])] });
448
423
  options.onPlan?.({
449
424
  mode: installed ? 'installed' : 'inject',
450
425
  agentPreflight,