evalsense 0.3.0 → 0.3.2
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.
- package/README.md +89 -66
- package/dist/{chunk-DFC6FRTG.cjs → chunk-BFGA2NUB.cjs} +67 -8
- package/dist/chunk-BFGA2NUB.cjs.map +1 -0
- package/dist/{chunk-JPVZL45G.js → chunk-IYLSY7NX.js} +67 -8
- package/dist/chunk-IYLSY7NX.js.map +1 -0
- package/dist/cli.cjs +11 -11
- package/dist/cli.js +1 -1
- package/dist/index.cjs +101 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +23 -55
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-DFC6FRTG.cjs.map +0 -1
- package/dist/chunk-JPVZL45G.js.map +0 -1
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
**evalsense** brings classical ML-style statistical evaluation to LLM systems in JavaScript. Instead of evaluating individual test cases, evalsense evaluates entire datasets and computes confusion matrices, precision/recall, F1 scores, and other statistical metrics.
|
|
9
9
|
|
|
10
|
+
> **New in v0.3.2:** Enhanced assertion reporting - all assertions (passed and failed) now display expected vs actual values, and chained assertions evaluate completely instead of short-circuiting on first failure!
|
|
10
11
|
> **New in v0.3.0:** Regression assertions (MAE, RMSE, R²) and flexible ID matching for custom identifier fields! [See migration guide](./docs/migration-v0.3.0.md).
|
|
11
12
|
> **New in v0.2.x:** Built-in adapters for OpenAI, Anthropic, and OpenRouter - no boilerplate needed!
|
|
12
13
|
> **New in v0.2.0:** LLM-powered metrics for hallucination, relevance, faithfulness, and toxicity detection. [See migration guide](./docs/migration-v0.2.md).
|
|
@@ -49,30 +50,30 @@ yarn add -D evalsense
|
|
|
49
50
|
Create a file named `sentiment.eval.js`:
|
|
50
51
|
|
|
51
52
|
```javascript
|
|
52
|
-
import { describe, evalTest, expectStats
|
|
53
|
+
import { describe, evalTest, expectStats } from "evalsense";
|
|
54
|
+
import { readFileSync } from "fs";
|
|
53
55
|
|
|
54
56
|
// Your model function - can be any JS function
|
|
55
|
-
function classifySentiment(
|
|
56
|
-
const
|
|
57
|
-
const hasPositive = /love|amazing|great|fantastic|perfect/.test(
|
|
58
|
-
const hasNegative = /terrible|worst|disappointed|waste/.test(
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
id: record.id,
|
|
62
|
-
sentiment: hasPositive && !hasNegative ? "positive" : "negative",
|
|
63
|
-
};
|
|
57
|
+
function classifySentiment(text) {
|
|
58
|
+
const lower = text.toLowerCase();
|
|
59
|
+
const hasPositive = /love|amazing|great|fantastic|perfect/.test(lower);
|
|
60
|
+
const hasNegative = /terrible|worst|disappointed|waste/.test(lower);
|
|
61
|
+
return hasPositive && !hasNegative ? "positive" : "negative";
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
describe("Sentiment classifier", () => {
|
|
67
65
|
evalTest("accuracy above 80%", async () => {
|
|
68
|
-
// 1. Load
|
|
69
|
-
const
|
|
66
|
+
// 1. Load ground truth data
|
|
67
|
+
const groundTruth = JSON.parse(readFileSync("./sentiment.json", "utf-8"));
|
|
70
68
|
|
|
71
|
-
// 2. Run your model
|
|
72
|
-
const
|
|
69
|
+
// 2. Run your model and collect predictions
|
|
70
|
+
const predictions = groundTruth.map((record) => ({
|
|
71
|
+
id: record.id,
|
|
72
|
+
sentiment: classifySentiment(record.text),
|
|
73
|
+
}));
|
|
73
74
|
|
|
74
75
|
// 3. Assert on statistical properties
|
|
75
|
-
expectStats(
|
|
76
|
+
expectStats(predictions, groundTruth)
|
|
76
77
|
.field("sentiment")
|
|
77
78
|
.toHaveAccuracyAbove(0.8)
|
|
78
79
|
.toHaveRecallAbove("positive", 0.7)
|
|
@@ -103,18 +104,19 @@ npx evalsense run sentiment.eval.js
|
|
|
103
104
|
### Basic Classification Example
|
|
104
105
|
|
|
105
106
|
```javascript
|
|
106
|
-
import { describe, evalTest, expectStats
|
|
107
|
+
import { describe, evalTest, expectStats } from "evalsense";
|
|
108
|
+
import { readFileSync } from "fs";
|
|
107
109
|
|
|
108
110
|
describe("Spam classifier", () => {
|
|
109
111
|
evalTest("high precision and recall", async () => {
|
|
110
|
-
const
|
|
112
|
+
const groundTruth = JSON.parse(readFileSync("./emails.json", "utf-8"));
|
|
111
113
|
|
|
112
|
-
const
|
|
114
|
+
const predictions = groundTruth.map((record) => ({
|
|
113
115
|
id: record.id,
|
|
114
116
|
isSpam: classifyEmail(record.text),
|
|
115
117
|
}));
|
|
116
118
|
|
|
117
|
-
expectStats(
|
|
119
|
+
expectStats(predictions, groundTruth)
|
|
118
120
|
.field("isSpam")
|
|
119
121
|
.toHaveAccuracyAbove(0.9)
|
|
120
122
|
.toHavePrecisionAbove(true, 0.85) // Precision for spam=true
|
|
@@ -127,20 +129,21 @@ describe("Spam classifier", () => {
|
|
|
127
129
|
### Continuous Scores with Binarization
|
|
128
130
|
|
|
129
131
|
```javascript
|
|
130
|
-
import { describe, evalTest, expectStats
|
|
132
|
+
import { describe, evalTest, expectStats } from "evalsense";
|
|
133
|
+
import { readFileSync } from "fs";
|
|
131
134
|
|
|
132
135
|
describe("Hallucination detector", () => {
|
|
133
136
|
evalTest("detect hallucinations with 70% recall", async () => {
|
|
134
|
-
const
|
|
137
|
+
const groundTruth = JSON.parse(readFileSync("./outputs.json", "utf-8"));
|
|
135
138
|
|
|
136
|
-
// Your model returns a continuous score
|
|
137
|
-
const
|
|
139
|
+
// Your model returns a continuous score (0.0 to 1.0)
|
|
140
|
+
const predictions = groundTruth.map((record) => ({
|
|
138
141
|
id: record.id,
|
|
139
|
-
hallucinated: computeHallucinationScore(record.output),
|
|
142
|
+
hallucinated: computeHallucinationScore(record.output),
|
|
140
143
|
}));
|
|
141
144
|
|
|
142
145
|
// Binarize the score at threshold 0.3
|
|
143
|
-
expectStats(
|
|
146
|
+
expectStats(predictions, groundTruth)
|
|
144
147
|
.field("hallucinated")
|
|
145
148
|
.binarize(0.3) // >= 0.3 means hallucinated
|
|
146
149
|
.toHaveRecallAbove(true, 0.7)
|
|
@@ -153,18 +156,19 @@ describe("Hallucination detector", () => {
|
|
|
153
156
|
### Multi-class Classification
|
|
154
157
|
|
|
155
158
|
```javascript
|
|
156
|
-
import { describe, evalTest, expectStats
|
|
159
|
+
import { describe, evalTest, expectStats } from "evalsense";
|
|
160
|
+
import { readFileSync } from "fs";
|
|
157
161
|
|
|
158
162
|
describe("Intent classifier", () => {
|
|
159
163
|
evalTest("balanced performance across intents", async () => {
|
|
160
|
-
const
|
|
164
|
+
const groundTruth = JSON.parse(readFileSync("./intents.json", "utf-8"));
|
|
161
165
|
|
|
162
|
-
const
|
|
166
|
+
const predictions = groundTruth.map((record) => ({
|
|
163
167
|
id: record.id,
|
|
164
168
|
intent: classifyIntent(record.query),
|
|
165
169
|
}));
|
|
166
170
|
|
|
167
|
-
expectStats(
|
|
171
|
+
expectStats(predictions, groundTruth)
|
|
168
172
|
.field("intent")
|
|
169
173
|
.toHaveAccuracyAbove(0.85)
|
|
170
174
|
.toHaveRecallAbove("purchase", 0.8)
|
|
@@ -175,28 +179,39 @@ describe("Intent classifier", () => {
|
|
|
175
179
|
});
|
|
176
180
|
```
|
|
177
181
|
|
|
178
|
-
### Parallel Model Execution
|
|
182
|
+
### Parallel Model Execution with LLMs
|
|
179
183
|
|
|
180
|
-
For LLM calls or slow operations, use
|
|
184
|
+
For LLM calls or slow operations, use `Promise.all` with chunking for concurrency control:
|
|
181
185
|
|
|
182
186
|
```javascript
|
|
183
|
-
import { describe, evalTest, expectStats
|
|
187
|
+
import { describe, evalTest, expectStats } from "evalsense";
|
|
188
|
+
import { readFileSync } from "fs";
|
|
189
|
+
|
|
190
|
+
// Helper for parallel execution with concurrency limit
|
|
191
|
+
async function mapConcurrent(items, fn, concurrency = 5) {
|
|
192
|
+
const results = [];
|
|
193
|
+
for (let i = 0; i < items.length; i += concurrency) {
|
|
194
|
+
const chunk = items.slice(i, i + concurrency);
|
|
195
|
+
results.push(...(await Promise.all(chunk.map(fn))));
|
|
196
|
+
}
|
|
197
|
+
return results;
|
|
198
|
+
}
|
|
184
199
|
|
|
185
200
|
describe("LLM classifier", () => {
|
|
186
201
|
evalTest("classification accuracy", async () => {
|
|
187
|
-
const
|
|
202
|
+
const groundTruth = JSON.parse(readFileSync("./data.json", "utf-8"));
|
|
188
203
|
|
|
189
204
|
// Run with concurrency=5
|
|
190
|
-
const
|
|
191
|
-
|
|
205
|
+
const predictions = await mapConcurrent(
|
|
206
|
+
groundTruth,
|
|
192
207
|
async (record) => {
|
|
193
208
|
const response = await callLLM(record.text);
|
|
194
209
|
return { id: record.id, category: response.category };
|
|
195
210
|
},
|
|
196
|
-
5
|
|
211
|
+
5
|
|
197
212
|
);
|
|
198
213
|
|
|
199
|
-
expectStats(
|
|
214
|
+
expectStats(predictions, groundTruth).field("category").toHaveAccuracyAbove(0.9);
|
|
200
215
|
});
|
|
201
216
|
});
|
|
202
217
|
```
|
|
@@ -302,59 +317,67 @@ evalTest("should have 90% accuracy", async () => {
|
|
|
302
317
|
});
|
|
303
318
|
```
|
|
304
319
|
|
|
305
|
-
### Dataset
|
|
306
|
-
|
|
307
|
-
#### `loadDataset(path)`
|
|
320
|
+
### Dataset Loading
|
|
308
321
|
|
|
309
|
-
|
|
322
|
+
evalsense doesn't dictate how you load data or run your model. Use standard Node.js tools:
|
|
310
323
|
|
|
311
324
|
```javascript
|
|
312
|
-
|
|
313
|
-
```
|
|
325
|
+
import { readFileSync } from "fs";
|
|
314
326
|
|
|
315
|
-
|
|
327
|
+
// Load ground truth
|
|
328
|
+
const groundTruth = JSON.parse(readFileSync("./data.json", "utf-8"));
|
|
316
329
|
|
|
317
|
-
|
|
330
|
+
// Run your model however you want
|
|
331
|
+
const predictions = groundTruth.map(runYourModel);
|
|
318
332
|
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
333
|
+
// Or use async operations
|
|
334
|
+
const predictions = await Promise.all(
|
|
335
|
+
groundTruth.map(async (item) => {
|
|
336
|
+
const result = await callLLM(item.text);
|
|
337
|
+
return { id: item.id, prediction: result };
|
|
338
|
+
})
|
|
339
|
+
);
|
|
324
340
|
```
|
|
325
341
|
|
|
326
|
-
|
|
342
|
+
**Helper functions available (optional):**
|
|
327
343
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
const result = await runModelParallel(dataset, modelFn, 10); // concurrency=10
|
|
332
|
-
```
|
|
344
|
+
- `loadDataset(path)` - Simple JSON file loader
|
|
345
|
+
- `runModel(dataset, fn)` - Sequential model execution
|
|
346
|
+
- `runModelParallel(dataset, fn, concurrency)` - Parallel execution with concurrency limit
|
|
333
347
|
|
|
334
348
|
### Assertions
|
|
335
349
|
|
|
336
|
-
#### `expectStats(
|
|
350
|
+
#### `expectStats(predictions, groundTruth)`
|
|
337
351
|
|
|
338
|
-
Creates a statistical assertion chain from
|
|
352
|
+
Creates a statistical assertion chain from predictions and ground truth. Aligns by `id` field.
|
|
339
353
|
|
|
340
354
|
```javascript
|
|
341
|
-
expectStats(
|
|
355
|
+
expectStats(predictions, groundTruth)
|
|
356
|
+
.field("prediction")
|
|
357
|
+
.toHaveAccuracyAbove(0.8)
|
|
358
|
+
.toHaveF1Above(0.75)
|
|
359
|
+
.toHaveConfusionMatrix();
|
|
342
360
|
```
|
|
343
361
|
|
|
344
|
-
|
|
362
|
+
**New in v0.3.2: Enhanced Assertion Reporting**
|
|
345
363
|
|
|
346
|
-
|
|
364
|
+
- All assertions (passed and failed) now display expected vs actual values
|
|
365
|
+
- Chained assertions evaluate completely instead of short-circuiting on first failure
|
|
366
|
+
- See all metric results in a single run for better debugging
|
|
367
|
+
|
|
368
|
+
**One-argument form (distribution assertions only):**
|
|
347
369
|
|
|
348
370
|
```javascript
|
|
349
|
-
//
|
|
350
|
-
expectStats(
|
|
371
|
+
// For distribution monitoring without ground truth
|
|
372
|
+
expectStats(predictions).field("confidence").toHavePercentageAbove(0.7, 0.8);
|
|
351
373
|
```
|
|
352
374
|
|
|
353
|
-
**
|
|
375
|
+
**Common use cases:**
|
|
354
376
|
|
|
377
|
+
- Classification evaluation with ground truth
|
|
378
|
+
- Regression evaluation (MAE, RMSE, R²)
|
|
355
379
|
- Validating LLM judges against human labels
|
|
356
|
-
-
|
|
357
|
-
- Testing automated detection systems
|
|
380
|
+
- Distribution monitoring without ground truth
|
|
358
381
|
|
|
359
382
|
### Field Selection
|
|
360
383
|
|
|
@@ -63,6 +63,17 @@ var TestExecutionError = class extends EvalSenseError {
|
|
|
63
63
|
this.originalError = originalError;
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
+
var MultipleAssertionError = class extends EvalSenseError {
|
|
67
|
+
failures;
|
|
68
|
+
constructor(failures) {
|
|
69
|
+
const count = failures.length;
|
|
70
|
+
const summary = failures.map((f) => ` - ${f.message}`).join("\n");
|
|
71
|
+
super(`${count} assertion${count > 1 ? "s" : ""} failed:
|
|
72
|
+
${summary}`);
|
|
73
|
+
this.name = "MultipleAssertionError";
|
|
74
|
+
this.failures = failures;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
66
77
|
|
|
67
78
|
// src/statistics/confusion-matrix.ts
|
|
68
79
|
function buildConfusionMatrix(actual, expected) {
|
|
@@ -258,7 +269,7 @@ var ConsoleReporter = class {
|
|
|
258
269
|
*/
|
|
259
270
|
printHeader(fileCount) {
|
|
260
271
|
this.log("");
|
|
261
|
-
this.log(this.color("bold", `EvalSense v0.3.
|
|
272
|
+
this.log(this.color("bold", `EvalSense v0.3.2`));
|
|
262
273
|
this.log(this.color("dim", `Running ${fileCount} eval file(s)...`));
|
|
263
274
|
this.log("");
|
|
264
275
|
}
|
|
@@ -293,12 +304,23 @@ var ConsoleReporter = class {
|
|
|
293
304
|
for (const fm of test.fieldMetrics) {
|
|
294
305
|
this.printFieldMetrics(fm);
|
|
295
306
|
}
|
|
296
|
-
|
|
297
|
-
|
|
307
|
+
for (const fm of test.fieldMetrics) {
|
|
308
|
+
if (fm.metrics.confusionMatrix && Object.keys(fm.metrics.confusionMatrix).length > 0) {
|
|
309
|
+
this.printConfusionMatrix(fm);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (test.error) {
|
|
313
|
+
const prefix = test.status === "error" ? "Error" : "Assertion Failed";
|
|
314
|
+
this.log(this.color("red", ` ${prefix}: ${test.error.message}`));
|
|
315
|
+
this.log("");
|
|
298
316
|
}
|
|
299
317
|
for (const assertion of test.assertions) {
|
|
300
|
-
|
|
301
|
-
|
|
318
|
+
const symbol2 = assertion.passed ? this.color("green", symbols.pass) : this.color("red", symbols.fail);
|
|
319
|
+
const color = assertion.passed ? "dim" : "red";
|
|
320
|
+
this.log(this.color(color, ` ${symbol2} ${assertion.message}`));
|
|
321
|
+
if (assertion.expected !== void 0 && assertion.actual !== void 0) {
|
|
322
|
+
this.log(this.color("dim", ` Expected: ${this.formatValue(assertion.expected)}`));
|
|
323
|
+
this.log(this.color("dim", ` Actual: ${this.formatValue(assertion.actual)}`));
|
|
302
324
|
}
|
|
303
325
|
}
|
|
304
326
|
}
|
|
@@ -414,6 +436,24 @@ var ConsoleReporter = class {
|
|
|
414
436
|
}
|
|
415
437
|
return `${colors[colorName]}${text}${colors.reset}`;
|
|
416
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* Formats a value for display
|
|
441
|
+
*/
|
|
442
|
+
formatValue(value) {
|
|
443
|
+
if (typeof value === "number") {
|
|
444
|
+
if (value >= 0 && value <= 1) {
|
|
445
|
+
return `${(value * 100).toFixed(1)}%`;
|
|
446
|
+
}
|
|
447
|
+
return value.toFixed(4);
|
|
448
|
+
}
|
|
449
|
+
if (typeof value === "string") {
|
|
450
|
+
return `"${value}"`;
|
|
451
|
+
}
|
|
452
|
+
if (Array.isArray(value)) {
|
|
453
|
+
return `[${value.join(", ")}]`;
|
|
454
|
+
}
|
|
455
|
+
return String(value);
|
|
456
|
+
}
|
|
417
457
|
/**
|
|
418
458
|
* Logs a line
|
|
419
459
|
*/
|
|
@@ -663,6 +703,25 @@ async function executeTest(name, fn, timeout = 3e4) {
|
|
|
663
703
|
)
|
|
664
704
|
]);
|
|
665
705
|
const { assertions, fieldMetrics } = endTestExecution();
|
|
706
|
+
const failedAssertions = assertions.filter((a) => !a.passed);
|
|
707
|
+
if (failedAssertions.length > 0) {
|
|
708
|
+
const error = new MultipleAssertionError(
|
|
709
|
+
failedAssertions.map((a) => ({
|
|
710
|
+
message: a.message,
|
|
711
|
+
expected: a.expected,
|
|
712
|
+
actual: a.actual,
|
|
713
|
+
field: a.field
|
|
714
|
+
}))
|
|
715
|
+
);
|
|
716
|
+
return {
|
|
717
|
+
name,
|
|
718
|
+
status: "failed",
|
|
719
|
+
assertions,
|
|
720
|
+
fieldMetrics,
|
|
721
|
+
duration: Date.now() - startTime,
|
|
722
|
+
error
|
|
723
|
+
};
|
|
724
|
+
}
|
|
666
725
|
return {
|
|
667
726
|
name,
|
|
668
727
|
status: "passed",
|
|
@@ -672,7 +731,7 @@ async function executeTest(name, fn, timeout = 3e4) {
|
|
|
672
731
|
};
|
|
673
732
|
} catch (error) {
|
|
674
733
|
const { assertions, fieldMetrics } = endTestExecution();
|
|
675
|
-
if (error instanceof AssertionError) {
|
|
734
|
+
if (error instanceof AssertionError || error instanceof MultipleAssertionError) {
|
|
676
735
|
return {
|
|
677
736
|
name,
|
|
678
737
|
status: "failed",
|
|
@@ -757,5 +816,5 @@ exports.parseReport = parseReport;
|
|
|
757
816
|
exports.recordAssertion = recordAssertion;
|
|
758
817
|
exports.recordFieldMetrics = recordFieldMetrics;
|
|
759
818
|
exports.setCurrentSuite = setCurrentSuite;
|
|
760
|
-
//# sourceMappingURL=chunk-
|
|
761
|
-
//# sourceMappingURL=chunk-
|
|
819
|
+
//# sourceMappingURL=chunk-BFGA2NUB.cjs.map
|
|
820
|
+
//# sourceMappingURL=chunk-BFGA2NUB.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/errors.ts","../src/statistics/confusion-matrix.ts","../src/report/json-reporter.ts","../src/report/console-reporter.ts","../src/runner/discovery.ts","../src/core/types.ts","../src/core/context.ts","../src/runner/executor.ts"],"names":["stringify","writeFileSync","symbol","glob","path","resolve","existsSync","pathToFileURL"],"mappings":";;;;;;;;;;;;;AAIO,IAAM,cAAA,GAAN,cAA6B,KAAA,CAAM;AAAA,EACxC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,gBAAA;AAAA,EACd;AACF;AAEO,IAAM,cAAA,GAAN,cAA6B,cAAA,CAAe;AAAA,EACjC,QAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EAEhB,WAAA,CAAY,OAAA,EAAiB,QAAA,EAAoB,MAAA,EAAkB,KAAA,EAAgB;AACjF,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,gBAAA;AACZ,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAChB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF;AAEO,IAAM,YAAA,GAAN,cAA2B,cAAA,CAAe;AAAA,EAC/B,MAAA;AAAA,EAEhB,WAAA,CAAY,SAAiB,MAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AACF;AAEO,IAAM,cAAA,GAAN,cAA6B,cAAA,CAAe;AAAA,EACjC,UAAA;AAAA,EACA,YAAA;AAAA,EAEhB,WAAA,CAAY,OAAA,EAAiB,UAAA,EAAuB,YAAA,EAAyB;AAC3E,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA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sourcesContent":["/**\n * Custom error classes for EvalSense\n */\n\nexport class EvalSenseError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"EvalSenseError\";\n }\n}\n\nexport class AssertionError extends EvalSenseError {\n public readonly expected: unknown;\n public readonly actual: unknown;\n public readonly field?: string;\n\n constructor(message: string, expected?: unknown, actual?: unknown, field?: string) {\n super(message);\n this.name = \"AssertionError\";\n this.expected = expected;\n this.actual = actual;\n this.field = field;\n }\n}\n\nexport class DatasetError extends EvalSenseError {\n public readonly source?: string;\n\n constructor(message: string, source?: string) {\n super(message);\n this.name = \"DatasetError\";\n this.source = source;\n }\n}\n\nexport class IntegrityError extends EvalSenseError {\n public readonly missingIds?: string[];\n public readonly duplicateIds?: string[];\n\n constructor(message: string, missingIds?: string[], duplicateIds?: string[]) {\n super(message);\n this.name = \"IntegrityError\";\n this.missingIds = missingIds;\n this.duplicateIds = duplicateIds;\n }\n}\n\nexport class ConfigurationError extends EvalSenseError {\n constructor(message: string) {\n super(message);\n this.name = \"ConfigurationError\";\n }\n}\n\nexport class TestExecutionError extends EvalSenseError {\n public readonly testName: string;\n public readonly originalError?: Error;\n\n constructor(message: string, testName: string, originalError?: Error) {\n super(message);\n this.name = \"TestExecutionError\";\n this.testName = testName;\n this.originalError = originalError;\n }\n}\n\nexport class MultipleAssertionError extends EvalSenseError {\n public readonly failures: Array<{\n message: string;\n expected?: unknown;\n actual?: unknown;\n field?: string;\n }>;\n\n constructor(\n failures: Array<{ message: string; expected?: unknown; actual?: unknown; field?: string }>\n ) {\n const count = failures.length;\n const summary = failures.map((f) => ` - ${f.message}`).join(\"\\n\");\n super(`${count} assertion${count > 1 ? \"s\" : \"\"} failed:\\n${summary}`);\n this.name = \"MultipleAssertionError\";\n this.failures = failures;\n }\n}\n","/**\n * Confusion matrix computation\n */\n\nimport type { ConfusionMatrix } from \"../core/types.js\";\n\n/**\n * Builds a confusion matrix from actual and predicted values\n *\n * @param actual - Actual/predicted values from the model\n * @param expected - Expected/ground truth values\n * @returns ConfusionMatrix with matrix, labels, and total\n *\n * @example\n * ```ts\n * const matrix = buildConfusionMatrix(\n * [\"positive\", \"negative\", \"positive\"],\n * [\"positive\", \"positive\", \"positive\"]\n * );\n * // matrix.matrix[i][j] = count of expected[i] predicted as actual[j]\n * ```\n */\nexport function buildConfusionMatrix(actual: unknown[], expected: unknown[]): ConfusionMatrix {\n if (actual.length !== expected.length) {\n throw new Error(\n `Array length mismatch: actual has ${actual.length} elements, expected has ${expected.length}`\n );\n }\n\n // Collect all unique labels\n const labelSet = new Set<string>();\n for (const val of actual) {\n if (val !== undefined && val !== null) {\n labelSet.add(String(val));\n }\n }\n for (const val of expected) {\n if (val !== undefined && val !== null) {\n labelSet.add(String(val));\n }\n }\n\n // Sort labels for deterministic ordering\n const labels = Array.from(labelSet).sort();\n const labelIndex = new Map<string, number>();\n labels.forEach((label, idx) => labelIndex.set(label, idx));\n\n // Initialize confusion matrix with zeros\n const matrix: number[][] = labels.map(() => labels.map(() => 0));\n\n // Fill the matrix\n // Row = expected (ground truth), Column = actual (predicted)\n for (let i = 0; i < actual.length; i++) {\n const actualVal = actual[i];\n const expectedVal = expected[i];\n\n if (actualVal === undefined || actualVal === null) continue;\n if (expectedVal === undefined || expectedVal === null) continue;\n\n const actualIdx = labelIndex.get(String(actualVal));\n const expectedIdx = labelIndex.get(String(expectedVal));\n\n if (actualIdx !== undefined && expectedIdx !== undefined) {\n matrix[expectedIdx]![actualIdx]!++;\n }\n }\n\n const total = actual.filter(\n (v, i) => v !== undefined && v !== null && expected[i] !== undefined && expected[i] !== null\n ).length;\n\n return { matrix, labels, total };\n}\n\n/**\n * Gets the count from a confusion matrix for a specific cell\n */\nexport function getCount(cm: ConfusionMatrix, expectedLabel: string, actualLabel: string): number {\n const expectedIdx = cm.labels.indexOf(expectedLabel);\n const actualIdx = cm.labels.indexOf(actualLabel);\n\n if (expectedIdx === -1 || actualIdx === -1) {\n return 0;\n }\n\n return cm.matrix[expectedIdx]?.[actualIdx] ?? 0;\n}\n\n/**\n * Gets true positives for a class\n */\nexport function getTruePositives(cm: ConfusionMatrix, label: string): number {\n return getCount(cm, label, label);\n}\n\n/**\n * Gets false positives for a class (predicted as class but wasn't)\n */\nexport function getFalsePositives(cm: ConfusionMatrix, label: string): number {\n const labelIdx = cm.labels.indexOf(label);\n if (labelIdx === -1) return 0;\n\n let fp = 0;\n for (let i = 0; i < cm.labels.length; i++) {\n if (i !== labelIdx) {\n fp += cm.matrix[i]?.[labelIdx] ?? 0;\n }\n }\n return fp;\n}\n\n/**\n * Gets false negatives for a class (was class but predicted as something else)\n */\nexport function getFalseNegatives(cm: ConfusionMatrix, label: string): number {\n const labelIdx = cm.labels.indexOf(label);\n if (labelIdx === -1) return 0;\n\n let fn = 0;\n for (let j = 0; j < cm.labels.length; j++) {\n if (j !== labelIdx) {\n fn += cm.matrix[labelIdx]?.[j] ?? 0;\n }\n }\n return fn;\n}\n\n/**\n * Gets true negatives for a class\n */\nexport function getTrueNegatives(cm: ConfusionMatrix, label: string): number {\n const labelIdx = cm.labels.indexOf(label);\n if (labelIdx === -1) return 0;\n\n let tn = 0;\n for (let i = 0; i < cm.labels.length; i++) {\n for (let j = 0; j < cm.labels.length; j++) {\n if (i !== labelIdx && j !== labelIdx) {\n tn += cm.matrix[i]?.[j] ?? 0;\n }\n }\n }\n return tn;\n}\n\n/**\n * Gets support (total instances) for a class in ground truth\n */\nexport function getSupport(cm: ConfusionMatrix, label: string): number {\n const labelIdx = cm.labels.indexOf(label);\n if (labelIdx === -1) return 0;\n\n let support = 0;\n for (let j = 0; j < cm.labels.length; j++) {\n support += cm.matrix[labelIdx]?.[j] ?? 0;\n }\n return support;\n}\n\n/**\n * Formats a confusion matrix as a string table\n */\nexport function formatConfusionMatrix(cm: ConfusionMatrix): string {\n const maxLabelLen = Math.max(...cm.labels.map((l) => l.length), 8);\n const colWidth = Math.max(...cm.matrix.flat().map((n) => String(n).length), maxLabelLen);\n\n const header = \" \".repeat(maxLabelLen + 2) + cm.labels.map((l) => l.padStart(colWidth)).join(\" \");\n\n const rows = cm.labels.map((label, i) => {\n const rowData = cm.matrix[i]!.map((n) => String(n).padStart(colWidth)).join(\" \");\n return label.padEnd(maxLabelLen) + \" \" + rowData;\n });\n\n return [header, ...rows].join(\"\\n\");\n}\n","/**\n * JSON Reporter - deterministic JSON output\n */\n\nimport { writeFileSync } from \"node:fs\";\nimport stringify from \"fast-json-stable-stringify\";\nimport type { EvalReport } from \"../core/types.js\";\n\n/**\n * JSON Reporter for machine-readable output\n */\nexport class JsonReporter {\n /**\n * Formats a report as deterministic JSON\n */\n format(report: EvalReport): string {\n // Create a serializable version of the report\n const serializable = this.toSerializable(report);\n return stringify(serializable) ?? \"{}\";\n }\n\n /**\n * Writes report to a file\n */\n writeToFile(report: EvalReport, path: string): void {\n const json = this.format(report);\n writeFileSync(path, json, \"utf-8\");\n }\n\n /**\n * Converts report to a JSON-serializable format\n */\n private toSerializable(report: EvalReport): Record<string, unknown> {\n return {\n version: report.version,\n timestamp: report.timestamp,\n summary: report.summary,\n suites: report.suites.map((suite) => ({\n name: suite.name,\n passed: suite.passed,\n failed: suite.failed,\n errors: suite.errors,\n skipped: suite.skipped,\n duration: suite.duration,\n tests: suite.tests.map((test) => ({\n name: test.name,\n status: test.status,\n duration: test.duration,\n error: test.error\n ? {\n name: test.error.name,\n message: test.error.message,\n }\n : undefined,\n assertions: test.assertions.map((a) => ({\n type: a.type,\n passed: a.passed,\n message: a.message,\n expected: a.expected,\n actual: a.actual,\n field: a.field,\n class: a.class,\n })),\n fieldMetrics: test.fieldMetrics.map((fm) => ({\n field: fm.field,\n binarized: fm.binarized,\n binarizeThreshold: fm.binarizeThreshold,\n metrics: {\n accuracy: fm.metrics.accuracy,\n perClass: fm.metrics.perClass,\n macroAvg: fm.metrics.macroAvg,\n weightedAvg: fm.metrics.weightedAvg,\n confusionMatrix: {\n labels: fm.metrics.confusionMatrix.labels,\n matrix: fm.metrics.confusionMatrix.matrix,\n total: fm.metrics.confusionMatrix.total,\n },\n },\n })),\n })),\n })),\n integrity: report.integrity,\n };\n }\n}\n\n/**\n * Parses a JSON report back into an EvalReport\n */\nexport function parseReport(json: string): EvalReport {\n const data = JSON.parse(json) as EvalReport;\n return data;\n}\n","/**\n * Console Reporter - human-readable output\n */\n\nimport type { EvalReport, TestResult, FieldMetricResult } from \"../core/types.js\";\nimport { formatConfusionMatrix } from \"../statistics/confusion-matrix.js\";\n\n/**\n * ANSI color codes\n */\nconst colors = {\n reset: \"\\x1b[0m\",\n bold: \"\\x1b[1m\",\n dim: \"\\x1b[2m\",\n red: \"\\x1b[31m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n blue: \"\\x1b[34m\",\n cyan: \"\\x1b[36m\",\n gray: \"\\x1b[90m\",\n};\n\n/**\n * Status symbols\n */\nconst symbols = {\n pass: \"\\u2713\", // ✓\n fail: \"\\u2717\", // ✗\n error: \"!\",\n skip: \"-\",\n};\n\n/**\n * Console reporter for human-readable output\n */\nexport class ConsoleReporter {\n private useColors: boolean;\n\n constructor(useColors = true) {\n this.useColors = useColors && process.stdout.isTTY !== false;\n }\n\n /**\n * Prints the run header\n */\n printHeader(fileCount: number): void {\n this.log(\"\");\n this.log(this.color(\"bold\", `EvalSense v0.3.2`));\n this.log(this.color(\"dim\", `Running ${fileCount} eval file(s)...`));\n this.log(\"\");\n }\n\n /**\n * Prints the full report\n */\n printReport(report: EvalReport): void {\n // Print each suite\n for (const suite of report.suites) {\n this.printSuite(suite.name, suite.tests);\n }\n\n // Print summary\n this.printSummary(report);\n }\n\n /**\n * Prints a suite's results\n */\n private printSuite(name: string, tests: TestResult[]): void {\n this.log(this.color(\"bold\", ` ${name}`));\n this.log(\"\");\n\n for (const test of tests) {\n this.printTest(test);\n }\n\n this.log(\"\");\n }\n\n /**\n * Prints a single test result\n */\n private printTest(test: TestResult): void {\n const symbol = this.getStatusSymbol(test.status);\n const statusColor = this.getStatusColor(test.status);\n const duration = this.color(\"dim\", `(${test.duration}ms)`);\n\n this.log(` ${this.color(statusColor, symbol)} ${test.name} ${duration}`);\n\n // Print field metrics\n for (const fm of test.fieldMetrics) {\n this.printFieldMetrics(fm);\n }\n\n // Print confusion matrices if requested\n for (const fm of test.fieldMetrics) {\n if (fm.metrics.confusionMatrix && Object.keys(fm.metrics.confusionMatrix).length > 0) {\n this.printConfusionMatrix(fm);\n }\n }\n\n // Print error message (for both errors and assertion failures)\n if (test.error) {\n const prefix = test.status === \"error\" ? \"Error\" : \"Assertion Failed\";\n this.log(this.color(\"red\", ` ${prefix}: ${test.error.message}`));\n this.log(\"\");\n }\n\n // Print all assertions with actual vs expected\n for (const assertion of test.assertions) {\n const symbol = assertion.passed\n ? this.color(\"green\", symbols.pass)\n : this.color(\"red\", symbols.fail);\n const color = assertion.passed ? \"dim\" : \"red\";\n\n this.log(this.color(color, ` ${symbol} ${assertion.message}`));\n\n // Show expected/actual values for all assertions (pass and fail)\n if (assertion.expected !== undefined && assertion.actual !== undefined) {\n this.log(this.color(\"dim\", ` Expected: ${this.formatValue(assertion.expected)}`));\n this.log(this.color(\"dim\", ` Actual: ${this.formatValue(assertion.actual)}`));\n }\n }\n }\n\n /**\n * Prints field metrics summary\n */\n private printFieldMetrics(fm: FieldMetricResult): void {\n const { metrics, field, binarized, binarizeThreshold } = fm;\n\n const fieldLabel = binarized ? `${field} (binarized @ ${binarizeThreshold})` : field;\n\n this.log(\n this.color(\n \"cyan\",\n ` Field: ${fieldLabel} | Accuracy: ${this.pct(metrics.accuracy)} | F1: ${this.pct(metrics.macroAvg.f1)}`\n )\n );\n\n // Show per-class metrics if multiple classes\n if (Object.keys(metrics.perClass).length > 1) {\n for (const [cls, classMetrics] of Object.entries(metrics.perClass)) {\n this.log(\n this.color(\n \"dim\",\n ` ${cls}: P=${this.pct(classMetrics.precision)} R=${this.pct(classMetrics.recall)} F1=${this.pct(classMetrics.f1)} (n=${classMetrics.support})`\n )\n );\n }\n }\n }\n\n /**\n * Prints the summary\n */\n private printSummary(report: EvalReport): void {\n const { summary } = report;\n\n this.log(this.color(\"bold\", \" Summary\"));\n this.log(\"\");\n\n const passedStr = this.color(\"green\", `${summary.passed} passed`);\n const failedStr =\n summary.failed > 0\n ? this.color(\"red\", `${summary.failed} failed`)\n : `${summary.failed} failed`;\n const errorsStr =\n summary.errors > 0\n ? this.color(\"red\", `${summary.errors} errors`)\n : `${summary.errors} errors`;\n const skippedStr =\n summary.skipped > 0\n ? this.color(\"yellow\", `${summary.skipped} skipped`)\n : `${summary.skipped} skipped`;\n\n this.log(` Tests: ${passedStr}, ${failedStr}, ${errorsStr}, ${skippedStr}`);\n this.log(` Suites: ${summary.totalSuites}`);\n this.log(` Duration: ${this.formatDuration(summary.duration)}`);\n this.log(\"\");\n\n // Final status\n if (summary.failed === 0 && summary.errors === 0) {\n this.log(this.color(\"green\", \" All tests passed!\"));\n } else {\n this.log(this.color(\"red\", \" Some tests failed.\"));\n }\n\n this.log(\"\");\n }\n\n /**\n * Prints a confusion matrix\n */\n printConfusionMatrix(fm: FieldMetricResult): void {\n this.log(\"\");\n this.log(this.color(\"bold\", ` Confusion Matrix: ${fm.field}`));\n this.log(\"\");\n\n const matrixStr = formatConfusionMatrix(fm.metrics.confusionMatrix);\n for (const line of matrixStr.split(\"\\n\")) {\n this.log(` ${line}`);\n }\n\n this.log(\"\");\n }\n\n /**\n * Formats a percentage\n */\n private pct(value: number): string {\n return `${(value * 100).toFixed(1)}%`;\n }\n\n /**\n * Formats duration\n */\n private formatDuration(ms: number): string {\n if (ms < 1000) {\n return `${ms}ms`;\n }\n return `${(ms / 1000).toFixed(2)}s`;\n }\n\n /**\n * Gets status symbol\n */\n private getStatusSymbol(status: TestResult[\"status\"]): string {\n switch (status) {\n case \"passed\":\n return symbols.pass;\n case \"failed\":\n return symbols.fail;\n case \"error\":\n return symbols.error;\n case \"skipped\":\n return symbols.skip;\n }\n }\n\n /**\n * Gets status color\n */\n private getStatusColor(status: TestResult[\"status\"]): keyof typeof colors {\n switch (status) {\n case \"passed\":\n return \"green\";\n case \"failed\":\n return \"red\";\n case \"error\":\n return \"red\";\n case \"skipped\":\n return \"yellow\";\n }\n }\n\n /**\n * Applies color if enabled\n */\n private color(colorName: keyof typeof colors, text: string): string {\n if (!this.useColors) {\n return text;\n }\n return `${colors[colorName]}${text}${colors.reset}`;\n }\n\n /**\n * Formats a value for display\n */\n private formatValue(value: unknown): string {\n if (typeof value === \"number\") {\n // Format numbers as percentages if between 0 and 1\n if (value >= 0 && value <= 1) {\n return `${(value * 100).toFixed(1)}%`;\n }\n return value.toFixed(4);\n }\n if (typeof value === \"string\") {\n return `\"${value}\"`;\n }\n if (Array.isArray(value)) {\n return `[${value.join(\", \")}]`;\n }\n return String(value);\n }\n\n /**\n * Logs a line\n */\n private log(message: string): void {\n console.log(message);\n }\n}\n","/**\n * Test file discovery - finds *.eval.js files\n */\n\nimport { glob } from \"glob\";\nimport { resolve, dirname } from \"node:path\";\nimport { existsSync } from \"node:fs\";\n\n/**\n * Default patterns for eval files\n */\nexport const DEFAULT_PATTERNS = [\"**/*.eval.js\", \"**/*.eval.ts\", \"**/*.eval.mjs\"];\n\n/**\n * Patterns to ignore\n */\nexport const DEFAULT_IGNORE = [\"**/node_modules/**\", \"**/dist/**\", \"**/build/**\", \"**/.git/**\"];\n\n/**\n * Options for file discovery\n */\nexport interface DiscoveryOptions {\n /** Patterns to match (default: *.eval.{js,ts,mjs}) */\n patterns?: string[];\n /** Patterns to ignore */\n ignore?: string[];\n /** Base directory to search from */\n cwd?: string;\n /** Filter pattern for test names */\n filter?: string;\n}\n\n/**\n * Discovers eval files matching the patterns\n *\n * @param options - Discovery options\n * @returns Array of absolute file paths\n */\nexport async function discoverEvalFiles(options: DiscoveryOptions = {}): Promise<string[]> {\n const { patterns = DEFAULT_PATTERNS, ignore = DEFAULT_IGNORE, cwd = process.cwd() } = options;\n\n const files: string[] = [];\n\n for (const pattern of patterns) {\n const matches = await glob(pattern, {\n cwd,\n ignore,\n absolute: true,\n nodir: true,\n });\n files.push(...matches);\n }\n\n // Remove duplicates and sort\n const unique = [...new Set(files)].sort();\n\n return unique;\n}\n\n/**\n * Discovers eval files from a specific path (file or directory)\n */\nexport async function discoverFromPath(\n path: string,\n options: DiscoveryOptions = {}\n): Promise<string[]> {\n const absolutePath = resolve(process.cwd(), path);\n\n if (!existsSync(absolutePath)) {\n throw new Error(`Path does not exist: ${path}`);\n }\n\n // Check if it's a file\n const { statSync } = await import(\"node:fs\");\n const stat = statSync(absolutePath);\n\n if (stat.isFile()) {\n // Single file\n return [absolutePath];\n }\n\n // Directory - discover within it\n return discoverEvalFiles({\n ...options,\n cwd: absolutePath,\n });\n}\n\n/**\n * Filters file paths by a pattern\n */\nexport function filterFiles(files: string[], filter?: string): string[] {\n if (!filter) {\n return files;\n }\n\n const filterLower = filter.toLowerCase();\n return files.filter((file) => file.toLowerCase().includes(filterLower));\n}\n\n/**\n * Groups files by their directory\n */\nexport function groupByDirectory(files: string[]): Map<string, string[]> {\n const groups = new Map<string, string[]>();\n\n for (const file of files) {\n const dir = dirname(file);\n const existing = groups.get(dir) ?? [];\n existing.push(file);\n groups.set(dir, existing);\n }\n\n return groups;\n}\n","/**\n * Core type definitions for EvalSense\n */\n\n// ============================================================================\n// Dataset & Alignment Types\n// ============================================================================\n\n/**\n * A loaded dataset with records and metadata\n */\nexport interface Dataset<T = Record<string, unknown>> {\n records: T[];\n metadata: DatasetMetadata;\n}\n\nexport interface DatasetMetadata {\n source: string;\n count: number;\n loadedAt: Date;\n}\n\n/**\n * A record aligned between actual (model output) and expected (ground truth)\n */\nexport interface AlignedRecord {\n id: string;\n actual: Record<string, unknown>;\n expected: Record<string, unknown>;\n}\n\n/**\n * Output from runModel() - predictions with IDs for alignment\n */\nexport interface Prediction {\n id: string;\n [field: string]: unknown;\n}\n\n// ============================================================================\n// LLM Types\n// ============================================================================\n\n/**\n * JSON Schema for structured LLM outputs\n */\nexport interface JSONSchema {\n type: string;\n properties?: Record<string, unknown>;\n required?: string[];\n [key: string]: unknown;\n}\n\n/**\n * LLM client interface for metric evaluation\n */\nexport interface LLMClient {\n /**\n * Generate a text completion from a prompt\n */\n complete(prompt: string): Promise<string>;\n\n /**\n * Generate a structured JSON completion (optional)\n */\n completeStructured?<T>(prompt: string, schema: JSONSchema): Promise<T>;\n}\n\n// ============================================================================\n// Metric Types\n// ============================================================================\n\n/**\n * Output from an LLM metric evaluation\n */\nexport interface MetricOutput {\n id: string;\n metric: string;\n score: number;\n label?: string;\n\n /** LLM's reasoning/explanation (for LLM-based metrics) */\n reasoning?: string;\n\n /** Evaluation mode used (for LLM-based metrics) */\n evaluationMode?: \"per-row\" | \"batch\";\n}\n\n/**\n * Configuration for a metric function\n */\nexport interface MetricConfig {\n outputs: Array<{ id: string; output: string }>;\n context?: string[];\n query?: string[];\n source?: string[];\n\n /** LLM client override (defaults to global client) */\n llmClient?: LLMClient;\n\n /** Evaluation mode: per-row (accurate, expensive) or batch (cheaper, potentially less accurate) */\n evaluationMode?: \"per-row\" | \"batch\";\n\n /** Custom prompt template override */\n customPrompt?: string;\n\n /** LLM temperature (default: 0) */\n temperature?: number;\n\n /** Max tokens per completion */\n maxTokens?: number;\n\n /** Timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * A metric function that evaluates outputs\n */\nexport type MetricFn = (config: MetricConfig) => Promise<MetricOutput[]>;\n\n// ============================================================================\n// Statistics Types\n// ============================================================================\n\n/**\n * Confusion matrix with labels\n */\nexport interface ConfusionMatrix {\n matrix: number[][];\n labels: string[];\n total: number;\n}\n\n/**\n * Per-class classification metrics\n */\nexport interface ClassMetrics {\n precision: number;\n recall: number;\n f1: number;\n support: number;\n}\n\n/**\n * Full classification metrics result\n */\nexport interface ClassificationMetrics {\n accuracy: number;\n perClass: Record<string, ClassMetrics>;\n macroAvg: { precision: number; recall: number; f1: number };\n weightedAvg: { precision: number; recall: number; f1: number };\n confusionMatrix: ConfusionMatrix;\n}\n\n/**\n * Regression metrics result\n */\nexport interface RegressionMetrics {\n mae: number;\n mse: number;\n rmse: number;\n r2: number;\n}\n\n// ============================================================================\n// Field Evaluation Types\n// ============================================================================\n\n/**\n * Result of evaluating a single field across all predictions\n */\nexport interface FieldMetricResult {\n field: string;\n metrics: ClassificationMetrics;\n binarized: boolean;\n binarizeThreshold?: number;\n}\n\n// ============================================================================\n// Test & Suite Types\n// ============================================================================\n\n/**\n * Test function signature\n */\nexport type TestFn = () => Promise<void> | void;\n\n/**\n * An individual eval test\n */\nexport interface EvalTest {\n name: string;\n fn: TestFn;\n}\n\n/**\n * A test suite (describe block)\n */\nexport interface Suite {\n name: string;\n tests: EvalTest[];\n beforeAll?: TestFn[];\n afterAll?: TestFn[];\n beforeEach?: TestFn[];\n afterEach?: TestFn[];\n}\n\n/**\n * Current test execution context\n */\nexport interface TestContext {\n currentSuite: Suite | null;\n suites: Suite[];\n results: SuiteResult[];\n}\n\n// ============================================================================\n// Assertion Types\n// ============================================================================\n\n/**\n * Result of a single assertion\n */\nexport interface AssertionResult {\n type: string;\n passed: boolean;\n message: string;\n expected?: unknown;\n actual?: unknown;\n field?: string;\n class?: string;\n}\n\n// ============================================================================\n// Result & Report Types\n// ============================================================================\n\n/**\n * Result of a single test\n */\nexport interface TestResult {\n name: string;\n status: \"passed\" | \"failed\" | \"error\" | \"skipped\";\n assertions: AssertionResult[];\n fieldMetrics: FieldMetricResult[];\n duration: number;\n error?: Error;\n}\n\n/**\n * Result of a test suite\n */\nexport interface SuiteResult {\n name: string;\n tests: TestResult[];\n passed: number;\n failed: number;\n errors: number;\n skipped: number;\n duration: number;\n}\n\n/**\n * Integrity check results for a dataset\n */\nexport interface IntegrityResult {\n valid: boolean;\n totalRecords: number;\n missingIds: string[];\n duplicateIds: string[];\n missingFields: Array<{ id: string; fields: string[] }>;\n}\n\n/**\n * Final evaluation report\n */\nexport interface EvalReport {\n version: string;\n timestamp: string;\n suites: SuiteResult[];\n summary: {\n totalSuites: number;\n totalTests: number;\n passed: number;\n failed: number;\n errors: number;\n skipped: number;\n duration: number;\n };\n integrity?: IntegrityResult;\n}\n\n// ============================================================================\n// CLI Types\n// ============================================================================\n\n/**\n * CLI configuration options\n */\nexport interface CLIOptions {\n filter?: string;\n output?: string;\n reporter?: \"json\" | \"console\" | \"both\";\n bail?: boolean;\n timeout?: number;\n}\n\n/**\n * Exit codes for CI integration\n */\nexport const ExitCodes = {\n SUCCESS: 0,\n ASSERTION_FAILURE: 1,\n INTEGRITY_FAILURE: 2,\n EXECUTION_ERROR: 3,\n CONFIGURATION_ERROR: 4,\n} as const;\n\nexport type ExitCode = (typeof ExitCodes)[keyof typeof ExitCodes];\n","/**\n * Test context management for EvalSense\n * Manages the global state during test execution\n */\n\nimport type { Suite, EvalTest, TestContext, AssertionResult, FieldMetricResult } from \"./types.js\";\n\n/**\n * Global test context - singleton for the current test run\n */\nlet globalContext: TestContext = createEmptyContext();\n\n/**\n * Current test execution state\n */\ninterface CurrentTestState {\n assertions: AssertionResult[];\n fieldMetrics: FieldMetricResult[];\n}\n\nlet currentTestState: CurrentTestState | null = null;\n\n/**\n * Creates an empty test context\n */\nexport function createEmptyContext(): TestContext {\n return {\n currentSuite: null,\n suites: [],\n results: [],\n };\n}\n\n/**\n * Gets the global test context\n */\nexport function getContext(): TestContext {\n return globalContext;\n}\n\n/**\n * Resets the global test context (used between test runs)\n */\nexport function resetContext(): void {\n globalContext = createEmptyContext();\n currentTestState = null;\n}\n\n/**\n * Gets the current suite being defined\n */\nexport function getCurrentSuite(): Suite | null {\n return globalContext.currentSuite;\n}\n\n/**\n * Sets the current suite being defined\n */\nexport function setCurrentSuite(suite: Suite | null): void {\n globalContext.currentSuite = suite;\n}\n\n/**\n * Adds a suite to the context\n */\nexport function addSuite(suite: Suite): void {\n globalContext.suites.push(suite);\n}\n\n/**\n * Adds a test to the current suite\n */\nexport function addTestToCurrentSuite(test: EvalTest): void {\n if (!globalContext.currentSuite) {\n throw new Error(\"Cannot add test outside of a describe() block\");\n }\n globalContext.currentSuite.tests.push(test);\n}\n\n/**\n * Gets all registered suites\n */\nexport function getSuites(): Suite[] {\n return globalContext.suites;\n}\n\n/**\n * Starts a new test execution (for collecting assertions)\n */\nexport function startTestExecution(): void {\n currentTestState = {\n assertions: [],\n fieldMetrics: [],\n };\n}\n\n/**\n * Ends the current test execution and returns collected data\n */\nexport function endTestExecution(): CurrentTestState {\n const state = currentTestState;\n currentTestState = null;\n return state ?? { assertions: [], fieldMetrics: [] };\n}\n\n/**\n * Records an assertion result in the current test\n */\nexport function recordAssertion(result: AssertionResult): void {\n if (currentTestState) {\n currentTestState.assertions.push(result);\n }\n}\n\n/**\n * Records field metrics in the current test\n */\nexport function recordFieldMetrics(metrics: FieldMetricResult): void {\n if (currentTestState) {\n currentTestState.fieldMetrics.push(metrics);\n }\n}\n\n/**\n * Checks if we're currently executing a test\n */\nexport function isInTestExecution(): boolean {\n return currentTestState !== null;\n}\n\n/**\n * Gets the current test state (for assertions to check)\n */\nexport function getCurrentTestState(): CurrentTestState | null {\n return currentTestState;\n}\n","/**\n * Test executor - runs discovered eval files\n */\n\nimport { pathToFileURL } from \"node:url\";\nimport type { Suite, TestResult, SuiteResult, EvalReport } from \"../core/types.js\";\nimport { ExitCodes } from \"../core/types.js\";\nimport { getSuites, startTestExecution, endTestExecution } from \"../core/context.js\";\nimport { AssertionError, TestExecutionError, MultipleAssertionError } from \"../core/errors.js\";\n\n/**\n * Options for test execution\n */\nexport interface ExecutorOptions {\n /** Stop on first failure */\n bail?: boolean;\n /** Test timeout in ms */\n timeout?: number;\n /** Filter pattern for test names */\n filter?: string;\n}\n\n/**\n * Executes all eval files and returns results\n */\nexport async function executeEvalFiles(\n files: string[],\n options: ExecutorOptions = {}\n): Promise<EvalReport> {\n const startTime = Date.now();\n const suiteResults: SuiteResult[] = [];\n\n // Load all eval files (this registers suites via describe())\n // Note: We don't reset context here because in CLI usage, each run\n // is a fresh Node process. For programmatic usage, call resetContext()\n // before calling this function if you need a clean slate.\n for (const file of files) {\n try {\n const fileUrl = pathToFileURL(file).href;\n await import(fileUrl);\n } catch (error) {\n throw new TestExecutionError(`Failed to load eval file: ${file}`, file, error as Error);\n }\n }\n\n // Get all registered suites\n const suites = getSuites();\n\n // Execute each suite\n for (const suite of suites) {\n const result = await executeSuite(suite, options);\n suiteResults.push(result);\n\n if (options.bail && result.failed > 0) {\n break;\n }\n }\n\n // Build report\n const report = buildReport(suiteResults, Date.now() - startTime);\n\n return report;\n}\n\n/**\n * Executes a single suite\n */\nasync function executeSuite(suite: Suite, options: ExecutorOptions): Promise<SuiteResult> {\n const startTime = Date.now();\n const testResults: TestResult[] = [];\n let passed = 0;\n let failed = 0;\n let errors = 0;\n let skipped = 0;\n\n // Run beforeAll hooks\n for (const hook of suite.beforeAll ?? []) {\n try {\n await hook();\n } catch (error) {\n // beforeAll failure fails all tests\n const message = error instanceof Error ? error.message : String(error);\n for (const test of suite.tests) {\n testResults.push({\n name: test.name,\n status: \"error\",\n assertions: [],\n fieldMetrics: [],\n duration: 0,\n error: new Error(`beforeAll hook failed: ${message}`),\n });\n errors++;\n }\n return {\n name: suite.name,\n tests: testResults,\n passed,\n failed,\n errors,\n skipped,\n duration: Date.now() - startTime,\n };\n }\n }\n\n // Run each test\n for (const test of suite.tests) {\n // Check filter\n if (options.filter && !test.name.toLowerCase().includes(options.filter.toLowerCase())) {\n testResults.push({\n name: test.name,\n status: \"skipped\",\n assertions: [],\n fieldMetrics: [],\n duration: 0,\n });\n skipped++;\n continue;\n }\n\n // Check if skipped\n if (test.name.startsWith(\"[SKIPPED]\")) {\n testResults.push({\n name: test.name,\n status: \"skipped\",\n assertions: [],\n fieldMetrics: [],\n duration: 0,\n });\n skipped++;\n continue;\n }\n\n // Run beforeEach hooks\n for (const hook of suite.beforeEach ?? []) {\n try {\n await hook();\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n testResults.push({\n name: test.name,\n status: \"error\",\n assertions: [],\n fieldMetrics: [],\n duration: 0,\n error: new Error(`beforeEach hook failed: ${message}`),\n });\n errors++;\n continue;\n }\n }\n\n // Execute the test\n const result = await executeTest(test.name, test.fn, options.timeout);\n testResults.push(result);\n\n if (result.status === \"passed\") {\n passed++;\n } else if (result.status === \"failed\") {\n failed++;\n } else if (result.status === \"error\") {\n errors++;\n }\n\n // Run afterEach hooks\n for (const hook of suite.afterEach ?? []) {\n try {\n await hook();\n } catch {\n // Log but don't fail the test\n }\n }\n\n // Bail on failure\n if (options.bail && (failed > 0 || errors > 0)) {\n break;\n }\n }\n\n // Run afterAll hooks\n for (const hook of suite.afterAll ?? []) {\n try {\n await hook();\n } catch {\n // Log but don't fail\n }\n }\n\n return {\n name: suite.name,\n tests: testResults,\n passed,\n failed,\n errors,\n skipped,\n duration: Date.now() - startTime,\n };\n}\n\n/**\n * Executes a single test with timeout\n */\nasync function executeTest(\n name: string,\n fn: () => Promise<void> | void,\n timeout = 30000\n): Promise<TestResult> {\n const startTime = Date.now();\n\n // Start collecting assertions\n startTestExecution();\n\n try {\n // Run with timeout\n await Promise.race([\n fn(),\n new Promise<never>((_, reject) =>\n setTimeout(() => reject(new Error(`Test timed out after ${timeout}ms`)), timeout)\n ),\n ]);\n\n // Test completed - collect results and check for assertion failures\n const { assertions, fieldMetrics } = endTestExecution();\n\n // Check if any assertions failed\n const failedAssertions = assertions.filter((a) => !a.passed);\n\n if (failedAssertions.length > 0) {\n // Multiple assertion failures - throw combined error\n const error = new MultipleAssertionError(\n failedAssertions.map((a) => ({\n message: a.message,\n expected: a.expected,\n actual: a.actual,\n field: a.field,\n }))\n );\n\n return {\n name,\n status: \"failed\",\n assertions,\n fieldMetrics,\n duration: Date.now() - startTime,\n error,\n };\n }\n\n // All assertions passed\n return {\n name,\n status: \"passed\",\n assertions,\n fieldMetrics,\n duration: Date.now() - startTime,\n };\n } catch (error) {\n const { assertions, fieldMetrics } = endTestExecution();\n\n if (error instanceof AssertionError || error instanceof MultipleAssertionError) {\n // Assertion failure\n return {\n name,\n status: \"failed\",\n assertions,\n fieldMetrics,\n duration: Date.now() - startTime,\n error,\n };\n }\n\n // Execution error\n return {\n name,\n status: \"error\",\n assertions,\n fieldMetrics,\n duration: Date.now() - startTime,\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n}\n\n/**\n * Builds the final report from suite results\n */\nfunction buildReport(suiteResults: SuiteResult[], totalDuration: number): EvalReport {\n let totalTests = 0;\n let totalPassed = 0;\n let totalFailed = 0;\n let totalErrors = 0;\n let totalSkipped = 0;\n\n for (const suite of suiteResults) {\n totalTests += suite.tests.length;\n totalPassed += suite.passed;\n totalFailed += suite.failed;\n totalErrors += suite.errors;\n totalSkipped += suite.skipped;\n }\n\n return {\n version: \"1.0.0\",\n timestamp: new Date().toISOString(),\n suites: suiteResults,\n summary: {\n totalSuites: suiteResults.length,\n totalTests,\n passed: totalPassed,\n failed: totalFailed,\n errors: totalErrors,\n skipped: totalSkipped,\n duration: totalDuration,\n },\n };\n}\n\n/**\n * Determines exit code from report\n */\nexport function getExitCode(report: EvalReport): number {\n if (report.summary.errors > 0) {\n return ExitCodes.EXECUTION_ERROR;\n }\n if (report.summary.failed > 0) {\n return ExitCodes.ASSERTION_FAILURE;\n }\n return ExitCodes.SUCCESS;\n}\n"]}
|