@nifrajs/testing 3.1.0 → 3.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/README.md +8 -0
- package/dist/agent-certification.d.ts +41 -0
- package/dist/agent-certification.d.ts.map +1 -0
- package/dist/agent-certification.js +242 -0
- package/dist/agent-certification.js.map +1 -0
- package/dist/agent-eval.d.ts +192 -0
- package/dist/agent-eval.d.ts.map +1 -0
- package/dist/agent-eval.js +410 -0
- package/dist/agent-eval.js.map +1 -0
- package/dist/contract-lab.d.ts +43 -0
- package/dist/contract-lab.d.ts.map +1 -0
- package/dist/contract-lab.js +139 -0
- package/dist/contract-lab.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +11 -6
- package/src/agent-certification.ts +296 -0
- package/src/agent-eval.ts +660 -0
- package/src/contract-lab.ts +196 -0
- package/src/index.ts +52 -0
package/README.md
CHANGED
|
@@ -194,6 +194,14 @@ that every call carries and captures cookies via a shared jar.
|
|
|
194
194
|
|
|
195
195
|
For a **stateless** request (no cookies), use `testClient` from `@nifrajs/client` directly.
|
|
196
196
|
|
|
197
|
+
### Agent evaluation and failure matrix
|
|
198
|
+
|
|
199
|
+
`runAgentEvalComposition` composes trajectory replay, fault profiles, contract invariants,
|
|
200
|
+
idempotency proofs, and adapter certification. Reports expose explicit invariant and rubric cases,
|
|
201
|
+
stable regression IDs, schedule tokens, and digests; they do not retain prompts, tool payloads,
|
|
202
|
+
model output, labels, or a single opaque quality score. The failure matrix covers model, tool,
|
|
203
|
+
approval, cancellation, lease, cursor, registry, and deployment boundaries.
|
|
204
|
+
|
|
197
205
|
## For AI agents
|
|
198
206
|
|
|
199
207
|
Start with [`LLM.md`](./LLM.md) - this package's contract card (the exports you call + its footguns),
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Certification profile for capability-descriptor adapters.
|
|
3
|
+
*
|
|
4
|
+
* An adapter that projects a tool, MCP tool, extension, model, or deployment target into a
|
|
5
|
+
* {@link CapabilityDescriptor} is certified structurally: its output must parse cleanly, carry a real
|
|
6
|
+
* schema digest, be free of any content-bearing field, compose into a deterministic snapshot, and
|
|
7
|
+
* surface a schema change on a stable identity as drift rather than a silent overwrite. The profile
|
|
8
|
+
* is dependency-free test evidence - an adapter package uses it only in CI, and the resulting matrix
|
|
9
|
+
* is portable JSON that names capabilities, never payloads.
|
|
10
|
+
*/
|
|
11
|
+
import { type AgentDeploymentAdapter, type ModelGateway } from "@nifrajs/agent";
|
|
12
|
+
import { type CapabilityDescriptor } from "@nifrajs/agent/registry";
|
|
13
|
+
import { type AdapterCertificationProfile } from "./certification.js";
|
|
14
|
+
/**
|
|
15
|
+
* The test-only surface a descriptor adapter exposes for certification. `describe` yields the
|
|
16
|
+
* adapter's representative descriptor; `describeDrift` yields a descriptor with the SAME identity
|
|
17
|
+
* (kind and name) but a DIFFERENT schema digest, so the drift check can prove the adapter's identity
|
|
18
|
+
* is stable across a schema change instead of colliding into it.
|
|
19
|
+
*/
|
|
20
|
+
export interface CertifiableDescriptorAdapter {
|
|
21
|
+
describe(): CapabilityDescriptor | Promise<CapabilityDescriptor>;
|
|
22
|
+
describeDrift(): CapabilityDescriptor | Promise<CapabilityDescriptor>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build the descriptor-adapter certification profile. Every check runs against a fresh adapter, so a
|
|
26
|
+
* failure never leaks into the next capability's evidence.
|
|
27
|
+
*/
|
|
28
|
+
export declare function registryCertificationProfile(): AdapterCertificationProfile<CertifiableDescriptorAdapter>;
|
|
29
|
+
export interface CertifiableModelGateway extends ModelGateway {
|
|
30
|
+
}
|
|
31
|
+
/** Certification for provider-neutral gateways. It never emits request or response content. */
|
|
32
|
+
export declare function gatewayCertificationProfile(): AdapterCertificationProfile<CertifiableModelGateway>;
|
|
33
|
+
export declare const modelGatewayCertificationProfile: typeof gatewayCertificationProfile;
|
|
34
|
+
export interface CertifiableDeploymentAdapter extends AgentDeploymentAdapter {
|
|
35
|
+
/** Required only when the adapter claims real OS hostile-code isolation. */
|
|
36
|
+
readonly verifyHostileCodeIsolation?: () => boolean | PromiseLike<boolean>;
|
|
37
|
+
}
|
|
38
|
+
/** Certification for lifecycle cleanup, capability truthfulness, authority, and isolation claims. */
|
|
39
|
+
export declare function deploymentCertificationProfile(): AdapterCertificationProfile<CertifiableDeploymentAdapter>;
|
|
40
|
+
export declare const deploymentAdapterCertificationProfile: typeof deploymentCertificationProfile;
|
|
41
|
+
//# sourceMappingURL=agent-certification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-certification.d.ts","sourceRoot":"","sources":["../src/agent-certification.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAEL,KAAK,sBAAsB,EAE3B,KAAK,YAAY,EAMlB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,KAAK,2BAA2B,EAA8B,MAAM,oBAAoB,CAAA;AAEjG;;;;;GAKG;AACH,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,IAAI,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;IAChE,aAAa,IAAI,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;CACtE;AAiBD;;;GAGG;AACH,wBAAgB,4BAA4B,IAAI,2BAA2B,CAAC,4BAA4B,CAAC,CA4DxG;AASD,MAAM,WAAW,uBAAwB,SAAQ,YAAY;CAAG;AAEhE,+FAA+F;AAC/F,wBAAgB,2BAA2B,IAAI,2BAA2B,CAAC,uBAAuB,CAAC,CAgFlG;AAWD,eAAO,MAAM,gCAAgC,oCAA8B,CAAA;AAE3E,MAAM,WAAW,4BAA6B,SAAQ,sBAAsB;IAC1E,4EAA4E;IAC5E,QAAQ,CAAC,0BAA0B,CAAC,EAAE,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;CAC3E;AAED,qGAAqG;AACrG,wBAAgB,8BAA8B,IAAI,2BAA2B,CAAC,4BAA4B,CAAC,CA8D1G;AAED,eAAO,MAAM,qCAAqC,uCAAiC,CAAA"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Certification profile for capability-descriptor adapters.
|
|
3
|
+
*
|
|
4
|
+
* An adapter that projects a tool, MCP tool, extension, model, or deployment target into a
|
|
5
|
+
* {@link CapabilityDescriptor} is certified structurally: its output must parse cleanly, carry a real
|
|
6
|
+
* schema digest, be free of any content-bearing field, compose into a deterministic snapshot, and
|
|
7
|
+
* surface a schema change on a stable identity as drift rather than a silent overwrite. The profile
|
|
8
|
+
* is dependency-free test evidence - an adapter package uses it only in CI, and the resulting matrix
|
|
9
|
+
* is portable JSON that names capabilities, never payloads.
|
|
10
|
+
*/
|
|
11
|
+
import { AgentDeployment, createDeploymentAuthority, parseDeploymentCapabilityReport, parseModelGatewayError, parseModelGatewayResult, runModelGateway, structuredOutputParser, } from "@nifrajs/agent";
|
|
12
|
+
import { composeRegistrySnapshot, parseCapabilityDescriptor, RegistryError, } from "@nifrajs/agent/registry";
|
|
13
|
+
import { defineCertificationProfile } from "./certification.js";
|
|
14
|
+
const ALLOWED_KEYS = new Set([
|
|
15
|
+
"descriptorVersion",
|
|
16
|
+
"kind",
|
|
17
|
+
"name",
|
|
18
|
+
"version",
|
|
19
|
+
"schemaDigest",
|
|
20
|
+
"requiredCapabilities",
|
|
21
|
+
"approval",
|
|
22
|
+
"retry",
|
|
23
|
+
"idempotency",
|
|
24
|
+
"isolation",
|
|
25
|
+
]);
|
|
26
|
+
const SCHEMA_DIGEST = /^[0-9a-f]{64}$/;
|
|
27
|
+
/**
|
|
28
|
+
* Build the descriptor-adapter certification profile. Every check runs against a fresh adapter, so a
|
|
29
|
+
* failure never leaks into the next capability's evidence.
|
|
30
|
+
*/
|
|
31
|
+
export function registryCertificationProfile() {
|
|
32
|
+
return defineCertificationProfile({
|
|
33
|
+
id: "capability-descriptor",
|
|
34
|
+
version: 1,
|
|
35
|
+
capabilities: ["content-free", "schema-digest", "snapshot-determinism", "drift-detection"],
|
|
36
|
+
checks: [
|
|
37
|
+
{
|
|
38
|
+
id: "content-free",
|
|
39
|
+
capability: "content-free",
|
|
40
|
+
async run(adapter) {
|
|
41
|
+
const descriptor = await adapter.describe();
|
|
42
|
+
const parsed = parseCapabilityDescriptor(descriptor);
|
|
43
|
+
for (const key of Object.keys(parsed)) {
|
|
44
|
+
if (!ALLOWED_KEYS.has(key))
|
|
45
|
+
throw new Error("DescriptorExtraField");
|
|
46
|
+
}
|
|
47
|
+
if (parsed.descriptorVersion !== 1)
|
|
48
|
+
throw new Error("DescriptorVersion");
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "schema-digest",
|
|
53
|
+
capability: "schema-digest",
|
|
54
|
+
async run(adapter) {
|
|
55
|
+
const descriptor = await adapter.describe();
|
|
56
|
+
if (!SCHEMA_DIGEST.test(descriptor.schemaDigest))
|
|
57
|
+
throw new Error("DescriptorSchemaDigest");
|
|
58
|
+
if (descriptor.version.length === 0)
|
|
59
|
+
throw new Error("DescriptorVersionMissing");
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: "snapshot-determinism",
|
|
64
|
+
capability: "snapshot-determinism",
|
|
65
|
+
async run(adapter) {
|
|
66
|
+
const descriptor = await adapter.describe();
|
|
67
|
+
const first = await composeRegistrySnapshot([descriptor]);
|
|
68
|
+
const second = await composeRegistrySnapshot([descriptor]);
|
|
69
|
+
if (first.digest !== second.digest)
|
|
70
|
+
throw new Error("SnapshotNonDeterministic");
|
|
71
|
+
if (first.descriptors.length !== 1)
|
|
72
|
+
throw new Error("SnapshotDescriptorCount");
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "identity-drift",
|
|
77
|
+
capability: "drift-detection",
|
|
78
|
+
async run(adapter) {
|
|
79
|
+
const descriptor = await adapter.describe();
|
|
80
|
+
const drift = await adapter.describeDrift();
|
|
81
|
+
if (descriptor.kind !== drift.kind || descriptor.name !== drift.name)
|
|
82
|
+
throw new Error("DriftIdentityMismatch");
|
|
83
|
+
if (descriptor.schemaDigest === drift.schemaDigest)
|
|
84
|
+
throw new Error("DriftDigestUnchanged");
|
|
85
|
+
let code;
|
|
86
|
+
try {
|
|
87
|
+
await composeRegistrySnapshot([descriptor, drift]);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error instanceof RegistryError)
|
|
91
|
+
code = error.code;
|
|
92
|
+
}
|
|
93
|
+
if (code !== "schema_drift")
|
|
94
|
+
throw new Error("DriftNotDetected");
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
class NamedCertificationFailure extends Error {
|
|
101
|
+
constructor(name) {
|
|
102
|
+
super(name);
|
|
103
|
+
this.name = name;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** Certification for provider-neutral gateways. It never emits request or response content. */
|
|
107
|
+
export function gatewayCertificationProfile() {
|
|
108
|
+
return defineCertificationProfile({
|
|
109
|
+
id: "model-gateway",
|
|
110
|
+
version: 1,
|
|
111
|
+
capabilities: ["parse-boundary", "error-taxonomy", "fallback-policy", "evidence-firewall"],
|
|
112
|
+
checks: [
|
|
113
|
+
{
|
|
114
|
+
id: "parse-boundary",
|
|
115
|
+
capability: "parse-boundary",
|
|
116
|
+
async run(adapter) {
|
|
117
|
+
const result = await runModelGateway(adapter, { input: { probe: true }, parser: structuredOutputParser((value) => value) }, { routes: ["cert-route"], retryableCodes: [], budget: { maxAttempts: 1 } });
|
|
118
|
+
if (!result.ok || result.evidence.some((item) => Object.hasOwn(item, "input")))
|
|
119
|
+
throw new NamedCertificationFailure("GatewayParseBoundary");
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: "error-taxonomy",
|
|
124
|
+
capability: "error-taxonomy",
|
|
125
|
+
run() {
|
|
126
|
+
for (const code of [
|
|
127
|
+
"malformed_output",
|
|
128
|
+
"refusal",
|
|
129
|
+
"timeout",
|
|
130
|
+
"rate_limit",
|
|
131
|
+
"unavailable",
|
|
132
|
+
"policy_denied",
|
|
133
|
+
"cancelled",
|
|
134
|
+
"internal",
|
|
135
|
+
]) {
|
|
136
|
+
if (parseModelGatewayError({ code }).code !== code)
|
|
137
|
+
throw new NamedCertificationFailure("GatewayErrorTaxonomy");
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: "fallback-policy",
|
|
143
|
+
capability: "fallback-policy",
|
|
144
|
+
async run(adapter) {
|
|
145
|
+
const result = await runModelGateway(adapter, { input: { probe: true } }, {
|
|
146
|
+
routes: ["cert-route", "cert-fallback"],
|
|
147
|
+
retryableCodes: ["rate_limit", "unavailable"],
|
|
148
|
+
allowFallback: true,
|
|
149
|
+
budget: { maxAttempts: 2 },
|
|
150
|
+
});
|
|
151
|
+
if (result.evidence.some((item) => item.kind === "fallback"))
|
|
152
|
+
return;
|
|
153
|
+
if (!result.ok)
|
|
154
|
+
throw new NamedCertificationFailure("GatewayFallback");
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
id: "evidence-firewall",
|
|
159
|
+
capability: "evidence-firewall",
|
|
160
|
+
async run(adapter) {
|
|
161
|
+
const raw = await adapter.complete({
|
|
162
|
+
routeId: "cert-route",
|
|
163
|
+
input: { probe: true },
|
|
164
|
+
signal: new AbortController().signal,
|
|
165
|
+
envelope: { attempt: 1, attemptsRemaining: 0 },
|
|
166
|
+
});
|
|
167
|
+
if (parseModelGatewayResult(raw).ok === false && isRecordWithKey(raw, "evidence"))
|
|
168
|
+
throw new NamedCertificationFailure("GatewayEvidenceFirewall");
|
|
169
|
+
const result = await runModelGateway(adapter, { input: { prompt: "transient" } }, { routes: ["cert-route"], retryableCodes: [], budget: { maxAttempts: 1 } });
|
|
170
|
+
const evidence = JSON.stringify(result.evidence).toLowerCase();
|
|
171
|
+
if (/prompt|message|response|credential|secret|diagnostic|stack|content/.test(evidence))
|
|
172
|
+
throw new NamedCertificationFailure("GatewayEvidenceFirewall");
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function isRecordWithKey(value, key) {
|
|
179
|
+
return (typeof value === "object" &&
|
|
180
|
+
value !== null &&
|
|
181
|
+
!Array.isArray(value) &&
|
|
182
|
+
Object.hasOwn(value, key));
|
|
183
|
+
}
|
|
184
|
+
export const modelGatewayCertificationProfile = gatewayCertificationProfile;
|
|
185
|
+
/** Certification for lifecycle cleanup, capability truthfulness, authority, and isolation claims. */
|
|
186
|
+
export function deploymentCertificationProfile() {
|
|
187
|
+
return defineCertificationProfile({
|
|
188
|
+
id: "deployment-adapter",
|
|
189
|
+
version: 1,
|
|
190
|
+
capabilities: ["capability-truthfulness", "lifecycle", "cleanup", "isolation-claims"],
|
|
191
|
+
checks: [
|
|
192
|
+
{
|
|
193
|
+
id: "capability-truthfulness",
|
|
194
|
+
capability: "capability-truthfulness",
|
|
195
|
+
async run(adapter) {
|
|
196
|
+
const report = parseDeploymentCapabilityReport(await adapter.capabilityReport());
|
|
197
|
+
if (report.adapterId !== adapter.id)
|
|
198
|
+
throw new NamedCertificationFailure("DeploymentCapability");
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
id: "lifecycle",
|
|
203
|
+
capability: "lifecycle",
|
|
204
|
+
async run(adapter) {
|
|
205
|
+
const deployment = new AgentDeployment(adapter, createDeploymentAuthority({ workspaceMaxBytes: 1024 * 1024 }));
|
|
206
|
+
await deployment.prepare({ deploymentId: "cert-deployment" });
|
|
207
|
+
await deployment.start();
|
|
208
|
+
const inspection = await deployment.inspect();
|
|
209
|
+
if (inspection.state !== "running")
|
|
210
|
+
throw new NamedCertificationFailure("DeploymentLifecycle");
|
|
211
|
+
await deployment.cancel();
|
|
212
|
+
await deployment.dispose();
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
id: "cleanup",
|
|
217
|
+
capability: "cleanup",
|
|
218
|
+
async run(adapter) {
|
|
219
|
+
const deployment = new AgentDeployment(adapter, createDeploymentAuthority({ workspaceMaxBytes: 1024 * 1024 }));
|
|
220
|
+
await deployment.prepare({ deploymentId: "cert-cleanup" });
|
|
221
|
+
await deployment.dispose();
|
|
222
|
+
if (deployment.lifecycleState !== "disposed")
|
|
223
|
+
throw new NamedCertificationFailure("DeploymentCleanup");
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
id: "isolation-claims",
|
|
228
|
+
capability: "isolation-claims",
|
|
229
|
+
async run(adapter) {
|
|
230
|
+
const report = parseDeploymentCapabilityReport(await adapter.capabilityReport());
|
|
231
|
+
if (report.capabilities.hostileCodeIsolation === "os") {
|
|
232
|
+
if (adapter.verifyHostileCodeIsolation === undefined ||
|
|
233
|
+
!(await adapter.verifyHostileCodeIsolation()))
|
|
234
|
+
throw new NamedCertificationFailure("DeploymentIsolationClaim");
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
export const deploymentAdapterCertificationProfile = deploymentCertificationProfile;
|
|
242
|
+
//# sourceMappingURL=agent-certification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-certification.js","sourceRoot":"","sources":["../src/agent-certification.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,eAAe,EAEf,yBAAyB,EAEzB,+BAA+B,EAC/B,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,sBAAsB,GACvB,MAA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,EAAE,CAAA;gBAC5B,CAAC;aACF;YACD;gBACE,EAAE,EAAE,SAAS;gBACb,UAAU,EAAE,SAAS;gBACrB,KAAK,CAAC,GAAG,CAAC,OAAO;oBACf,MAAM,UAAU,GAAG,IAAI,eAAe,CACpC,OAAO,EACP,yBAAyB,CAAC,EAAE,iBAAiB,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAC9D,CAAA;oBACD,MAAM,UAAU,CAAC,OAAO,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC,CAAA;oBAC1D,MAAM,UAAU,CAAC,OAAO,EAAE,CAAA;oBAC1B,IAAI,UAAU,CAAC,cAAc,KAAK,UAAU;wBAC1C,MAAM,IAAI,yBAAyB,CAAC,mBAAmB,CAAC,CAAA;gBAC5D,CAAC;aACF;YACD;gBACE,EAAE,EAAE,kBAAkB;gBACtB,UAAU,EAAE,kBAAkB;gBAC9B,KAAK,CAAC,GAAG,CAAC,OAAO;oBACf,MAAM,MAAM,GAAG,+BAA+B,CAAC,MAAM,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAA;oBAChF,IAAI,MAAM,CAAC,YAAY,CAAC,oBAAoB,KAAK,IAAI,EAAE,CAAC;wBACtD,IACE,OAAO,CAAC,0BAA0B,KAAK,SAAS;4BAChD,CAAC,CAAC,MAAM,OAAO,CAAC,0BAA0B,EAAE,CAAC;4BAE7C,MAAM,IAAI,yBAAyB,CAAC,0BAA0B,CAAC,CAAA;oBACnE,CAAC;gBACH,CAAC;aACF;SACF;KACF,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,qCAAqC,GAAG,8BAA8B,CAAA"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nifrajs/testing/agent-eval` - a deterministic, evidence-only eval harness for agent runs.
|
|
3
|
+
*
|
|
4
|
+
* A suite is a bounded set of cases, each scored by one or more typed rubrics. A rubric is a closed
|
|
5
|
+
* contract: an ordered outcome allow-list, a finite score range, and a set of named numeric metrics.
|
|
6
|
+
* Nothing else is admitted - a verdict carrying free-form evaluator prose, an out-of-range score, or
|
|
7
|
+
* an unknown outcome is rejected at parse time. There is no opaque blended "agent score": the report
|
|
8
|
+
* is the evidence contract (ids, codes, bounded numbers, digests) and nothing more.
|
|
9
|
+
*
|
|
10
|
+
* Determinism is structural: cases run in sorted id order and every digest is taken over a canonical,
|
|
11
|
+
* order-independent projection, so reordering declarations cannot change a digest. Baseline
|
|
12
|
+
* comparison classifies each (case, rubric) as equal / improved / tolerated / regressed / missing /
|
|
13
|
+
* incomparable against explicit tolerances, and every regression carries a stable, addressable id.
|
|
14
|
+
*/
|
|
15
|
+
import { type FaultProfile } from "./fault-profile.js";
|
|
16
|
+
import { type EffectLedger } from "./idempotency.js";
|
|
17
|
+
/** A closed rubric contract. Outcomes are ordered worst -> best; the index is the outcome rank. */
|
|
18
|
+
export interface RubricSpec {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
/** Ordered outcome codes, worst first. Rank = index; a change in rank is an improvement/regression. */
|
|
21
|
+
readonly outcomes: readonly string[];
|
|
22
|
+
/** Finite inclusive score range. */
|
|
23
|
+
readonly score: {
|
|
24
|
+
readonly min: number;
|
|
25
|
+
readonly max: number;
|
|
26
|
+
};
|
|
27
|
+
/** Whether a higher score is better. Default true. Governs improved/regressed classification. */
|
|
28
|
+
readonly higherIsBetter?: boolean;
|
|
29
|
+
/** Allowed numeric metric names. A verdict metric outside this set is rejected. */
|
|
30
|
+
readonly metrics?: readonly string[];
|
|
31
|
+
}
|
|
32
|
+
/** One rubric's verdict on one case. Numbers and codes only; no free-form text field exists. */
|
|
33
|
+
export interface RubricVerdict {
|
|
34
|
+
readonly rubricId: string;
|
|
35
|
+
readonly outcome: string;
|
|
36
|
+
readonly score: number;
|
|
37
|
+
readonly metrics?: Readonly<Record<string, number>>;
|
|
38
|
+
}
|
|
39
|
+
/** One eval case. `evaluate` is a deterministic producer of rubric verdicts - evidence, not a run. */
|
|
40
|
+
export interface AgentEvalCase {
|
|
41
|
+
readonly id: string;
|
|
42
|
+
evaluate(): readonly RubricVerdict[] | PromiseLike<readonly RubricVerdict[]>;
|
|
43
|
+
}
|
|
44
|
+
export interface AgentEvalSuiteSpec {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly version?: number;
|
|
47
|
+
readonly rubrics: readonly RubricSpec[];
|
|
48
|
+
readonly cases: readonly AgentEvalCase[];
|
|
49
|
+
}
|
|
50
|
+
export interface AgentEvalSuite {
|
|
51
|
+
readonly id: string;
|
|
52
|
+
readonly version: number;
|
|
53
|
+
readonly caseIds: readonly string[];
|
|
54
|
+
readonly rubricIds: readonly string[];
|
|
55
|
+
run(): Promise<AgentEvalReport>;
|
|
56
|
+
}
|
|
57
|
+
/** The frozen shape of a rubric, embedded so a baseline comparison is self-contained. */
|
|
58
|
+
export interface RubricShape {
|
|
59
|
+
readonly rubricId: string;
|
|
60
|
+
readonly outcomes: readonly string[];
|
|
61
|
+
readonly scoreMin: number;
|
|
62
|
+
readonly scoreMax: number;
|
|
63
|
+
readonly higherIsBetter: boolean;
|
|
64
|
+
readonly digest: string;
|
|
65
|
+
}
|
|
66
|
+
export interface CaseResult {
|
|
67
|
+
readonly caseId: string;
|
|
68
|
+
readonly verdicts: readonly RubricVerdict[];
|
|
69
|
+
readonly digest: string;
|
|
70
|
+
}
|
|
71
|
+
export interface AgentEvalReport {
|
|
72
|
+
readonly version: 1;
|
|
73
|
+
readonly suiteId: string;
|
|
74
|
+
readonly suiteVersion: number;
|
|
75
|
+
readonly rubricShapes: readonly RubricShape[];
|
|
76
|
+
readonly cases: readonly CaseResult[];
|
|
77
|
+
readonly digest: string;
|
|
78
|
+
}
|
|
79
|
+
export type ComparisonCode = "equal" | "improved" | "tolerated" | "regressed" | "missing" | "incomparable";
|
|
80
|
+
/** Explicit tolerance for a score regression. `rubricId` omitted applies to every rubric. */
|
|
81
|
+
export interface ScoreTolerance {
|
|
82
|
+
readonly rubricId?: string;
|
|
83
|
+
/** Absolute worsening tolerated. Default 0. */
|
|
84
|
+
readonly abs?: number;
|
|
85
|
+
/** Relative worsening tolerated, as a fraction of the baseline magnitude. Default 0. */
|
|
86
|
+
readonly rel?: number;
|
|
87
|
+
}
|
|
88
|
+
export interface BaselineOptions {
|
|
89
|
+
readonly tolerances?: readonly ScoreTolerance[];
|
|
90
|
+
/** Comparison codes that fail the assertion. Default `["regressed"]`. */
|
|
91
|
+
readonly failOn?: readonly ComparisonCode[];
|
|
92
|
+
}
|
|
93
|
+
export interface CaseComparison {
|
|
94
|
+
readonly caseId: string;
|
|
95
|
+
readonly rubricId: string;
|
|
96
|
+
readonly code: ComparisonCode;
|
|
97
|
+
readonly regressionId: string;
|
|
98
|
+
readonly baselineScore?: number;
|
|
99
|
+
readonly currentScore?: number;
|
|
100
|
+
}
|
|
101
|
+
export interface BaselineComparison {
|
|
102
|
+
readonly suiteId: string;
|
|
103
|
+
readonly comparisons: readonly CaseComparison[];
|
|
104
|
+
readonly regressions: readonly string[];
|
|
105
|
+
readonly digest: string;
|
|
106
|
+
}
|
|
107
|
+
/** Thrown by {@link assertAgentEvalBaseline} when a comparison contains a failing code. */
|
|
108
|
+
export declare class AgentEvalRegressionError extends Error {
|
|
109
|
+
readonly comparison: BaselineComparison;
|
|
110
|
+
constructor(comparison: BaselineComparison);
|
|
111
|
+
}
|
|
112
|
+
/** Fault boundaries covered by the public deterministic matrix. */
|
|
113
|
+
export type AgentFailureMatrixKind = "model" | "tool" | "approval" | "cancellation" | "lease" | "cursor" | "registry" | "deployment";
|
|
114
|
+
export interface AgentFailureMatrixCase {
|
|
115
|
+
readonly id: string;
|
|
116
|
+
readonly kind: AgentFailureMatrixKind;
|
|
117
|
+
readonly scheduleToken: string;
|
|
118
|
+
readonly ok: boolean;
|
|
119
|
+
readonly regressionId: string;
|
|
120
|
+
}
|
|
121
|
+
export interface AgentFailureMatrixReport {
|
|
122
|
+
readonly version: 1;
|
|
123
|
+
readonly seed: number;
|
|
124
|
+
readonly cases: readonly AgentFailureMatrixCase[];
|
|
125
|
+
readonly digest: string;
|
|
126
|
+
readonly ok: boolean;
|
|
127
|
+
}
|
|
128
|
+
export declare class AgentFailureMatrixError extends Error {
|
|
129
|
+
readonly report: AgentFailureMatrixReport;
|
|
130
|
+
constructor(report: AgentFailureMatrixReport);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Run the same token-only crash fixture at each agent boundary. The implementation intentionally
|
|
134
|
+
* delegates scheduling and replay identity to the existing failure laboratory; this is a matrix
|
|
135
|
+
* consumer, not a second fault engine.
|
|
136
|
+
*/
|
|
137
|
+
export declare function runAgentFailureMatrix(options?: {
|
|
138
|
+
readonly seed?: number;
|
|
139
|
+
}): Promise<AgentFailureMatrixReport>;
|
|
140
|
+
export declare function assertAgentFailureMatrix(report: AgentFailureMatrixReport): void;
|
|
141
|
+
export interface AgentEvalComponentEvidence {
|
|
142
|
+
readonly id: "trajectory" | "fault-profile" | "contract-lab" | "idempotency" | "certification";
|
|
143
|
+
readonly ok: boolean;
|
|
144
|
+
readonly code?: string;
|
|
145
|
+
readonly digest?: string;
|
|
146
|
+
}
|
|
147
|
+
export interface AgentEvalCompositionOptions {
|
|
148
|
+
readonly suite: AgentEvalSuite;
|
|
149
|
+
readonly trajectory?: () => Promise<{
|
|
150
|
+
readonly ok: boolean;
|
|
151
|
+
readonly digest: string;
|
|
152
|
+
readonly regressionIds?: readonly string[];
|
|
153
|
+
}>;
|
|
154
|
+
readonly faultProfile?: {
|
|
155
|
+
readonly profile: FaultProfile;
|
|
156
|
+
readonly seed?: number;
|
|
157
|
+
};
|
|
158
|
+
readonly contractLab?: () => Promise<{
|
|
159
|
+
readonly ok: boolean;
|
|
160
|
+
readonly digest?: string;
|
|
161
|
+
readonly code?: string;
|
|
162
|
+
}>;
|
|
163
|
+
readonly idempotency?: {
|
|
164
|
+
readonly run: () => Promise<EffectLedger> | EffectLedger;
|
|
165
|
+
readonly runs?: number;
|
|
166
|
+
};
|
|
167
|
+
readonly certification?: () => Promise<{
|
|
168
|
+
readonly ok: boolean;
|
|
169
|
+
readonly digest?: string;
|
|
170
|
+
readonly code?: string;
|
|
171
|
+
}>;
|
|
172
|
+
}
|
|
173
|
+
export interface AgentEvalCompositionReport {
|
|
174
|
+
readonly version: 1;
|
|
175
|
+
readonly suite: AgentEvalReport;
|
|
176
|
+
readonly components: readonly AgentEvalComponentEvidence[];
|
|
177
|
+
readonly regressionIds: readonly string[];
|
|
178
|
+
readonly digest: string;
|
|
179
|
+
readonly ok: boolean;
|
|
180
|
+
}
|
|
181
|
+
/** Compose existing trajectory, fault, contract, idempotency, and certification owners. */
|
|
182
|
+
export declare function runAgentEvalComposition(options: AgentEvalCompositionOptions): Promise<AgentEvalCompositionReport>;
|
|
183
|
+
export declare function assertAgentEval(report: AgentEvalCompositionReport): void;
|
|
184
|
+
/** Parse one verdict against its rubric. Fails closed on unknown outcome, bad range, or stray key. */
|
|
185
|
+
export declare function parseRubricVerdict(rubric: RubricSpec, value: unknown): RubricVerdict;
|
|
186
|
+
/** Declare a bounded, deterministic eval suite. Duplicate case or rubric ids fail closed. */
|
|
187
|
+
export declare function defineAgentEvalSuite(spec: AgentEvalSuiteSpec): AgentEvalSuite;
|
|
188
|
+
/** Compare a fresh report against a baseline report. Every (case, rubric) gets a stable id. */
|
|
189
|
+
export declare function compareAgentEvalBaseline(baseline: AgentEvalReport, current: AgentEvalReport, options?: BaselineOptions): Promise<BaselineComparison>;
|
|
190
|
+
/** Assert no failing comparison. Throws {@link AgentEvalRegressionError} with the stable ids. */
|
|
191
|
+
export declare function assertAgentEvalBaseline(baseline: AgentEvalReport, current: AgentEvalReport, options?: BaselineOptions): Promise<BaselineComparison>;
|
|
192
|
+
//# sourceMappingURL=agent-eval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-eval.d.ts","sourceRoot":"","sources":["../src/agent-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAA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