@valerypopoff/rivet2-evaluations 2.3.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.
- package/LICENSE +7 -0
- package/README.md +27 -0
- package/dist/cjs/bundle.cjs +3160 -0
- package/dist/cjs/bundle.cjs.map +7 -0
- package/dist/esm/assertions.js +555 -0
- package/dist/esm/canonical.js +109 -0
- package/dist/esm/dataTypes.js +103 -0
- package/dist/esm/datasetTransfer.js +146 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/normalization.js +369 -0
- package/dist/esm/runner.js +1767 -0
- package/dist/esm/serialization.js +277 -0
- package/dist/esm/store.js +88 -0
- package/dist/esm/suiteTransfer.js +63 -0
- package/dist/esm/types.js +16 -0
- package/dist/types/assertions.d.ts +17 -0
- package/dist/types/canonical.d.ts +23 -0
- package/dist/types/dataTypes.d.ts +19 -0
- package/dist/types/datasetTransfer.d.ts +26 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/normalization.d.ts +11 -0
- package/dist/types/runner.d.ts +66 -0
- package/dist/types/serialization.d.ts +6 -0
- package/dist/types/store.d.ts +37 -0
- package/dist/types/suiteTransfer.d.ts +22 -0
- package/dist/types/types.d.ts +429 -0
- package/package.json +42 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { EvaluationDatasetSnapshot, EvaluationRecordingArtifact, EvaluationRun, EvaluationRunStore } from './types.js';
|
|
2
|
+
export declare class InMemoryEvaluationRunStore implements EvaluationRunStore {
|
|
3
|
+
#private;
|
|
4
|
+
put(run: EvaluationRun): Promise<void>;
|
|
5
|
+
get(input: {
|
|
6
|
+
projectId: string;
|
|
7
|
+
runId: string;
|
|
8
|
+
}): Promise<EvaluationRun | undefined>;
|
|
9
|
+
list(input: {
|
|
10
|
+
projectId: string;
|
|
11
|
+
suiteId?: string;
|
|
12
|
+
}): Promise<readonly EvaluationRun[]>;
|
|
13
|
+
delete(input: {
|
|
14
|
+
projectId: string;
|
|
15
|
+
runId: string;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
putDatasetSnapshot(snapshot: EvaluationDatasetSnapshot): Promise<void>;
|
|
18
|
+
getDatasetSnapshot(input: {
|
|
19
|
+
projectId: string;
|
|
20
|
+
fingerprint: string;
|
|
21
|
+
}): Promise<EvaluationDatasetSnapshot | undefined>;
|
|
22
|
+
putRecording(artifact: EvaluationRecordingArtifact): Promise<void>;
|
|
23
|
+
getRecording(input: {
|
|
24
|
+
projectId: string;
|
|
25
|
+
recordingId: string;
|
|
26
|
+
}): Promise<EvaluationRecordingArtifact | undefined>;
|
|
27
|
+
updateRecordingRetention(input: {
|
|
28
|
+
projectId: string;
|
|
29
|
+
recordingId: string;
|
|
30
|
+
retention: EvaluationRecordingArtifact['reference']['retention'];
|
|
31
|
+
expiresAt?: string;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
promoteBaseline(input: {
|
|
34
|
+
projectId: string;
|
|
35
|
+
runId: string;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EvaluationDataset, EvaluationSuite } from './types.js';
|
|
2
|
+
export type EvaluationSuiteBundle = {
|
|
3
|
+
suite: EvaluationSuite;
|
|
4
|
+
dataset: EvaluationDataset;
|
|
5
|
+
};
|
|
6
|
+
export type EvaluationSuiteBundleImportScope = {
|
|
7
|
+
suiteId: string;
|
|
8
|
+
datasetId: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A portable suite bundle includes the suite definition and its referenced
|
|
12
|
+
* dataset. It intentionally excludes graphs, baselines, recordings, and run
|
|
13
|
+
* history, which belong to the destination project or its run store.
|
|
14
|
+
*/
|
|
15
|
+
export declare function serializeEvaluationSuiteBundleJson(suite: EvaluationSuite, dataset: EvaluationDataset): string;
|
|
16
|
+
/**
|
|
17
|
+
* Imports a bundle as new local evaluation resources. Field and case IDs remain stable
|
|
18
|
+
* so the imported suite's bindings and expected-value references still point
|
|
19
|
+
* to its imported dataset; suite and dataset identities are always supplied by
|
|
20
|
+
* the destination to avoid overwriting existing resources.
|
|
21
|
+
*/
|
|
22
|
+
export declare function deserializeEvaluationSuiteBundleJson(source: string, scope: EvaluationSuiteBundleImportScope): EvaluationSuiteBundle;
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import type { GraphId, Project, ProjectId } from '@valerypopoff/rivet2-core';
|
|
2
|
+
/** Values saved in evaluation datasets, assertions, evidence, and run artifacts. */
|
|
3
|
+
export type PortableJson = null | boolean | number | string | PortableJson[] | {
|
|
4
|
+
[key: string]: PortableJson;
|
|
5
|
+
};
|
|
6
|
+
export type EvaluationDatasetFieldRole = 'input' | 'expected' | 'metadata';
|
|
7
|
+
export type EvaluationDatasetField = {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
/** Rivet data type identifier. The runner validates bindings against the target graph. */
|
|
12
|
+
dataType: string;
|
|
13
|
+
role: EvaluationDatasetFieldRole;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type EvaluationDatasetCase = {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
tags?: string[];
|
|
21
|
+
note?: string;
|
|
22
|
+
values: Record<string, PortableJson>;
|
|
23
|
+
};
|
|
24
|
+
export type EvaluationDataset = {
|
|
25
|
+
id: string;
|
|
26
|
+
/**
|
|
27
|
+
* Legacy project ownership retained only while importing older project
|
|
28
|
+
* files. Locally persisted evaluation datasets intentionally omit it so
|
|
29
|
+
* they can be reused with any currently open project.
|
|
30
|
+
*/
|
|
31
|
+
projectId?: ProjectId;
|
|
32
|
+
name: string;
|
|
33
|
+
fields: EvaluationDatasetField[];
|
|
34
|
+
cases: EvaluationDatasetCase[];
|
|
35
|
+
/** Derived from fields and cases; stored to make snapshot reuse inspectable. */
|
|
36
|
+
contentFingerprint?: string;
|
|
37
|
+
};
|
|
38
|
+
export type EvaluationInputBinding = {
|
|
39
|
+
graphInputId: string;
|
|
40
|
+
datasetFieldId: string;
|
|
41
|
+
};
|
|
42
|
+
export type EvaluationExpectedSource = {
|
|
43
|
+
kind: 'literal';
|
|
44
|
+
value: PortableJson;
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'dataset-field';
|
|
47
|
+
fieldId: string;
|
|
48
|
+
};
|
|
49
|
+
export type EvaluationAssertionOperator = 'equals' | 'not-equals' | 'contains' | 'matches-regex' | 'type-is' | 'json-schema' | 'number-at-least' | 'number-at-most' | 'number-between' | 'array-includes' | 'set-overlaps' | 'contains-any' | 'contains-all';
|
|
50
|
+
export type EvaluationAssertion = {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
required?: boolean;
|
|
54
|
+
outputPath: string;
|
|
55
|
+
operator: EvaluationAssertionOperator;
|
|
56
|
+
expected: EvaluationExpectedSource;
|
|
57
|
+
};
|
|
58
|
+
export type EvaluationEvaluatorContextInput = 'case' | 'inputs' | 'expected' | 'outputs' | 'run';
|
|
59
|
+
export type EvaluationEvaluatorInputSource = {
|
|
60
|
+
kind: 'dataset-field';
|
|
61
|
+
fieldId: string;
|
|
62
|
+
} | {
|
|
63
|
+
kind: 'target-output';
|
|
64
|
+
outputId: string;
|
|
65
|
+
} | {
|
|
66
|
+
kind: 'context';
|
|
67
|
+
context: EvaluationEvaluatorContextInput;
|
|
68
|
+
};
|
|
69
|
+
export type EvaluationEvaluatorInputBinding = {
|
|
70
|
+
graphInputId: string;
|
|
71
|
+
source: EvaluationEvaluatorInputSource;
|
|
72
|
+
};
|
|
73
|
+
export type EvaluationGraphEvaluator = {
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
graphId: GraphId;
|
|
77
|
+
/**
|
|
78
|
+
* Explicit evaluator Graph Input mappings. Missing means an older evaluator
|
|
79
|
+
* may use the five reserved context inputs; an empty array explicitly opts
|
|
80
|
+
* into direct mapping for a graph with no required inputs.
|
|
81
|
+
*/
|
|
82
|
+
inputBindings?: EvaluationEvaluatorInputBinding[];
|
|
83
|
+
required?: boolean;
|
|
84
|
+
scoreWeight?: number;
|
|
85
|
+
runOnTargetError?: boolean;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Pass/fail suites evaluate required assertions and evaluator verdicts.
|
|
89
|
+
* Scoring evaluator graphs return scores on the user-facing 0..100 scale.
|
|
90
|
+
* Runs store normalized scores internally for aggregation and compatibility.
|
|
91
|
+
*/
|
|
92
|
+
export type EvaluationSuiteMode = 'pass-fail' | 'scoring';
|
|
93
|
+
export type EvaluationThreshold = {
|
|
94
|
+
id: string;
|
|
95
|
+
metric: 'pass-rate' | 'mean-score';
|
|
96
|
+
operator: 'at-least';
|
|
97
|
+
value: number;
|
|
98
|
+
} | {
|
|
99
|
+
id: string;
|
|
100
|
+
metric: 'target-error-rate' | 'evaluator-error-rate' | 'tool-failure-rate' | 'average-cost' | 'total-cost' | 'average-latency-ms' | 'p95-latency-ms';
|
|
101
|
+
operator: 'at-most';
|
|
102
|
+
value: number;
|
|
103
|
+
} | {
|
|
104
|
+
id: string;
|
|
105
|
+
metric: `custom:${string}`;
|
|
106
|
+
operator: 'at-least' | 'at-most';
|
|
107
|
+
value: number;
|
|
108
|
+
} | {
|
|
109
|
+
id: string;
|
|
110
|
+
metric: string;
|
|
111
|
+
operator: 'max-regression';
|
|
112
|
+
value: number;
|
|
113
|
+
};
|
|
114
|
+
export type EvaluationRunConfiguration = {
|
|
115
|
+
trialCount?: number;
|
|
116
|
+
concurrency?: number;
|
|
117
|
+
timeoutMs?: number;
|
|
118
|
+
seed?: number;
|
|
119
|
+
seedGraphInputId?: string;
|
|
120
|
+
recordingRetention?: 'failures-and-baselines' | 'all';
|
|
121
|
+
};
|
|
122
|
+
export type EvaluationSuite = {
|
|
123
|
+
id: string;
|
|
124
|
+
name: string;
|
|
125
|
+
description?: string;
|
|
126
|
+
tags?: string[];
|
|
127
|
+
targetGraphId: GraphId;
|
|
128
|
+
datasetId: string;
|
|
129
|
+
inputBindings: EvaluationInputBinding[];
|
|
130
|
+
assertions: EvaluationAssertion[];
|
|
131
|
+
evaluators: EvaluationGraphEvaluator[];
|
|
132
|
+
/** Missing values are legacy pass/fail suites. */
|
|
133
|
+
evaluationMode?: EvaluationSuiteMode;
|
|
134
|
+
configuration?: EvaluationRunConfiguration;
|
|
135
|
+
thresholds?: EvaluationThreshold[];
|
|
136
|
+
};
|
|
137
|
+
export type EvaluationBaselineSnapshot = {
|
|
138
|
+
id: string;
|
|
139
|
+
suiteId: string;
|
|
140
|
+
sourceRunId?: string;
|
|
141
|
+
createdAt: string;
|
|
142
|
+
provenance: EvaluationRunProvenance;
|
|
143
|
+
aggregate: EvaluationAggregate;
|
|
144
|
+
/** Optional for project baselines created before EvaluationRun v2. */
|
|
145
|
+
purpose?: EvaluationRunPurpose;
|
|
146
|
+
/** Optional for project baselines created before EvaluationRun v2. */
|
|
147
|
+
qualityStatus?: EvaluationQualityStatus;
|
|
148
|
+
/** Optional for project baselines created before EvaluationRun v2. */
|
|
149
|
+
qualityReason?: EvaluationQualityReason;
|
|
150
|
+
/** Optional for project baselines created before EvaluationRun v2. */
|
|
151
|
+
accountingStatus?: EvaluationAccountingStatus;
|
|
152
|
+
/** Optional for baselines created before score-capable suites existed. */
|
|
153
|
+
evaluationMode?: EvaluationSuiteMode;
|
|
154
|
+
cases: Array<Pick<EvaluationCaseAggregate, 'caseId' | 'caseName' | 'passRate' | 'meanScore' | 'metrics' | 'evaluatedTrialCount' | 'passedTrialCount' | 'failedTrialCount' | 'notEvaluatedTrialCount' | 'unableToEvaluateTrialCount' | 'erroredTrialCount' | 'canceledTrialCount' | 'scoredTrialCount' | 'missingScoreTrialCount'>>;
|
|
155
|
+
};
|
|
156
|
+
export type EvaluationProjectData = {
|
|
157
|
+
version: 1;
|
|
158
|
+
suites: EvaluationSuite[];
|
|
159
|
+
baselines: EvaluationBaselineSnapshot[];
|
|
160
|
+
};
|
|
161
|
+
export type EvaluationObservationStatus = 'passed' | 'failed' | 'scored' | 'error' | 'skipped';
|
|
162
|
+
export type EvaluationObservation = {
|
|
163
|
+
id: string;
|
|
164
|
+
kind: 'assertion' | 'graph';
|
|
165
|
+
name: string;
|
|
166
|
+
status: EvaluationObservationStatus;
|
|
167
|
+
required: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Normalized internal score in the closed 0..1 range. Evaluator graphs
|
|
170
|
+
* return their `result.score` on the user-facing 0..100 scale.
|
|
171
|
+
*/
|
|
172
|
+
score?: number;
|
|
173
|
+
/**
|
|
174
|
+
* The configured importance of a graph evaluator's score. It is copied into
|
|
175
|
+
* the observation so a stored run remains interpretable after its suite is
|
|
176
|
+
* edited.
|
|
177
|
+
*/
|
|
178
|
+
scoreWeight?: number;
|
|
179
|
+
message?: string;
|
|
180
|
+
evidence?: PortableJson;
|
|
181
|
+
metrics?: Record<string, number>;
|
|
182
|
+
durationMs?: number;
|
|
183
|
+
costUsd?: number;
|
|
184
|
+
/** Privacy-bounded physical provider and profile decisions from this evaluator graph. */
|
|
185
|
+
providerAttempts?: PortableJson;
|
|
186
|
+
/**
|
|
187
|
+
* Replay artifact for this evaluator execution. The serialized recording
|
|
188
|
+
* itself stays in the evaluation run store, never in the project or run
|
|
189
|
+
* summary document.
|
|
190
|
+
*/
|
|
191
|
+
recording?: EvaluationRecordingReference;
|
|
192
|
+
};
|
|
193
|
+
export type EvaluationUsage = {
|
|
194
|
+
inputTokens?: number;
|
|
195
|
+
outputTokens?: number;
|
|
196
|
+
cachedInputTokens?: number;
|
|
197
|
+
reasoningTokens?: number;
|
|
198
|
+
modelCallCount?: number;
|
|
199
|
+
toolCallCount?: number;
|
|
200
|
+
toolFailureCount?: number;
|
|
201
|
+
costUsd?: number;
|
|
202
|
+
hasUnknownCost?: boolean;
|
|
203
|
+
};
|
|
204
|
+
export type EvaluationExecutionMetrics = EvaluationUsage & {
|
|
205
|
+
durationMs: number;
|
|
206
|
+
};
|
|
207
|
+
export type EvaluationRunPurpose = 'evaluation' | 'execution-benchmark';
|
|
208
|
+
export type EvaluationTrialExecutionStatus = 'completed' | 'error' | 'canceled';
|
|
209
|
+
export type EvaluationQualityStatus = 'passed' | 'failed' | 'scored' | 'not-evaluated' | 'unable-to-evaluate';
|
|
210
|
+
export type EvaluationAccountingStatus = 'complete' | 'partial';
|
|
211
|
+
export type EvaluationQualityReasonCode = 'in-progress' | 'checks-passed' | 'checks-failed' | 'scores-complete' | 'scores-incomplete' | 'benchmark' | 'no-trial-quality-checks' | 'target-error' | 'required-check-error' | 'required-metric-unavailable' | 'thresholds-passed' | 'thresholds-failed' | 'canceled' | 'no-completed-trials';
|
|
212
|
+
export type EvaluationQualityReason = {
|
|
213
|
+
code: EvaluationQualityReasonCode;
|
|
214
|
+
message: string;
|
|
215
|
+
};
|
|
216
|
+
export type EvaluationThresholdResult = {
|
|
217
|
+
id: string;
|
|
218
|
+
metric: string;
|
|
219
|
+
operator: EvaluationThreshold['operator'];
|
|
220
|
+
status: 'passed' | 'failed' | 'unavailable';
|
|
221
|
+
expectedValue: number;
|
|
222
|
+
actualValue?: number;
|
|
223
|
+
baselineValue?: number;
|
|
224
|
+
regression?: number;
|
|
225
|
+
message: string;
|
|
226
|
+
};
|
|
227
|
+
export type EvaluationTrial = {
|
|
228
|
+
id: string;
|
|
229
|
+
caseId: string;
|
|
230
|
+
caseName: string;
|
|
231
|
+
caseIndex: number;
|
|
232
|
+
trialIndex: number;
|
|
233
|
+
executionStatus: EvaluationTrialExecutionStatus;
|
|
234
|
+
qualityStatus: EvaluationQualityStatus;
|
|
235
|
+
qualityReason: EvaluationQualityReason;
|
|
236
|
+
inputs: Record<string, PortableJson>;
|
|
237
|
+
expected: Record<string, PortableJson>;
|
|
238
|
+
outputs: Record<string, PortableJson>;
|
|
239
|
+
observations: EvaluationObservation[];
|
|
240
|
+
targetMetrics: EvaluationExecutionMetrics;
|
|
241
|
+
evaluatorMetrics: EvaluationExecutionMetrics;
|
|
242
|
+
totalMetrics: EvaluationExecutionMetrics;
|
|
243
|
+
error?: string;
|
|
244
|
+
seed?: number;
|
|
245
|
+
recording?: EvaluationRecordingReference;
|
|
246
|
+
/** Privacy-bounded physical provider and profile decisions from the target graph. */
|
|
247
|
+
targetProviderAttempts?: PortableJson;
|
|
248
|
+
};
|
|
249
|
+
export type EvaluationCaseAggregate = {
|
|
250
|
+
caseId: string;
|
|
251
|
+
caseName: string;
|
|
252
|
+
/** Undefined when no trial for this case produced an authoritative quality result. */
|
|
253
|
+
passRate?: number;
|
|
254
|
+
/** Optional so compact baselines written before EvaluationRun v2 remain readable. */
|
|
255
|
+
evaluatedTrialCount?: number;
|
|
256
|
+
passedTrialCount?: number;
|
|
257
|
+
failedTrialCount?: number;
|
|
258
|
+
notEvaluatedTrialCount?: number;
|
|
259
|
+
unableToEvaluateTrialCount?: number;
|
|
260
|
+
erroredTrialCount?: number;
|
|
261
|
+
canceledTrialCount?: number;
|
|
262
|
+
/** Completed trials that produced a usable score in a scoring suite. */
|
|
263
|
+
scoredTrialCount?: number;
|
|
264
|
+
/** Requested trials that could not contribute a score. */
|
|
265
|
+
missingScoreTrialCount?: number;
|
|
266
|
+
/** Normalized internal score in the closed 0..1 range. */
|
|
267
|
+
meanScore?: number;
|
|
268
|
+
metrics: Record<string, number>;
|
|
269
|
+
};
|
|
270
|
+
export type EvaluationAggregate = {
|
|
271
|
+
trialCount: number;
|
|
272
|
+
evaluatedTrialCount: number;
|
|
273
|
+
notEvaluatedTrialCount: number;
|
|
274
|
+
unableToEvaluateTrialCount: number;
|
|
275
|
+
passedTrialCount: number;
|
|
276
|
+
failedTrialCount: number;
|
|
277
|
+
erroredTrialCount: number;
|
|
278
|
+
canceledTrialCount: number;
|
|
279
|
+
/** Completed trials that produced a usable score in a scoring suite. */
|
|
280
|
+
scoredTrialCount?: number;
|
|
281
|
+
/** Requested trials that could not contribute a score. */
|
|
282
|
+
missingScoreTrialCount?: number;
|
|
283
|
+
passRate: number;
|
|
284
|
+
/** Normalized internal score in the closed 0..1 range. */
|
|
285
|
+
meanScore?: number;
|
|
286
|
+
averageLatencyMs: number;
|
|
287
|
+
p95LatencyMs: number;
|
|
288
|
+
totalCostUsd?: number;
|
|
289
|
+
averageCostUsd?: number;
|
|
290
|
+
targetErrorRate: number;
|
|
291
|
+
evaluatorErrorRate: number;
|
|
292
|
+
toolFailureRate: number;
|
|
293
|
+
metrics: Record<string, number>;
|
|
294
|
+
};
|
|
295
|
+
export type EvaluationRunProvenance = {
|
|
296
|
+
projectFingerprint: string;
|
|
297
|
+
suiteFingerprint: string;
|
|
298
|
+
datasetFingerprint: string;
|
|
299
|
+
targetFingerprint: string;
|
|
300
|
+
evaluatorFingerprints: Record<string, string>;
|
|
301
|
+
executionMode: string;
|
|
302
|
+
accountingComplete: boolean;
|
|
303
|
+
};
|
|
304
|
+
export type EvaluationRun = {
|
|
305
|
+
version: 2;
|
|
306
|
+
id: string;
|
|
307
|
+
projectId: ProjectId;
|
|
308
|
+
suiteId: string;
|
|
309
|
+
suiteName: string;
|
|
310
|
+
/**
|
|
311
|
+
* Monotonically increases while a run is persisted. Stores use it to reject
|
|
312
|
+
* a delayed live-progress write after a newer completed snapshot.
|
|
313
|
+
* Missing means zero for recordings created before this field existed.
|
|
314
|
+
*/
|
|
315
|
+
revision?: number;
|
|
316
|
+
startedAt: string;
|
|
317
|
+
completedAt?: string;
|
|
318
|
+
purpose: EvaluationRunPurpose;
|
|
319
|
+
/** Captures the suite semantics that produced this run. */
|
|
320
|
+
evaluationMode?: EvaluationSuiteMode;
|
|
321
|
+
executionStatus: 'queued' | 'running' | 'completed' | 'canceled' | 'error';
|
|
322
|
+
qualityStatus: EvaluationQualityStatus;
|
|
323
|
+
qualityReason: EvaluationQualityReason;
|
|
324
|
+
accountingStatus: EvaluationAccountingStatus;
|
|
325
|
+
provenance: EvaluationRunProvenance;
|
|
326
|
+
aggregate?: EvaluationAggregate;
|
|
327
|
+
/** Structured aggregate-threshold evidence for UI, reporters, and retained runs. */
|
|
328
|
+
thresholdResults: EvaluationThresholdResult[];
|
|
329
|
+
trials: EvaluationTrial[];
|
|
330
|
+
warnings: string[];
|
|
331
|
+
};
|
|
332
|
+
export type EvaluationRecordingReference = {
|
|
333
|
+
id: string;
|
|
334
|
+
retention: 'temporary' | 'failure' | 'baseline' | 'retained';
|
|
335
|
+
expiresAt?: string;
|
|
336
|
+
};
|
|
337
|
+
/** A replayable execution artifact owned by an EvaluationRunStore. */
|
|
338
|
+
export type EvaluationRecordingArtifact = {
|
|
339
|
+
projectId: ProjectId;
|
|
340
|
+
runId: string;
|
|
341
|
+
trialId: string;
|
|
342
|
+
reference: EvaluationRecordingReference;
|
|
343
|
+
/** ExecutionRecorder's compact serialized representation. */
|
|
344
|
+
serialized: string;
|
|
345
|
+
createdAt: string;
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* Immutable, content-addressed copy of the cases used by an evaluation run.
|
|
349
|
+
* It lives with the run history rather than in a compact project baseline, so
|
|
350
|
+
* a later edit to a .rivet-data file cannot rewrite historical evidence.
|
|
351
|
+
*/
|
|
352
|
+
export type EvaluationDatasetSnapshot = {
|
|
353
|
+
projectId: ProjectId;
|
|
354
|
+
fingerprint: string;
|
|
355
|
+
dataset: EvaluationDataset;
|
|
356
|
+
createdAt: string;
|
|
357
|
+
};
|
|
358
|
+
export type EvaluationGraphExecution = {
|
|
359
|
+
outputs: Record<string, PortableJson>;
|
|
360
|
+
metrics: EvaluationExecutionMetrics;
|
|
361
|
+
recording?: EvaluationRecordingReference;
|
|
362
|
+
providerAttempts?: PortableJson;
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* Lets a target adapter preserve its metrics and replay reference when a
|
|
366
|
+
* graph itself fails. The runner still classifies that as a target failure.
|
|
367
|
+
*/
|
|
368
|
+
export declare class EvaluationGraphExecutionError extends Error {
|
|
369
|
+
readonly metrics?: EvaluationExecutionMetrics;
|
|
370
|
+
readonly recording?: EvaluationRecordingReference;
|
|
371
|
+
readonly providerAttempts?: PortableJson;
|
|
372
|
+
constructor(message: string, details?: Partial<Pick<EvaluationGraphExecution, 'metrics' | 'recording' | 'providerAttempts'>>);
|
|
373
|
+
}
|
|
374
|
+
export type EvaluationGraphRunner = (input: {
|
|
375
|
+
project: Project;
|
|
376
|
+
graphId: GraphId;
|
|
377
|
+
inputs: Record<string, PortableJson>;
|
|
378
|
+
signal?: AbortSignal;
|
|
379
|
+
metadata: {
|
|
380
|
+
evaluationRunId: string;
|
|
381
|
+
suiteId: string;
|
|
382
|
+
caseId: string;
|
|
383
|
+
trialIndex: number;
|
|
384
|
+
phase: 'target' | 'evaluator';
|
|
385
|
+
};
|
|
386
|
+
}) => Promise<EvaluationGraphExecution>;
|
|
387
|
+
export type EvaluationRunStore = {
|
|
388
|
+
put(run: EvaluationRun): Promise<void>;
|
|
389
|
+
get(input: {
|
|
390
|
+
projectId: ProjectId;
|
|
391
|
+
runId: string;
|
|
392
|
+
}): Promise<EvaluationRun | undefined>;
|
|
393
|
+
list(input: {
|
|
394
|
+
projectId: ProjectId;
|
|
395
|
+
suiteId?: string;
|
|
396
|
+
}): Promise<readonly EvaluationRun[]>;
|
|
397
|
+
delete(input: {
|
|
398
|
+
projectId: ProjectId;
|
|
399
|
+
runId: string;
|
|
400
|
+
}): Promise<void>;
|
|
401
|
+
/**
|
|
402
|
+
* Persists the first project-scoped snapshot for a dataset fingerprint.
|
|
403
|
+
* Implementations must not rewrite an existing snapshot.
|
|
404
|
+
*/
|
|
405
|
+
putDatasetSnapshot(snapshot: EvaluationDatasetSnapshot): Promise<void>;
|
|
406
|
+
getDatasetSnapshot(input: {
|
|
407
|
+
projectId: ProjectId;
|
|
408
|
+
fingerprint: string;
|
|
409
|
+
}): Promise<EvaluationDatasetSnapshot | undefined>;
|
|
410
|
+
putRecording(artifact: EvaluationRecordingArtifact): Promise<void>;
|
|
411
|
+
getRecording(input: {
|
|
412
|
+
projectId: ProjectId;
|
|
413
|
+
recordingId: string;
|
|
414
|
+
}): Promise<EvaluationRecordingArtifact | undefined>;
|
|
415
|
+
updateRecordingRetention(input: {
|
|
416
|
+
projectId: ProjectId;
|
|
417
|
+
recordingId: string;
|
|
418
|
+
retention: EvaluationRecordingReference['retention'];
|
|
419
|
+
expiresAt?: string;
|
|
420
|
+
}): Promise<void>;
|
|
421
|
+
/** Pins all artifacts belonging to the run before its compact baseline is saved in the project. */
|
|
422
|
+
promoteBaseline(input: {
|
|
423
|
+
projectId: ProjectId;
|
|
424
|
+
runId: string;
|
|
425
|
+
}): Promise<void>;
|
|
426
|
+
};
|
|
427
|
+
export type EvaluationReporter = {
|
|
428
|
+
report(run: EvaluationRun): Promise<void> | void;
|
|
429
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@valerypopoff/rivet2-evaluations",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "dist/cjs/bundle.cjs",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
"node": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"import": "./dist/esm/index.js",
|
|
13
|
+
"require": "./dist/cjs/bundle.cjs"
|
|
14
|
+
},
|
|
15
|
+
"browser": {
|
|
16
|
+
"types": "./dist/types/index.d.ts",
|
|
17
|
+
"import": "./dist/esm/index.js",
|
|
18
|
+
"require": "./dist/cjs/bundle.cjs"
|
|
19
|
+
},
|
|
20
|
+
"default": {
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
22
|
+
"import": "./dist/esm/index.js",
|
|
23
|
+
"require": "./dist/cjs/bundle.cjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/cjs/**",
|
|
28
|
+
"dist/esm/**",
|
|
29
|
+
"dist/types/**"
|
|
30
|
+
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/valerypopoff/rivet2.0.git"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@valerypopoff/rivet2-core": "^2.3.0",
|
|
40
|
+
"yaml": "^2.9.0"
|
|
41
|
+
}
|
|
42
|
+
}
|