@tangle-network/agent-eval 2.0.16 → 2.0.18
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/CHANGELOG.md +17 -0
- package/dist/analyst/index.d.ts +20 -2
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +3 -3
- package/dist/app-grade/index.d.ts +1 -1
- package/dist/{benchmark-command-DgR1i30h.js → benchmark-command-CZbrh9bS.js} +27 -8
- package/dist/benchmark-command-CZbrh9bS.js.map +1 -0
- package/dist/benchmarks/index.d.ts +13 -0
- package/dist/benchmarks/index.d.ts.map +1 -1
- package/dist/benchmarks/index.js +100 -11
- package/dist/benchmarks/index.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/dspy-rlm-engine-DFgGrKzg.js +1613 -0
- package/dist/dspy-rlm-engine-DFgGrKzg.js.map +1 -0
- package/dist/experiment/index.d.ts +74 -5
- package/dist/experiment/index.d.ts.map +1 -1
- package/dist/experiment/index.js +196 -13
- package/dist/experiment/index.js.map +1 -1
- package/dist/{findings-store-Drnjid7m.js → findings-store-DcBkRLDk.js} +2 -2
- package/dist/{findings-store-Drnjid7m.js.map → findings-store-DcBkRLDk.js.map} +1 -1
- package/dist/{index-B8bNGE_2.d.ts → index-4khf0Q7g.d.ts} +236 -2
- package/dist/index-4khf0Q7g.d.ts.map +1 -0
- package/dist/{index-BkWxigto.d.ts → index-Cq_5SLfF.d.ts} +6 -236
- package/dist/index-Cq_5SLfF.d.ts.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -1087
- package/dist/index.js.map +1 -1
- package/dist/openapi.json +1 -1
- package/dist/wire/index.d.ts +2 -2
- package/docs/experiment.md +31 -1
- package/docs/trace-contracts.md +23 -0
- package/package.json +1 -1
- package/dist/benchmark-command-DgR1i30h.js.map +0 -1
- package/dist/dspy-rlm-engine-CR5MSL2k.js +0 -463
- package/dist/dspy-rlm-engine-CR5MSL2k.js.map +0 -1
- package/dist/index-B8bNGE_2.d.ts.map +0 -1
- package/dist/index-BkWxigto.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
|
|
2
|
-
import { c as errorMessage$1, i as JudgeError,
|
|
2
|
+
import { c as errorMessage$1, i as JudgeError, o as NotFoundError, r as ConfigError, s as ValidationError, t as AgentEvalError } from "./errors-DeEEV9Vx.js";
|
|
3
3
|
import { a as hashCanonical, r as canonicalString } from "./canonical-DKgL_Wby.js";
|
|
4
4
|
import { a as agentProfileModelId, i as agentProfileId, n as HARNESS_NATIVE_MODEL, o as expandProfileAxes, r as agentProfileHash, s as harnessAxisOf, t as CODING_HARNESSES } from "./agent-profile-CCw6EXWW.js";
|
|
5
5
|
import { a as groupRunsByAgentProfileCell, c as verifyAgentProfileCell, i as buildAgentProfileCell, l as hashJson, o as toAgentProfileJson, r as agentProfileCellKey, s as validateAgentProfileCell, t as AGENT_PROFILE_KINDS, u as manifestContentDigest } from "./agent-profile-cell-CUthydZB.js";
|
|
@@ -41,6 +41,7 @@ import { _ as exportRunAsOtlp, c as describeTraceInsightScope, g as analyzeTrace
|
|
|
41
41
|
import { t as TraceEmitter } from "./emitter-xN9wGTVw.js";
|
|
42
42
|
import { n as assertRunCaptured, t as RunIntegrityError } from "./integrity-DOHt1mwU.js";
|
|
43
43
|
import { n as InMemoryTraceStore, t as FileSystemTraceStore } from "./store-ZykIyQmy.js";
|
|
44
|
+
import { _ as normalizePredicate, a as evaluateTraceContract, c as explainTraceContract, d as assertOrder, f as assertRule, g as RUN_STATUSES, h as ORDER_MODES, i as checkTraceContracts, l as assertContract, m as ARGUMENT_TYPES, o as describeCheck, p as ARGUMENT_OCCURRENCES, r as contractSpansFromHarnessSession, s as describePredicate, t as createDspyRlmTraceEngine, u as assertCount } from "./dspy-rlm-engine-DFgGrKzg.js";
|
|
44
45
|
import { t as packageVersion$1 } from "./package-version-CJl_pY9W.js";
|
|
45
46
|
import { n as trajectoryTimingBoundary, t as buildTrajectory } from "./trajectory-CKVZaQoQ.js";
|
|
46
47
|
import { i as failureBlame, n as classifyFailure, r as classifyFailureReason } from "./failure-taxonomy-9eQfXKoW.js";
|
|
@@ -53,8 +54,7 @@ import "./rollout-CbHMVoDr.js";
|
|
|
53
54
|
import { t as mintRolloutRows } from "./mint-B4n1pRRd.js";
|
|
54
55
|
import { i as sequentialPairedPower, n as pairedEvalueSequence, r as sequentialCrossingHorizon, t as evaluateInterimReleaseConfidence } from "./sequential-DR-pnYQ7.js";
|
|
55
56
|
import { n as paidJsonChat } from "./chat-json-call-gu3deRID.js";
|
|
56
|
-
import { t as
|
|
57
|
-
import { n as diffFindings, r as createChatTraceEngine, t as FindingsStore } from "./findings-store-Drnjid7m.js";
|
|
57
|
+
import { n as diffFindings, r as createChatTraceEngine, t as FindingsStore } from "./findings-store-DcBkRLDk.js";
|
|
58
58
|
import { t as estimateTokens } from "./metrics-C6pXdupw.js";
|
|
59
59
|
import { a as budgetBreachView, i as failureClusterView, n as computeToolUseMetrics, r as judgeAgreementView, t as toolWasteView } from "./tool-waste-BZnYSa6J.js";
|
|
60
60
|
import { _ as analyzeSeries, a as judgeGateDecision, c as snapshotFromJudgeAgreement, g as withJudgeRetry, i as assertJudgeMayGate, n as JudgeGateRefusedError, o as measureJudgeAgreement, r as addCalibrationVerdicts, s as registerCalibrationSet, t as DEFAULT_JUDGE_GATE_POLICY } from "./judge-gate-WgYqQ9LA.js";
|
|
@@ -63,7 +63,7 @@ import { n as bootstrapCi, t as evaluateReleaseConfidence } from "./release-conf
|
|
|
63
63
|
import { createHash } from "node:crypto";
|
|
64
64
|
import { accessSync, appendFileSync, constants, cpSync, existsSync, mkdirSync, promises, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
65
65
|
import { basename, delimiter, dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
|
|
66
|
-
import {
|
|
66
|
+
import { SPAN_KINDS } from "@tangle-network/agent-trace-contract";
|
|
67
67
|
import { spawnSync } from "node:child_process";
|
|
68
68
|
// src/profile/baselines.ts
|
|
69
69
|
/**
|
|
@@ -1026,441 +1026,6 @@ function formatScorecardDiff(diff) {
|
|
|
1026
1026
|
}
|
|
1027
1027
|
return lines.join("\n");
|
|
1028
1028
|
}
|
|
1029
|
-
// src/trace-contracts/spans.ts
|
|
1030
|
-
const EVAL_KIND_TO_CONTRACT_KIND = /* @__PURE__ */ new Map([["judge", "EVALUATOR"], ["retrieval", "RETRIEVER"]]);
|
|
1031
|
-
/**
|
|
1032
|
-
* The span's contract kind: a declared kind when recognised, else inferred.
|
|
1033
|
-
* A top-level `kind` counts as a declaration only when it names a contract
|
|
1034
|
-
* kind; OTLP words such as `SPAN_KIND_INTERNAL` and the eval kinds `sandbox`
|
|
1035
|
-
* and `custom` fall through to the span-kind attribute and name signals.
|
|
1036
|
-
*/
|
|
1037
|
-
function contractSpanKind(span) {
|
|
1038
|
-
const raw = typeof span.kind === "string" ? span.kind : void 0;
|
|
1039
|
-
const mapped = raw === void 0 ? void 0 : EVAL_KIND_TO_CONTRACT_KIND.get(raw) ?? raw.toUpperCase();
|
|
1040
|
-
const declared = mapped !== void 0 && SPAN_KINDS.includes(mapped) ? mapped : void 0;
|
|
1041
|
-
return resolveSpanKind({
|
|
1042
|
-
...declared === void 0 ? {} : { kind: declared },
|
|
1043
|
-
name: span.name,
|
|
1044
|
-
attributes: span.attributes ?? {}
|
|
1045
|
-
});
|
|
1046
|
-
}
|
|
1047
|
-
/**
|
|
1048
|
-
* Tool name: `span.toolName` (typed ToolSpan) → the tool-name attributes
|
|
1049
|
-
* (`gen_ai.tool.name`, `tool.name`, ..., `toolName`) → `span.name` when the
|
|
1050
|
-
* span is a TOOL span.
|
|
1051
|
-
*/
|
|
1052
|
-
function contractSpanToolName(span) {
|
|
1053
|
-
if (typeof span.toolName === "string") return span.toolName;
|
|
1054
|
-
const attributes = span.attributes ?? {};
|
|
1055
|
-
const fromAttr = firstStringAttr(attributes, TOOL_NAME_ATTR_KEYS) ?? firstStringAttr(attributes, ["toolName"]);
|
|
1056
|
-
if (fromAttr !== void 0) return fromAttr;
|
|
1057
|
-
if (typeof span.name === "string" && contractSpanKind(span) === "TOOL") return span.name;
|
|
1058
|
-
}
|
|
1059
|
-
function spanModel(span) {
|
|
1060
|
-
if (typeof span.model === "string" && span.model.length > 0) return span.model;
|
|
1061
|
-
return firstStringAttr(span.attributes ?? {}, MODEL_ATTR_KEYS);
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* Input plus output tokens, or `undefined` when either side is unrecorded.
|
|
1065
|
-
* Input follows the OTel GenAI definition — prompt tokens plus any cache
|
|
1066
|
-
* read and cache write tokens the span records — because a cached call's
|
|
1067
|
-
* `INPUT_TOKEN_ATTR_KEYS` value (`llm.token_count.prompt` and its aliases)
|
|
1068
|
-
* carries only the uncached remainder, and a cache-heavy call can spend far
|
|
1069
|
-
* more on cache reads and writes than on that remainder. `llm.maxTotalTokens`
|
|
1070
|
-
* would otherwise pass runs at a small fraction of what they actually cost.
|
|
1071
|
-
*/
|
|
1072
|
-
function spanTotalTokens(span) {
|
|
1073
|
-
const attributes = span.attributes ?? {};
|
|
1074
|
-
const input = finite(span.inputTokens) ?? firstNumberAttr(attributes, INPUT_TOKEN_ATTR_KEYS);
|
|
1075
|
-
const output = finite(span.outputTokens) ?? firstNumberAttr(attributes, OUTPUT_TOKEN_ATTR_KEYS);
|
|
1076
|
-
if (input === void 0 || output === void 0) return void 0;
|
|
1077
|
-
const cacheRead = firstNumberAttr(attributes, ["llm.token_count.prompt_cache_hit"]) ?? 0;
|
|
1078
|
-
const cacheWrite = firstNumberAttr(attributes, ["llm.token_count.prompt_cache_write"]) ?? 0;
|
|
1079
|
-
return input + output + cacheRead + cacheWrite;
|
|
1080
|
-
}
|
|
1081
|
-
const ARGUMENT_ATTR_KEYS = [
|
|
1082
|
-
"gen_ai.tool.call.arguments",
|
|
1083
|
-
"tool.arguments",
|
|
1084
|
-
"input.value"
|
|
1085
|
-
];
|
|
1086
|
-
/** The call's arguments: the typed `args` field, else the argument attributes.
|
|
1087
|
-
* JSON strings are parsed; an unparseable string is kept as a string. */
|
|
1088
|
-
function spanArguments(span) {
|
|
1089
|
-
if (span.argsCaptured === false || span.attributes?.["tool.args_captured"] === false) return {
|
|
1090
|
-
known: false,
|
|
1091
|
-
reason: "arguments were not captured"
|
|
1092
|
-
};
|
|
1093
|
-
if (span.args !== void 0) return {
|
|
1094
|
-
known: true,
|
|
1095
|
-
value: parseJsonString(span.args)
|
|
1096
|
-
};
|
|
1097
|
-
for (const key of ARGUMENT_ATTR_KEYS) {
|
|
1098
|
-
const value = span.attributes?.[key];
|
|
1099
|
-
if (value !== void 0 && value !== null) return {
|
|
1100
|
-
known: true,
|
|
1101
|
-
value: parseJsonString(value)
|
|
1102
|
-
};
|
|
1103
|
-
}
|
|
1104
|
-
return {
|
|
1105
|
-
known: false,
|
|
1106
|
-
reason: "the span carries no argument evidence"
|
|
1107
|
-
};
|
|
1108
|
-
}
|
|
1109
|
-
/** The tool names a span records as offered to the model. */
|
|
1110
|
-
function spanOfferedTools(span) {
|
|
1111
|
-
const raw = span.attributes?.[ATTR.toolDefinitions];
|
|
1112
|
-
if (raw === void 0 || raw === null) return { recorded: false };
|
|
1113
|
-
const value = parseJsonString(raw);
|
|
1114
|
-
if (!Array.isArray(value)) return {
|
|
1115
|
-
recorded: true,
|
|
1116
|
-
unreadable: `${ATTR.toolDefinitions} is not a list`
|
|
1117
|
-
};
|
|
1118
|
-
const names = [];
|
|
1119
|
-
for (const entry of value) {
|
|
1120
|
-
const name = typeof entry === "string" ? entry : definitionName(entry);
|
|
1121
|
-
if (name === void 0) return {
|
|
1122
|
-
recorded: true,
|
|
1123
|
-
unreadable: `${ATTR.toolDefinitions} has an entry without a tool name`
|
|
1124
|
-
};
|
|
1125
|
-
names.push(name);
|
|
1126
|
-
}
|
|
1127
|
-
return {
|
|
1128
|
-
recorded: true,
|
|
1129
|
-
names
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
1132
|
-
function definitionName(entry) {
|
|
1133
|
-
if (entry === null || typeof entry !== "object") return void 0;
|
|
1134
|
-
const record = entry;
|
|
1135
|
-
if (typeof record.name === "string" && record.name.length > 0) return record.name;
|
|
1136
|
-
const fn = record.function;
|
|
1137
|
-
return fn !== null && typeof fn === "object" && typeof fn.name === "string" && fn.name.length > 0 ? fn.name : void 0;
|
|
1138
|
-
}
|
|
1139
|
-
function parseJsonString(value) {
|
|
1140
|
-
if (typeof value !== "string") return value;
|
|
1141
|
-
try {
|
|
1142
|
-
return JSON.parse(value);
|
|
1143
|
-
} catch {
|
|
1144
|
-
return value;
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
function finite(value) {
|
|
1148
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1149
|
-
}
|
|
1150
|
-
function isSpanError(span) {
|
|
1151
|
-
return typeof span.status === "string" && /^(?:error|status_code_error)$/i.test(span.status);
|
|
1152
|
-
}
|
|
1153
|
-
// src/trace-contracts/predicates.ts
|
|
1154
|
-
function isSerializedRegex(v) {
|
|
1155
|
-
return typeof v === "object" && v !== null && typeof v.$regex === "string" && typeof v.flags === "string";
|
|
1156
|
-
}
|
|
1157
|
-
function isOneOfMatcher(v) {
|
|
1158
|
-
return typeof v === "object" && v !== null && Array.isArray(v.oneOf);
|
|
1159
|
-
}
|
|
1160
|
-
function isRegexValue(v) {
|
|
1161
|
-
return v instanceof RegExp || isSerializedRegex(v);
|
|
1162
|
-
}
|
|
1163
|
-
function matchText(actual, matcher) {
|
|
1164
|
-
if (typeof actual !== "string") return false;
|
|
1165
|
-
if (typeof matcher === "string") return actual === matcher;
|
|
1166
|
-
if (matcher instanceof RegExp) return matcher.test(actual);
|
|
1167
|
-
if (isOneOfMatcher(matcher)) return matcher.oneOf.includes(actual);
|
|
1168
|
-
return new RegExp(matcher.$regex, matcher.flags).test(actual);
|
|
1169
|
-
}
|
|
1170
|
-
function assertMatcher(m, where) {
|
|
1171
|
-
if (typeof m === "string" || m instanceof RegExp) return;
|
|
1172
|
-
if (isSerializedRegex(m)) {
|
|
1173
|
-
try {
|
|
1174
|
-
new RegExp(m.$regex, m.flags);
|
|
1175
|
-
} catch (error) {
|
|
1176
|
-
throw new ValidationError(`${where}: invalid regex /${m.$regex}/${m.flags}: ${String(error)}`);
|
|
1177
|
-
}
|
|
1178
|
-
return;
|
|
1179
|
-
}
|
|
1180
|
-
if (isOneOfMatcher(m)) {
|
|
1181
|
-
if (m.oneOf.length === 0 || !m.oneOf.every((x) => typeof x === "string")) throw new ValidationError(`${where}: "oneOf" must be a non-empty array of strings`);
|
|
1182
|
-
return;
|
|
1183
|
-
}
|
|
1184
|
-
throw new ValidationError(`${where}: matcher must be string | RegExp | SerializedRegex | { oneOf }`);
|
|
1185
|
-
}
|
|
1186
|
-
function assertPredicate(value, where) {
|
|
1187
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new ValidationError(`${where}: predicate must be an object, got ${typeof value}`);
|
|
1188
|
-
const p = value;
|
|
1189
|
-
for (const field of [
|
|
1190
|
-
"name",
|
|
1191
|
-
"tool",
|
|
1192
|
-
"model"
|
|
1193
|
-
]) if (p[field] !== void 0) assertMatcher(p[field], `${where} "${field}"`);
|
|
1194
|
-
if (p.kind !== void 0 && !SPAN_KINDS.includes(p.kind)) throw new ValidationError(`${where}: "kind" must be one of ${SPAN_KINDS.join(", ")}`);
|
|
1195
|
-
if (p.attr !== void 0 && (p.attr === null || typeof p.attr !== "object" || Array.isArray(p.attr))) throw new ValidationError(`${where}: "attr" must be a plain object`);
|
|
1196
|
-
for (const [key, expected] of Object.entries(p.attr ?? {})) if (expected !== null && typeof expected === "object") assertMatcher(expected, `${where} attr "${key}"`);
|
|
1197
|
-
if (p.not !== void 0) assertPredicate(p.not, `${where} "not"`);
|
|
1198
|
-
if (p.requiresCustom && typeof p.custom !== "function") throw new ValidationError(`${where}: rule was built with a custom predicate function, which does not survive JSON serialization — re-attach \`custom\` after deserializing or drop the rule`);
|
|
1199
|
-
const hasAttr = p.attr !== void 0 && Object.keys(p.attr).length > 0;
|
|
1200
|
-
if (p.name === void 0 && p.tool === void 0 && p.model === void 0 && p.kind === void 0 && p.not === void 0 && !hasAttr && typeof p.custom !== "function") throw new ValidationError(`${where}: empty predicate would match every span — specify name, tool, model, kind, attr, not, or custom`);
|
|
1201
|
-
}
|
|
1202
|
-
function predicateMatches(span, p) {
|
|
1203
|
-
if (p.kind !== void 0 && contractSpanKind(span) !== p.kind) return false;
|
|
1204
|
-
if (p.name !== void 0 && !matchText(span.name, p.name)) return false;
|
|
1205
|
-
if (p.tool !== void 0 && !matchText(contractSpanToolName(span), p.tool)) return false;
|
|
1206
|
-
if (p.model !== void 0 && !matchText(spanModel(span), p.model)) return false;
|
|
1207
|
-
if (p.attr !== void 0) for (const [key, expected] of Object.entries(p.attr)) {
|
|
1208
|
-
const actual = span.attributes?.[key];
|
|
1209
|
-
if (isRegexValue(expected) || isOneOfMatcher(expected)) {
|
|
1210
|
-
if (!matchText(typeof actual === "string" ? actual : void 0, expected)) return false;
|
|
1211
|
-
} else if (actual !== expected) return false;
|
|
1212
|
-
}
|
|
1213
|
-
if (p.not !== void 0 && predicateMatches(span, p.not)) return false;
|
|
1214
|
-
if (p.custom !== void 0 && !p.custom(span)) return false;
|
|
1215
|
-
return true;
|
|
1216
|
-
}
|
|
1217
|
-
function normalizeMatcher(m) {
|
|
1218
|
-
if (m instanceof RegExp) return {
|
|
1219
|
-
$regex: m.source,
|
|
1220
|
-
flags: m.flags
|
|
1221
|
-
};
|
|
1222
|
-
if (isOneOfMatcher(m)) return { oneOf: [...m.oneOf] };
|
|
1223
|
-
return m;
|
|
1224
|
-
}
|
|
1225
|
-
function normalizePredicate(p, where) {
|
|
1226
|
-
const kind = typeof p?.kind === "string" ? p.kind.toUpperCase() : p?.kind;
|
|
1227
|
-
const withKind = kind === void 0 ? p : {
|
|
1228
|
-
...p,
|
|
1229
|
-
kind
|
|
1230
|
-
};
|
|
1231
|
-
assertPredicate(withKind, where);
|
|
1232
|
-
const out = {};
|
|
1233
|
-
if (withKind.kind !== void 0) out.kind = withKind.kind;
|
|
1234
|
-
if (withKind.name !== void 0) out.name = normalizeMatcher(withKind.name);
|
|
1235
|
-
if (withKind.tool !== void 0) out.tool = normalizeMatcher(withKind.tool);
|
|
1236
|
-
if (withKind.model !== void 0) out.model = normalizeMatcher(withKind.model);
|
|
1237
|
-
if (withKind.attr !== void 0) out.attr = Object.fromEntries(Object.entries(withKind.attr).map(([k, v]) => [k, v instanceof RegExp ? normalizeMatcher(v) : v]));
|
|
1238
|
-
if (withKind.not !== void 0) out.not = normalizePredicate(withKind.not, `${where} "not"`);
|
|
1239
|
-
if (typeof withKind.custom === "function") {
|
|
1240
|
-
out.custom = withKind.custom;
|
|
1241
|
-
out.requiresCustom = true;
|
|
1242
|
-
}
|
|
1243
|
-
return out;
|
|
1244
|
-
}
|
|
1245
|
-
// src/trace-contracts/types.ts
|
|
1246
|
-
const ORDER_MODES = [
|
|
1247
|
-
"start-order",
|
|
1248
|
-
"finish-before-start",
|
|
1249
|
-
"all-occurrences"
|
|
1250
|
-
];
|
|
1251
|
-
const RUN_STATUSES = [
|
|
1252
|
-
"running",
|
|
1253
|
-
"completed",
|
|
1254
|
-
"failed",
|
|
1255
|
-
"aborted"
|
|
1256
|
-
];
|
|
1257
|
-
const ARGUMENT_OCCURRENCES = [
|
|
1258
|
-
"first",
|
|
1259
|
-
"last",
|
|
1260
|
-
"any",
|
|
1261
|
-
"all"
|
|
1262
|
-
];
|
|
1263
|
-
const ARGUMENT_TYPES = [
|
|
1264
|
-
"string",
|
|
1265
|
-
"number",
|
|
1266
|
-
"boolean",
|
|
1267
|
-
"object",
|
|
1268
|
-
"array",
|
|
1269
|
-
"null"
|
|
1270
|
-
];
|
|
1271
|
-
// src/trace-contracts/validate.ts
|
|
1272
|
-
function assertOrder(order, where) {
|
|
1273
|
-
if (order === void 0) return void 0;
|
|
1274
|
-
if (!ORDER_MODES.includes(order)) throw new ValidationError(`${where}: order must be one of ${ORDER_MODES.join(", ")}`);
|
|
1275
|
-
return order;
|
|
1276
|
-
}
|
|
1277
|
-
function assertCount(max, where) {
|
|
1278
|
-
if (typeof max !== "number" || !Number.isInteger(max) || max < 0) throw new ValidationError(`${where}: max must be a non-negative integer`);
|
|
1279
|
-
}
|
|
1280
|
-
function assertJsonPointer(pointer, where) {
|
|
1281
|
-
if (typeof pointer !== "string" || pointer !== "" && !pointer.startsWith("/")) throw new ValidationError(`${where}: pointer must be an RFC 6901 JSON Pointer ('' or '/a/b')`);
|
|
1282
|
-
if (/~(?![01])/.test(pointer)) throw new ValidationError(`${where}: pointer has an invalid escape; use ~0 for ~ and ~1 for /`);
|
|
1283
|
-
}
|
|
1284
|
-
/** A non-empty list of distinct, non-empty tool names. */
|
|
1285
|
-
function assertNames(names, where) {
|
|
1286
|
-
if (!Array.isArray(names) || names.length === 0) throw new ValidationError(`${where} must be a non-empty array of tool names`);
|
|
1287
|
-
for (const name of names) if (typeof name !== "string" || name.length === 0) throw new ValidationError(`${where} must hold non-empty tool names`);
|
|
1288
|
-
const dup = names.find((n, i) => names.indexOf(n) !== i);
|
|
1289
|
-
if (dup !== void 0) throw new ValidationError(`${where} lists "${dup}" twice`);
|
|
1290
|
-
return names;
|
|
1291
|
-
}
|
|
1292
|
-
function assertArgumentCheck(check, where) {
|
|
1293
|
-
const c = check;
|
|
1294
|
-
if (c === null || typeof c !== "object") throw new ValidationError(`${where}: check must be an object`);
|
|
1295
|
-
switch (c.op) {
|
|
1296
|
-
case "exists": return;
|
|
1297
|
-
case "equals":
|
|
1298
|
-
if (!("value" in c)) throw new ValidationError(`${where}: equals needs a value`);
|
|
1299
|
-
return;
|
|
1300
|
-
case "oneOf":
|
|
1301
|
-
if (!Array.isArray(c.values) || c.values.length === 0) throw new ValidationError(`${where}: oneOf needs a non-empty values array`);
|
|
1302
|
-
return;
|
|
1303
|
-
case "type":
|
|
1304
|
-
if (!ARGUMENT_TYPES.includes(c.type)) throw new ValidationError(`${where}: type must be one of ${ARGUMENT_TYPES.join(", ")}`);
|
|
1305
|
-
return;
|
|
1306
|
-
default: throw new ValidationError(`${where}: check.op must be exists, equals, oneOf, or type`);
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
function assertRule(rule, where) {
|
|
1310
|
-
switch (rule.kind) {
|
|
1311
|
-
case "always":
|
|
1312
|
-
case "never":
|
|
1313
|
-
case "eventually":
|
|
1314
|
-
assertPredicate(rule.p, `${where} (p)`);
|
|
1315
|
-
return;
|
|
1316
|
-
case "precedes":
|
|
1317
|
-
assertPredicate(rule.a, `${where} (a)`);
|
|
1318
|
-
assertPredicate(rule.b, `${where} (b)`);
|
|
1319
|
-
assertOrder(rule.order, where);
|
|
1320
|
-
return;
|
|
1321
|
-
case "neverUnless":
|
|
1322
|
-
assertPredicate(rule.p, `${where} (p)`);
|
|
1323
|
-
assertPredicate(rule.prior, `${where} (prior)`);
|
|
1324
|
-
assertOrder(rule.order, where);
|
|
1325
|
-
return;
|
|
1326
|
-
case "atMost":
|
|
1327
|
-
case "tokensAtMost":
|
|
1328
|
-
assertPredicate(rule.p, `${where} (p)`);
|
|
1329
|
-
assertCount(rule.max, where);
|
|
1330
|
-
return;
|
|
1331
|
-
case "run":
|
|
1332
|
-
if (!rule.requireCompleted && rule.allowedStatuses === void 0 && rule.maxDurationMs === void 0) throw new ValidationError(`${where}: run rule checks nothing`);
|
|
1333
|
-
if (rule.requireCompleted !== void 0 && typeof rule.requireCompleted !== "boolean") throw new ValidationError(`${where}: requireCompleted must be a boolean`);
|
|
1334
|
-
if (rule.allowedStatuses !== void 0) {
|
|
1335
|
-
if (!Array.isArray(rule.allowedStatuses) || rule.allowedStatuses.length === 0) throw new ValidationError(`${where}: allowedStatuses must be a non-empty array`);
|
|
1336
|
-
for (const status of rule.allowedStatuses) if (!RUN_STATUSES.includes(status)) throw new ValidationError(`${where}: unknown run status "${String(status)}" — expected one of ${RUN_STATUSES.join(", ")}`);
|
|
1337
|
-
}
|
|
1338
|
-
if (rule.maxDurationMs !== void 0 && (typeof rule.maxDurationMs !== "number" || !Number.isFinite(rule.maxDurationMs) || rule.maxDurationMs <= 0)) throw new ValidationError(`${where}: maxDurationMs must be a positive number`);
|
|
1339
|
-
return;
|
|
1340
|
-
case "argument":
|
|
1341
|
-
assertPredicate(rule.p, `${where} (p)`);
|
|
1342
|
-
assertJsonPointer(rule.pointer, where);
|
|
1343
|
-
assertArgumentCheck(rule.check, where);
|
|
1344
|
-
if (rule.occurrence !== void 0 && !ARGUMENT_OCCURRENCES.includes(rule.occurrence)) throw new ValidationError(`${where}: occurrence must be one of ${ARGUMENT_OCCURRENCES.join(", ")}`);
|
|
1345
|
-
return;
|
|
1346
|
-
case "toolsOffered":
|
|
1347
|
-
if (rule.declared !== void 0) assertNames(rule.declared, `${where}: declared`);
|
|
1348
|
-
return;
|
|
1349
|
-
case "retrySafe": {
|
|
1350
|
-
const reads = rule.reads === void 0 ? [] : assertNames(rule.reads, `${where}: reads`);
|
|
1351
|
-
if (rule.writes === void 0 && rule.reads === void 0) throw new ValidationError(`${where}: retrySafe needs reads or writes`);
|
|
1352
|
-
if (rule.writes !== void 0) {
|
|
1353
|
-
if (!Array.isArray(rule.writes) || rule.writes.length === 0) throw new ValidationError(`${where}: writes must be a non-empty array`);
|
|
1354
|
-
const writes = assertNames(rule.writes.map((w) => w?.tool), `${where}: writes[].tool`);
|
|
1355
|
-
for (const [i, w] of rule.writes.entries()) {
|
|
1356
|
-
if (w.idempotencyKey === void 0) continue;
|
|
1357
|
-
assertJsonPointer(w.idempotencyKey, `${where}: writes[${i}].idempotencyKey`);
|
|
1358
|
-
if (w.idempotencyKey === "") throw new ValidationError(`${where}: writes[${i}].idempotencyKey must name a member, not the whole arguments`);
|
|
1359
|
-
}
|
|
1360
|
-
const both = writes.find((t) => reads.includes(t));
|
|
1361
|
-
if (both !== void 0) throw new ValidationError(`${where}: "${both}" is both a read and a write`);
|
|
1362
|
-
}
|
|
1363
|
-
return;
|
|
1364
|
-
}
|
|
1365
|
-
default: throw new ValidationError(`${where}: unknown rule kind "${String(rule.kind)}"`);
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
function assertRules(rules, where, allowEmpty = false) {
|
|
1369
|
-
if (!Array.isArray(rules) || rules.length === 0 && !allowEmpty) throw new ValidationError(`${where}: no rules — an empty contract would vacuously pass`);
|
|
1370
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1371
|
-
for (const rule of rules) {
|
|
1372
|
-
const ruleWhere = `${where} rule "${rule?.label ?? "<unlabeled>"}"`;
|
|
1373
|
-
if (typeof rule?.label !== "string" || rule.label.length === 0) throw new ValidationError(`${ruleWhere}: label must be a non-empty string`);
|
|
1374
|
-
if (seen.has(rule.label)) throw new ValidationError(`${ruleWhere}: duplicate label would collapse per-rule scores`);
|
|
1375
|
-
seen.add(rule.label);
|
|
1376
|
-
assertRule(rule, ruleWhere);
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
function assertContract(contract, where) {
|
|
1380
|
-
if (typeof contract?.name !== "string" || contract.name.length === 0) throw new ValidationError(`${where}: contract.name must be a non-empty string`);
|
|
1381
|
-
const at = `${where} "${contract.name}"`;
|
|
1382
|
-
assertRules(contract.rules, at, Array.isArray(contract.alternatives) && contract.alternatives.length > 0);
|
|
1383
|
-
if (contract.scope !== void 0) assertPredicate(contract.scope?.root, `${at} scope.root`);
|
|
1384
|
-
if (contract.alternatives !== void 0) {
|
|
1385
|
-
if (!Array.isArray(contract.alternatives) || contract.alternatives.length === 0) throw new ValidationError(`${at}: alternatives must be a non-empty array`);
|
|
1386
|
-
const ids = /* @__PURE__ */ new Set();
|
|
1387
|
-
for (const alternative of contract.alternatives) {
|
|
1388
|
-
if (typeof alternative?.id !== "string" || alternative.id.length === 0) throw new ValidationError(`${at}: every alternative needs a non-empty id`);
|
|
1389
|
-
if (ids.has(alternative.id)) throw new ValidationError(`${at}: duplicate alternative id "${alternative.id}"`);
|
|
1390
|
-
ids.add(alternative.id);
|
|
1391
|
-
assertRules(alternative.rules, `${at} alternative "${alternative.id}"`);
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
// src/trace-contracts/explain.ts
|
|
1396
|
-
function describeMatcher(m) {
|
|
1397
|
-
if (typeof m === "string") return m;
|
|
1398
|
-
if (m instanceof RegExp) return `/${m.source}/${m.flags}`;
|
|
1399
|
-
if (isOneOfMatcher(m)) return `oneOf(${m.oneOf.join("|")})`;
|
|
1400
|
-
return `/${m.$regex}/${m.flags}`;
|
|
1401
|
-
}
|
|
1402
|
-
function describePredicate(p) {
|
|
1403
|
-
const parts = [];
|
|
1404
|
-
if (p.kind !== void 0) parts.push(`kind=${p.kind}`);
|
|
1405
|
-
if (p.name !== void 0) parts.push(`name=${describeMatcher(p.name)}`);
|
|
1406
|
-
if (p.tool !== void 0) parts.push(`tool=${describeMatcher(p.tool)}`);
|
|
1407
|
-
if (p.model !== void 0) parts.push(`model=${describeMatcher(p.model)}`);
|
|
1408
|
-
if (p.attr !== void 0) for (const [k, v] of Object.entries(p.attr)) parts.push(`attr.${k}=${isRegexValue(v) ? describeMatcher(v) : JSON.stringify(v)}`);
|
|
1409
|
-
if (p.not !== void 0) parts.push(`not(${describePredicate(p.not)})`);
|
|
1410
|
-
if (typeof p.custom === "function") parts.push(`custom=${p.custom.name || "fn"}`);
|
|
1411
|
-
return parts.join(",");
|
|
1412
|
-
}
|
|
1413
|
-
function describeCheck(check) {
|
|
1414
|
-
switch (check.op) {
|
|
1415
|
-
case "exists": return "exists";
|
|
1416
|
-
case "equals": return `equals ${JSON.stringify(check.value)}`;
|
|
1417
|
-
case "oneOf": return `oneOf ${JSON.stringify(check.values)}`;
|
|
1418
|
-
case "type": return `type ${check.type}`;
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
/** One line per rule, stating what it requires. */
|
|
1422
|
-
function describeRule(rule) {
|
|
1423
|
-
switch (rule.kind) {
|
|
1424
|
-
case "always": return `every span matches ${describePredicate(rule.p)}`;
|
|
1425
|
-
case "never": return `no span matches ${describePredicate(rule.p)}`;
|
|
1426
|
-
case "eventually": return `some span matches ${describePredicate(rule.p)}`;
|
|
1427
|
-
case "precedes": return `${describePredicate(rule.a)} and ${describePredicate(rule.b)} both occur, and the first comes before the second (${rule.order ?? "start-order"})`;
|
|
1428
|
-
case "neverUnless": return `every ${describePredicate(rule.p)} has an earlier ${describePredicate(rule.prior)} (${rule.order ?? "start-order"})`;
|
|
1429
|
-
case "atMost": return `at most ${rule.max} span(s) match ${describePredicate(rule.p)}`;
|
|
1430
|
-
case "tokensAtMost": return `spans matching ${describePredicate(rule.p)} use at most ${rule.max} tokens in total`;
|
|
1431
|
-
case "run": {
|
|
1432
|
-
const parts = [];
|
|
1433
|
-
if (rule.requireCompleted) parts.push("the run completed and recorded its end");
|
|
1434
|
-
if (rule.allowedStatuses) parts.push(`its status is one of ${rule.allowedStatuses.join(", ")}`);
|
|
1435
|
-
if (rule.maxDurationMs !== void 0) parts.push(`it took at most ${rule.maxDurationMs} ms`);
|
|
1436
|
-
return parts.join("; ");
|
|
1437
|
-
}
|
|
1438
|
-
case "argument": return `${rule.occurrence ?? "all"} call(s) matching ${describePredicate(rule.p)} have argument ${rule.pointer || "(whole value)"} that ${describeCheck(rule.check)}`;
|
|
1439
|
-
case "toolsOffered": return `the trace records the tools offered to the model, every tool call is one of them${rule.declared ? `, and every offered tool is one of ${rule.declared.join(", ")}` : ""}`;
|
|
1440
|
-
case "retrySafe": {
|
|
1441
|
-
const parts = ["no tool is called twice with the same arguments"];
|
|
1442
|
-
if (rule.reads) parts.push(`except the reads ${rule.reads.join(", ")}`);
|
|
1443
|
-
for (const w of rule.writes ?? []) parts.push(w.idempotencyKey === void 0 ? `write ${w.tool} may never repeat` : `write ${w.tool} may repeat only with one idempotency key at ${w.idempotencyKey}`);
|
|
1444
|
-
return parts.join("; ");
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
}
|
|
1448
|
-
/** Plain-language statement of everything a contract checks, one rule per line. */
|
|
1449
|
-
function explainTraceContract(contract) {
|
|
1450
|
-
assertContract(contract, "explainTraceContract");
|
|
1451
|
-
const lines = [`Contract "${contract.name}"${contract.description ? ` — ${contract.description}` : ""}`];
|
|
1452
|
-
if (contract.scope) lines.push(`Scope: only the span matching ${describePredicate(contract.scope.root)} and its descendants; exactly one span must match.`);
|
|
1453
|
-
lines.push("Every rule must pass:");
|
|
1454
|
-
for (const rule of contract.rules) lines.push(` - ${rule.label}: ${describeRule(rule)}`);
|
|
1455
|
-
if (contract.alternatives) {
|
|
1456
|
-
lines.push("And at least one alternative must pass completely:");
|
|
1457
|
-
for (const alternative of contract.alternatives) {
|
|
1458
|
-
lines.push(` ${alternative.id}:`);
|
|
1459
|
-
for (const rule of alternative.rules) lines.push(` - ${rule.label}: ${describeRule(rule)}`);
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
return lines.join("\n");
|
|
1463
|
-
}
|
|
1464
1029
|
// src/trace-contracts/builder.ts
|
|
1465
1030
|
var TraceContractBuilder = class TraceContractBuilder {
|
|
1466
1031
|
name;
|
|
@@ -1639,653 +1204,6 @@ function traceContract(name) {
|
|
|
1639
1204
|
if (typeof name !== "string" || name.length === 0) throw new ValidationError("traceContract: name must be a non-empty string");
|
|
1640
1205
|
return new TraceContractBuilder(name);
|
|
1641
1206
|
}
|
|
1642
|
-
// src/trace-contracts/rules.ts
|
|
1643
|
-
function spanRef(span, index) {
|
|
1644
|
-
return span.spanId ?? `#${index}`;
|
|
1645
|
-
}
|
|
1646
|
-
/**
|
|
1647
|
-
* Whether this trace shows any sign that spans of `kind` are actually
|
|
1648
|
-
* captured, independent of whether any span happens to match a given rule's
|
|
1649
|
-
* predicate. A `never`, `atMost`, `tokensAtMost` or `retrySafe` rule that
|
|
1650
|
-
* targets TOOL or LLM spans and finds zero matches cannot otherwise tell "no
|
|
1651
|
-
* calls happened" from "calls were not recorded": an exporter that silently
|
|
1652
|
-
* drops a span kind makes `forbidden`, `allowed`, `maxCalls` and `retries`
|
|
1653
|
-
* checks on that kind pass vacuously. Evidence is: a span of that kind
|
|
1654
|
-
* anywhere in the trace, or — for TOOL — a recorded offered-tool set
|
|
1655
|
-
* (`gen_ai.tool.definitions`), which proves the capture pipeline ran even on
|
|
1656
|
-
* a turn that called no tool.
|
|
1657
|
-
*/
|
|
1658
|
-
function hasCaptureEvidence(spans, kind) {
|
|
1659
|
-
if (spans.some((span) => contractSpanKind(span) === kind)) return true;
|
|
1660
|
-
if (kind === "TOOL") return spans.some((span) => spanOfferedTools(span).recorded);
|
|
1661
|
-
return false;
|
|
1662
|
-
}
|
|
1663
|
-
/** Only `TOOL`/`LLM`-scoped predicates have capture evidence to check. */
|
|
1664
|
-
function capturedKindOf(p) {
|
|
1665
|
-
return p.kind === "TOOL" || p.kind === "LLM" ? p.kind : void 0;
|
|
1666
|
-
}
|
|
1667
|
-
function requireCaptureEvidence(spans, p, rule, situation) {
|
|
1668
|
-
const kind = capturedKindOf(p);
|
|
1669
|
-
if (kind === void 0) return;
|
|
1670
|
-
if (hasCaptureEvidence(spans, kind)) return;
|
|
1671
|
-
throw new CaptureIntegrityError(`rule '${rule}': ${situation} and the trace has no ${kind} capture evidence (no ${kind} span` + (kind === "TOOL" ? `, no ${ATTR.toolDefinitions}` : "") + `) — cannot tell whether ${describePredicate(p)} never happened or was never recorded`);
|
|
1672
|
-
}
|
|
1673
|
-
function indexed(spans, p) {
|
|
1674
|
-
const out = [];
|
|
1675
|
-
spans.forEach((span, i) => {
|
|
1676
|
-
if (predicateMatches(span, p)) out.push({
|
|
1677
|
-
span,
|
|
1678
|
-
ref: spanRef(span, i)
|
|
1679
|
-
});
|
|
1680
|
-
});
|
|
1681
|
-
return out;
|
|
1682
|
-
}
|
|
1683
|
-
/**
|
|
1684
|
-
* Is guarded span `b` preceded by the guard spans under `order`? A span never
|
|
1685
|
-
* witnesses itself. Missing timestamps fail: the checker cannot prove an
|
|
1686
|
-
* order it cannot see.
|
|
1687
|
-
*/
|
|
1688
|
-
function witnessed(b, guards, order) {
|
|
1689
|
-
const bStart = finite(b.span.startedAt);
|
|
1690
|
-
if (bStart === void 0) return {
|
|
1691
|
-
ok: false,
|
|
1692
|
-
detail: `span ${b.ref} has no startedAt, so its order cannot be proven`
|
|
1693
|
-
};
|
|
1694
|
-
const candidates = guards.filter((a) => a.span !== b.span);
|
|
1695
|
-
if (candidates.length === 0) return {
|
|
1696
|
-
ok: false,
|
|
1697
|
-
detail: `span ${b.ref} has no earlier match`
|
|
1698
|
-
};
|
|
1699
|
-
const boundary = order === "start-order" ? "startedAt" : "endedAt";
|
|
1700
|
-
const untimed = candidates.find((a) => finite(a.span[boundary]) === void 0);
|
|
1701
|
-
if (order === "all-occurrences") {
|
|
1702
|
-
if (untimed) return {
|
|
1703
|
-
ok: false,
|
|
1704
|
-
detail: `span ${untimed.ref} has no endedAt, so its order cannot be proven`
|
|
1705
|
-
};
|
|
1706
|
-
const late = candidates.find((a) => a.span.endedAt > bStart);
|
|
1707
|
-
return late ? {
|
|
1708
|
-
ok: false,
|
|
1709
|
-
detail: `span ${late.ref} ends after span ${b.ref} starts`
|
|
1710
|
-
} : { ok: true };
|
|
1711
|
-
}
|
|
1712
|
-
if (candidates.some((a) => {
|
|
1713
|
-
const t = finite(a.span[boundary]);
|
|
1714
|
-
return t !== void 0 && (order === "start-order" ? t < bStart : t <= bStart);
|
|
1715
|
-
})) return { ok: true };
|
|
1716
|
-
if (untimed) return {
|
|
1717
|
-
ok: false,
|
|
1718
|
-
detail: `span ${untimed.ref} has no ${boundary}, so its order cannot be proven`
|
|
1719
|
-
};
|
|
1720
|
-
return {
|
|
1721
|
-
ok: false,
|
|
1722
|
-
detail: order === "start-order" ? `span ${b.ref} has no match that started before it` : `span ${b.ref} has no match that finished before it started`
|
|
1723
|
-
};
|
|
1724
|
-
}
|
|
1725
|
-
function orderViolations(label, guards, guarded, order, describe) {
|
|
1726
|
-
const out = [];
|
|
1727
|
-
for (const b of guarded) {
|
|
1728
|
-
const w = witnessed(b, guards, order);
|
|
1729
|
-
if (!w.ok) out.push({
|
|
1730
|
-
rule: label,
|
|
1731
|
-
spanId: b.span.spanId,
|
|
1732
|
-
detail: `${describe}: ${w.detail}`
|
|
1733
|
-
});
|
|
1734
|
-
}
|
|
1735
|
-
return out;
|
|
1736
|
-
}
|
|
1737
|
-
/** RFC 6901 resolution. `found: false` when any reference token is absent. */
|
|
1738
|
-
function resolveJsonPointer(value, pointer) {
|
|
1739
|
-
if (pointer === "") return {
|
|
1740
|
-
found: true,
|
|
1741
|
-
value
|
|
1742
|
-
};
|
|
1743
|
-
let current = value;
|
|
1744
|
-
for (const raw of pointer.slice(1).split("/")) {
|
|
1745
|
-
const token = raw.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1746
|
-
if (Array.isArray(current)) {
|
|
1747
|
-
if (!/^(?:0|[1-9]\d*)$/.test(token) || Number(token) >= current.length) return { found: false };
|
|
1748
|
-
current = current[Number(token)];
|
|
1749
|
-
} else if (current !== null && typeof current === "object" && Object.hasOwn(current, token)) current = current[token];
|
|
1750
|
-
else return { found: false };
|
|
1751
|
-
}
|
|
1752
|
-
return {
|
|
1753
|
-
found: true,
|
|
1754
|
-
value: current
|
|
1755
|
-
};
|
|
1756
|
-
}
|
|
1757
|
-
function jsonType(value) {
|
|
1758
|
-
if (value === null) return "null";
|
|
1759
|
-
if (Array.isArray(value)) return "array";
|
|
1760
|
-
const t = typeof value;
|
|
1761
|
-
return t === "string" || t === "number" || t === "boolean" || t === "object" ? t : "undefined";
|
|
1762
|
-
}
|
|
1763
|
-
function jsonEqual(a, b) {
|
|
1764
|
-
if (a === b) return true;
|
|
1765
|
-
const ta = jsonType(a);
|
|
1766
|
-
if (ta !== jsonType(b)) return false;
|
|
1767
|
-
if (ta === "array") {
|
|
1768
|
-
const x = a;
|
|
1769
|
-
const y = b;
|
|
1770
|
-
return x.length === y.length && x.every((v, i) => jsonEqual(v, y[i]));
|
|
1771
|
-
}
|
|
1772
|
-
if (ta === "object") {
|
|
1773
|
-
const x = a;
|
|
1774
|
-
const y = b;
|
|
1775
|
-
const keys = Object.keys(x);
|
|
1776
|
-
return keys.length === Object.keys(y).length && keys.every((k) => Object.hasOwn(y, k) && jsonEqual(x[k], y[k]));
|
|
1777
|
-
}
|
|
1778
|
-
return false;
|
|
1779
|
-
}
|
|
1780
|
-
/** Why `value` fails `check`, or `undefined` when it passes. Never echoes the
|
|
1781
|
-
* actual argument value: arguments can carry customer data. */
|
|
1782
|
-
function argumentFailure(evidence, pointer, check) {
|
|
1783
|
-
if (!evidence.known) return evidence.reason;
|
|
1784
|
-
const resolved = resolveJsonPointer(evidence.value, pointer);
|
|
1785
|
-
if (!resolved.found) return `argument ${pointer || "(whole value)"} is absent`;
|
|
1786
|
-
switch (check.op) {
|
|
1787
|
-
case "exists": return;
|
|
1788
|
-
case "equals": return jsonEqual(resolved.value, check.value) ? void 0 : `argument ${pointer || "(whole value)"} (a ${jsonType(resolved.value)}) does not equal the expected value`;
|
|
1789
|
-
case "oneOf": return check.values.some((v) => jsonEqual(resolved.value, v)) ? void 0 : `argument ${pointer || "(whole value)"} (a ${jsonType(resolved.value)}) is not one of the expected values`;
|
|
1790
|
-
case "type": return jsonType(resolved.value) === check.type ? void 0 : `argument ${pointer || "(whole value)"} is a ${jsonType(resolved.value)}, not a ${check.type}`;
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
function checkArgument(rule, spans) {
|
|
1794
|
-
const matches = indexed(spans, rule.p);
|
|
1795
|
-
if (matches.length === 0) return [{
|
|
1796
|
-
rule: rule.label,
|
|
1797
|
-
detail: `no span matches ${describePredicate(rule.p)}, so there is no argument evidence to check`
|
|
1798
|
-
}];
|
|
1799
|
-
const occurrence = rule.occurrence ?? "all";
|
|
1800
|
-
let selected = matches;
|
|
1801
|
-
if ((occurrence === "first" || occurrence === "last") && matches.length > 1) {
|
|
1802
|
-
const untimed = matches.find((m) => finite(m.span.startedAt) === void 0);
|
|
1803
|
-
if (untimed) return [{
|
|
1804
|
-
rule: rule.label,
|
|
1805
|
-
spanId: untimed.span.spanId,
|
|
1806
|
-
detail: `span ${untimed.ref} has no startedAt, so the ${occurrence} call cannot be chosen`
|
|
1807
|
-
}];
|
|
1808
|
-
const sorted = [...matches].sort((x, y) => x.span.startedAt - y.span.startedAt);
|
|
1809
|
-
selected = [occurrence === "first" ? sorted[0] : sorted[sorted.length - 1]];
|
|
1810
|
-
}
|
|
1811
|
-
const failures = selected.map((m) => ({
|
|
1812
|
-
m,
|
|
1813
|
-
why: argumentFailure(spanArguments(m.span), rule.pointer, rule.check)
|
|
1814
|
-
}));
|
|
1815
|
-
const failed = failures.filter((f) => f.why !== void 0);
|
|
1816
|
-
if (occurrence === "any" ? failed.length < failures.length : failed.length === 0) return [];
|
|
1817
|
-
return failed.map((f) => ({
|
|
1818
|
-
rule: rule.label,
|
|
1819
|
-
spanId: f.m.span.spanId,
|
|
1820
|
-
detail: `span ${f.m.ref}: ${f.why}`
|
|
1821
|
-
}));
|
|
1822
|
-
}
|
|
1823
|
-
function checkRun(rule, context) {
|
|
1824
|
-
if ("unknown" in context) return [{
|
|
1825
|
-
rule: rule.label,
|
|
1826
|
-
detail: `run record unavailable: ${context.unknown}`
|
|
1827
|
-
}];
|
|
1828
|
-
const run = context.run;
|
|
1829
|
-
const out = [];
|
|
1830
|
-
if (rule.requireCompleted && (run.status !== "completed" || finite(run.endedAt) === void 0)) out.push({
|
|
1831
|
-
rule: rule.label,
|
|
1832
|
-
detail: run.status === "completed" ? "run status is completed but no end time was recorded" : `run status is ${run.status ?? "unknown"}, not completed`
|
|
1833
|
-
});
|
|
1834
|
-
if (rule.allowedStatuses && !rule.allowedStatuses.includes(run.status ?? "")) out.push({
|
|
1835
|
-
rule: rule.label,
|
|
1836
|
-
detail: `run status ${run.status ?? "unknown"} is not one of ${rule.allowedStatuses.join(", ")}`
|
|
1837
|
-
});
|
|
1838
|
-
if (rule.maxDurationMs !== void 0) {
|
|
1839
|
-
const start = finite(run.startedAt);
|
|
1840
|
-
const end = finite(run.endedAt);
|
|
1841
|
-
if (start === void 0 || end === void 0) out.push({
|
|
1842
|
-
rule: rule.label,
|
|
1843
|
-
detail: "run duration is unknown: start or end time is missing"
|
|
1844
|
-
});
|
|
1845
|
-
else if (end - start > rule.maxDurationMs) out.push({
|
|
1846
|
-
rule: rule.label,
|
|
1847
|
-
detail: `run took ${end - start} ms, over ${rule.maxDurationMs} ms`
|
|
1848
|
-
});
|
|
1849
|
-
}
|
|
1850
|
-
return out;
|
|
1851
|
-
}
|
|
1852
|
-
const listed = (names, max = 6) => names.length <= max ? names.join(", ") : `${names.slice(0, max).join(", ")} and ${names.length - max} more`;
|
|
1853
|
-
function toolSpans(spans) {
|
|
1854
|
-
const out = [];
|
|
1855
|
-
spans.forEach((span, i) => {
|
|
1856
|
-
if (contractSpanKind(span) === "TOOL") out.push({
|
|
1857
|
-
span,
|
|
1858
|
-
ref: spanRef(span, i)
|
|
1859
|
-
});
|
|
1860
|
-
});
|
|
1861
|
-
return out;
|
|
1862
|
-
}
|
|
1863
|
-
/** Declared, offered and called tools agree. */
|
|
1864
|
-
function checkToolsOffered(rule, spans) {
|
|
1865
|
-
const out = [];
|
|
1866
|
-
const offered = /* @__PURE__ */ new Set();
|
|
1867
|
-
let recorded = 0;
|
|
1868
|
-
const declared = rule.declared ? new Set(rule.declared) : void 0;
|
|
1869
|
-
spans.forEach((span, i) => {
|
|
1870
|
-
const tools = spanOfferedTools(span);
|
|
1871
|
-
if (!tools.recorded) return;
|
|
1872
|
-
recorded += 1;
|
|
1873
|
-
const ref = spanRef(span, i);
|
|
1874
|
-
if ("unreadable" in tools) {
|
|
1875
|
-
out.push({
|
|
1876
|
-
rule: rule.label,
|
|
1877
|
-
spanId: span.spanId,
|
|
1878
|
-
detail: `span ${ref}: ${tools.unreadable}`
|
|
1879
|
-
});
|
|
1880
|
-
return;
|
|
1881
|
-
}
|
|
1882
|
-
for (const name of tools.names) offered.add(name);
|
|
1883
|
-
const undeclared = declared ? [...new Set(tools.names)].filter((n) => !declared.has(n)) : [];
|
|
1884
|
-
if (undeclared.length > 0) out.push({
|
|
1885
|
-
rule: rule.label,
|
|
1886
|
-
spanId: span.spanId,
|
|
1887
|
-
detail: `span ${ref} offered the model ${undeclared.length} undeclared tool(s): ${listed(undeclared)}`
|
|
1888
|
-
});
|
|
1889
|
-
});
|
|
1890
|
-
if (recorded === 0) return [{
|
|
1891
|
-
rule: rule.label,
|
|
1892
|
-
detail: `no span records the tools offered to the model (${ATTR.toolDefinitions}), so what the harness enforced is unknown`
|
|
1893
|
-
}];
|
|
1894
|
-
for (const { span, ref } of toolSpans(spans)) {
|
|
1895
|
-
const name = contractSpanToolName(span);
|
|
1896
|
-
if (name === void 0) out.push({
|
|
1897
|
-
rule: rule.label,
|
|
1898
|
-
spanId: span.spanId,
|
|
1899
|
-
detail: `span ${ref} has no tool name, so it cannot be matched to an offered tool`
|
|
1900
|
-
});
|
|
1901
|
-
else if (!offered.has(name)) out.push({
|
|
1902
|
-
rule: rule.label,
|
|
1903
|
-
spanId: span.spanId,
|
|
1904
|
-
detail: `span ${ref} called ${name}, which was never offered: the harness did not enforce its tool set`
|
|
1905
|
-
});
|
|
1906
|
-
}
|
|
1907
|
-
return out;
|
|
1908
|
-
}
|
|
1909
|
-
/** The call's idempotency key, or why it has none. */
|
|
1910
|
-
function idempotencyKey(span, pointer) {
|
|
1911
|
-
const evidence = spanArguments(span);
|
|
1912
|
-
if (!evidence.known) return { missing: evidence.reason };
|
|
1913
|
-
const resolved = resolveJsonPointer(evidence.value, pointer);
|
|
1914
|
-
const value = resolved.value;
|
|
1915
|
-
if (resolved.found && typeof value === "string" && value.length > 0) return { key: value };
|
|
1916
|
-
if (resolved.found && typeof value === "number" && Number.isFinite(value)) return { key: String(value) };
|
|
1917
|
-
return { missing: `no idempotency key at ${pointer}` };
|
|
1918
|
-
}
|
|
1919
|
-
/** No call repeats a side effect that is not proven safe to repeat. */
|
|
1920
|
-
function checkRetrySafe(rule, spans) {
|
|
1921
|
-
const reads = new Set(rule.reads ?? []);
|
|
1922
|
-
const writes = new Map((rule.writes ?? []).map((w) => [w.tool, w]));
|
|
1923
|
-
const out = [];
|
|
1924
|
-
const groups = /* @__PURE__ */ new Map();
|
|
1925
|
-
const unseen = /* @__PURE__ */ new Map();
|
|
1926
|
-
const calls = toolSpans(spans);
|
|
1927
|
-
if (calls.length === 0 && !hasCaptureEvidence(spans, "TOOL")) throw new CaptureIntegrityError(`rule '${rule.label}': retrySafe found 0 TOOL spans and the trace has no TOOL capture evidence (no TOOL span, no ${ATTR.toolDefinitions}) — cannot tell whether no reads or writes happened or the trace lost its TOOL spans`);
|
|
1928
|
-
for (const call of calls) {
|
|
1929
|
-
const name = contractSpanToolName(call.span);
|
|
1930
|
-
if (name === void 0) {
|
|
1931
|
-
out.push({
|
|
1932
|
-
rule: rule.label,
|
|
1933
|
-
spanId: call.span.spanId,
|
|
1934
|
-
detail: `span ${call.ref} has no tool name, so whether it repeats a call is unknown`
|
|
1935
|
-
});
|
|
1936
|
-
continue;
|
|
1937
|
-
}
|
|
1938
|
-
if (reads.has(name)) continue;
|
|
1939
|
-
const args = spanArguments(call.span);
|
|
1940
|
-
if (!args.known) {
|
|
1941
|
-
const list = unseen.get(name) ?? [];
|
|
1942
|
-
list.push(call);
|
|
1943
|
-
unseen.set(name, list);
|
|
1944
|
-
continue;
|
|
1945
|
-
}
|
|
1946
|
-
const pointer = writes.get(name)?.idempotencyKey;
|
|
1947
|
-
const identity = pointer === void 0 ? args.value : withoutMember(args.value, pointer);
|
|
1948
|
-
const key = `${name}\u0000${canonicalString(identity)}`;
|
|
1949
|
-
const list = groups.get(key) ?? [];
|
|
1950
|
-
list.push(call);
|
|
1951
|
-
groups.set(key, list);
|
|
1952
|
-
}
|
|
1953
|
-
for (const [name, calls] of unseen) {
|
|
1954
|
-
const total = calls.length + [...groups].reduce((n, [k, list]) => k.startsWith(`${name}\u0000`) ? n + list.length : n, 0);
|
|
1955
|
-
if (total > 1) out.push({
|
|
1956
|
-
rule: rule.label,
|
|
1957
|
-
spanId: calls[0].span.spanId,
|
|
1958
|
-
detail: `${name} was called ${total} times and span ${calls[0].ref} has no captured arguments, so whether a call repeats another is unknown`
|
|
1959
|
-
});
|
|
1960
|
-
}
|
|
1961
|
-
for (const [key, calls] of groups) {
|
|
1962
|
-
if (calls.length < 2) continue;
|
|
1963
|
-
const name = key.slice(0, key.indexOf("\0"));
|
|
1964
|
-
const refs = listed(calls.map((c) => c.ref));
|
|
1965
|
-
const write = writes.get(name);
|
|
1966
|
-
if (!write) {
|
|
1967
|
-
out.push({
|
|
1968
|
-
rule: rule.label,
|
|
1969
|
-
spanId: calls[1].span.spanId,
|
|
1970
|
-
detail: `${name} was called ${calls.length} times with the same arguments (spans ${refs}) and its side effect is not declared, so the repeat is not proven safe`
|
|
1971
|
-
});
|
|
1972
|
-
continue;
|
|
1973
|
-
}
|
|
1974
|
-
const pointer = write.idempotencyKey;
|
|
1975
|
-
if (pointer === void 0) {
|
|
1976
|
-
out.push({
|
|
1977
|
-
rule: rule.label,
|
|
1978
|
-
spanId: calls[1].span.spanId,
|
|
1979
|
-
detail: `write ${name} was called ${calls.length} times with the same arguments (spans ${refs}) and declares no idempotency key, so it may have applied more than once`
|
|
1980
|
-
});
|
|
1981
|
-
continue;
|
|
1982
|
-
}
|
|
1983
|
-
const keyed = calls.map((c) => ({
|
|
1984
|
-
c,
|
|
1985
|
-
k: idempotencyKey(c.span, pointer)
|
|
1986
|
-
}));
|
|
1987
|
-
const missing = keyed.find((x) => "missing" in x.k);
|
|
1988
|
-
const keys = new Set(keyed.flatMap((x) => "key" in x.k ? [x.k.key] : []));
|
|
1989
|
-
if (missing) out.push({
|
|
1990
|
-
rule: rule.label,
|
|
1991
|
-
spanId: missing.c.span.spanId,
|
|
1992
|
-
detail: `write ${name} was called ${calls.length} times with the same arguments (spans ${refs}); span ${missing.c.ref} has ${missing.k.missing}, so it may have applied more than once`
|
|
1993
|
-
});
|
|
1994
|
-
else if (keys.size > 1) out.push({
|
|
1995
|
-
rule: rule.label,
|
|
1996
|
-
spanId: calls[1].span.spanId,
|
|
1997
|
-
detail: `write ${name} was called ${calls.length} times with the same arguments (spans ${refs}) under ${keys.size} different idempotency keys, so the target cannot tell they are one operation`
|
|
1998
|
-
});
|
|
1999
|
-
}
|
|
2000
|
-
const flagged = new Set(out.map((v) => v.spanId));
|
|
2001
|
-
for (const call of toolSpans(spans)) {
|
|
2002
|
-
const name = contractSpanToolName(call.span);
|
|
2003
|
-
if (name === void 0 || flagged.has(call.span.spanId)) continue;
|
|
2004
|
-
const write = writes.get(name);
|
|
2005
|
-
if (!write || !isSpanError(call.span)) continue;
|
|
2006
|
-
const pointer = write.idempotencyKey;
|
|
2007
|
-
if (!(pointer !== void 0 && "key" in idempotencyKey(call.span, pointer))) {
|
|
2008
|
-
out.push({
|
|
2009
|
-
rule: rule.label,
|
|
2010
|
-
spanId: call.span.spanId,
|
|
2011
|
-
detail: `write ${name} (span ${call.ref}) errored and ${pointer === void 0 ? "declares no idempotency key" : `has ${idempotencyKey(call.span, pointer).missing}`}; its outcome is unknown, so a retry cannot be proven safe`
|
|
2012
|
-
});
|
|
2013
|
-
flagged.add(call.span.spanId);
|
|
2014
|
-
}
|
|
2015
|
-
}
|
|
2016
|
-
return out;
|
|
2017
|
-
}
|
|
2018
|
-
/** A copy of `value` without the member `pointer` names (RFC 6901). */
|
|
2019
|
-
function withoutMember(value, pointer) {
|
|
2020
|
-
const tokens = pointer.slice(1).split("/").map((t) => t.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
2021
|
-
const strip = (node, depth) => {
|
|
2022
|
-
const token = tokens[depth];
|
|
2023
|
-
const last = depth === tokens.length - 1;
|
|
2024
|
-
if (Array.isArray(node)) {
|
|
2025
|
-
const index = /^(?:0|[1-9]\d*)$/.test(token) ? Number(token) : -1;
|
|
2026
|
-
if (index < 0 || index >= node.length) return node;
|
|
2027
|
-
return last ? node.filter((_, i) => i !== index) : node.map((v, i) => i === index ? strip(v, depth + 1) : v);
|
|
2028
|
-
}
|
|
2029
|
-
if (node === null || typeof node !== "object" || !Object.hasOwn(node, token)) return node;
|
|
2030
|
-
const copy = { ...node };
|
|
2031
|
-
if (last) delete copy[token];
|
|
2032
|
-
else copy[token] = strip(copy[token], depth + 1);
|
|
2033
|
-
return copy;
|
|
2034
|
-
};
|
|
2035
|
-
return strip(value, 0);
|
|
2036
|
-
}
|
|
2037
|
-
function checkRule(rule, ctx) {
|
|
2038
|
-
const { spans } = ctx;
|
|
2039
|
-
switch (rule.kind) {
|
|
2040
|
-
case "always": return spans.flatMap((span, i) => predicateMatches(span, rule.p) ? [] : [{
|
|
2041
|
-
rule: rule.label,
|
|
2042
|
-
spanId: span.spanId,
|
|
2043
|
-
detail: `span ${spanRef(span, i)} ("${span.name ?? ""}") fails always(${describePredicate(rule.p)})`
|
|
2044
|
-
}]);
|
|
2045
|
-
case "never": {
|
|
2046
|
-
const matches = indexed(spans, rule.p);
|
|
2047
|
-
if (matches.length === 0) requireCaptureEvidence(spans, rule.p, rule.label, `never(${describePredicate(rule.p)}) matched 0 spans`);
|
|
2048
|
-
return matches.map(({ span, ref }) => ({
|
|
2049
|
-
rule: rule.label,
|
|
2050
|
-
spanId: span.spanId,
|
|
2051
|
-
detail: `span ${ref} ("${span.name ?? ""}") matches never(${describePredicate(rule.p)})`
|
|
2052
|
-
}));
|
|
2053
|
-
}
|
|
2054
|
-
case "eventually": return spans.some((span) => predicateMatches(span, rule.p)) ? [] : [{
|
|
2055
|
-
rule: rule.label,
|
|
2056
|
-
detail: `no span matches eventually(${describePredicate(rule.p)}) over ${spans.length} span(s)`
|
|
2057
|
-
}];
|
|
2058
|
-
case "precedes": {
|
|
2059
|
-
const as = indexed(spans, rule.a);
|
|
2060
|
-
const bs = indexed(spans, rule.b);
|
|
2061
|
-
const out = [];
|
|
2062
|
-
if (as.length === 0) out.push({
|
|
2063
|
-
rule: rule.label,
|
|
2064
|
-
detail: `required predecessor ${describePredicate(rule.a)} never occurred`
|
|
2065
|
-
});
|
|
2066
|
-
if (bs.length === 0) out.push({
|
|
2067
|
-
rule: rule.label,
|
|
2068
|
-
detail: `required successor ${describePredicate(rule.b)} never occurred`
|
|
2069
|
-
});
|
|
2070
|
-
if (out.length > 0) return out;
|
|
2071
|
-
return orderViolations(rule.label, as, bs, rule.order ?? "start-order", `${describePredicate(rule.b)} is not preceded by ${describePredicate(rule.a)}`);
|
|
2072
|
-
}
|
|
2073
|
-
case "neverUnless": return orderViolations(rule.label, indexed(spans, rule.prior), indexed(spans, rule.p), rule.order ?? "start-order", `${describePredicate(rule.p)} without an earlier ${describePredicate(rule.prior)}`);
|
|
2074
|
-
case "atMost": {
|
|
2075
|
-
const matches = indexed(spans, rule.p);
|
|
2076
|
-
if (matches.length === 0) requireCaptureEvidence(spans, rule.p, rule.label, `atMost(${describePredicate(rule.p)}) matched 0 spans`);
|
|
2077
|
-
return matches.length <= rule.max ? [] : [{
|
|
2078
|
-
rule: rule.label,
|
|
2079
|
-
spanId: matches[rule.max]?.span.spanId,
|
|
2080
|
-
detail: `${matches.length} span(s) match ${describePredicate(rule.p)}, over the limit of ${rule.max}`
|
|
2081
|
-
}];
|
|
2082
|
-
}
|
|
2083
|
-
case "tokensAtMost": {
|
|
2084
|
-
const matches = indexed(spans, rule.p);
|
|
2085
|
-
if (matches.length === 0) requireCaptureEvidence(spans, rule.p, rule.label, `tokensAtMost(${describePredicate(rule.p)}) matched 0 spans`);
|
|
2086
|
-
const unknown = matches.find((m) => spanTotalTokens(m.span) === void 0);
|
|
2087
|
-
if (unknown) return [{
|
|
2088
|
-
rule: rule.label,
|
|
2089
|
-
spanId: unknown.span.spanId,
|
|
2090
|
-
detail: `span ${unknown.ref} has no recorded input and output token counts, so the total is unknown`
|
|
2091
|
-
}];
|
|
2092
|
-
const total = matches.reduce((sum, m) => sum + spanTotalTokens(m.span), 0);
|
|
2093
|
-
return total <= rule.max ? [] : [{
|
|
2094
|
-
rule: rule.label,
|
|
2095
|
-
detail: `${total} tokens across ${matches.length} span(s) matching ${describePredicate(rule.p)}, over the limit of ${rule.max}`
|
|
2096
|
-
}];
|
|
2097
|
-
}
|
|
2098
|
-
case "run": return checkRun(rule, ctx.run);
|
|
2099
|
-
case "argument": return checkArgument(rule, spans);
|
|
2100
|
-
case "toolsOffered": return checkToolsOffered(rule, spans);
|
|
2101
|
-
case "retrySafe": return checkRetrySafe(rule, spans);
|
|
2102
|
-
}
|
|
2103
|
-
}
|
|
2104
|
-
function executeRule(rule, ctx) {
|
|
2105
|
-
try {
|
|
2106
|
-
const violations = checkRule(rule, ctx);
|
|
2107
|
-
return {
|
|
2108
|
-
status: violations.length === 0 ? "pass" : "fail",
|
|
2109
|
-
violations
|
|
2110
|
-
};
|
|
2111
|
-
} catch (error) {
|
|
2112
|
-
return {
|
|
2113
|
-
status: "error",
|
|
2114
|
-
violations: [],
|
|
2115
|
-
error: error instanceof Error ? error.message : String(error)
|
|
2116
|
-
};
|
|
2117
|
-
}
|
|
2118
|
-
}
|
|
2119
|
-
// src/trace-contracts/evaluate.ts
|
|
2120
|
-
/**
|
|
2121
|
-
* A run derived from one span: the `run.status` attribute a run-anchor span
|
|
2122
|
-
* carries (store-to-otlp writes it), else failed on an error status, else
|
|
2123
|
-
* unknown. An ended span with an OK status and no declared `run.status` is
|
|
2124
|
-
* NOT inferred as completed — a span exporter can end its root span cleanly
|
|
2125
|
-
* without ever learning whether the underlying run actually finished (for
|
|
2126
|
-
* example, a trace reader that saw no terminal record). `requireCompleted`
|
|
2127
|
-
* and `allowedStatuses` must fail closed on that gap rather than pass it.
|
|
2128
|
-
*/
|
|
2129
|
-
function runOfSpan(span) {
|
|
2130
|
-
const declared = span.attributes?.["run.status"];
|
|
2131
|
-
return {
|
|
2132
|
-
status: typeof declared === "string" && RUN_STATUSES.includes(declared) ? declared : isSpanError(span) ? "failed" : void 0,
|
|
2133
|
-
...finite(span.startedAt) === void 0 ? {} : { startedAt: span.startedAt },
|
|
2134
|
-
...finite(span.endedAt) === void 0 ? {} : { endedAt: span.endedAt }
|
|
2135
|
-
};
|
|
2136
|
-
}
|
|
2137
|
-
function rootsOf(spans) {
|
|
2138
|
-
const ids = new Set(spans.map((s) => s.spanId).filter((id) => typeof id === "string"));
|
|
2139
|
-
return spans.filter((s) => !s.parentSpanId || !ids.has(s.parentSpanId));
|
|
2140
|
-
}
|
|
2141
|
-
function subtree(spans, root) {
|
|
2142
|
-
if (typeof root.spanId !== "string") return [root];
|
|
2143
|
-
const children = /* @__PURE__ */ new Map();
|
|
2144
|
-
for (const span of spans) if (typeof span.parentSpanId === "string") {
|
|
2145
|
-
const list = children.get(span.parentSpanId) ?? [];
|
|
2146
|
-
list.push(span);
|
|
2147
|
-
children.set(span.parentSpanId, list);
|
|
2148
|
-
}
|
|
2149
|
-
const members = /* @__PURE__ */ new Set([root]);
|
|
2150
|
-
const queue = [root];
|
|
2151
|
-
while (queue.length > 0) {
|
|
2152
|
-
const current = queue.shift();
|
|
2153
|
-
for (const child of typeof current.spanId === "string" && children.get(current.spanId) || []) if (!members.has(child)) {
|
|
2154
|
-
members.add(child);
|
|
2155
|
-
queue.push(child);
|
|
2156
|
-
}
|
|
2157
|
-
}
|
|
2158
|
-
return spans.filter((s) => members.has(s));
|
|
2159
|
-
}
|
|
2160
|
-
function statusOf(outcomes) {
|
|
2161
|
-
if (outcomes.some((o) => o.status === "error")) return "error";
|
|
2162
|
-
return outcomes.every((o) => o.status === "pass") ? "pass" : "fail";
|
|
2163
|
-
}
|
|
2164
|
-
/**
|
|
2165
|
-
* Evaluate one contract over a span sequence. Pure and synchronous — works on
|
|
2166
|
-
* `Span[]` from a TraceStore, `contractSpansFromOtlp` output, or any array
|
|
2167
|
-
* satisfying `ContractSpan`. Throws
|
|
2168
|
-
* `ValidationError` for a malformed contract; a rule that cannot be evaluated
|
|
2169
|
-
* is reported as `error` in the verdict instead.
|
|
2170
|
-
*/
|
|
2171
|
-
function evaluateTraceContract(contract, spans, options = {}) {
|
|
2172
|
-
assertContract(contract, "evaluateTraceContract");
|
|
2173
|
-
if (!Array.isArray(spans)) throw new ValidationError(`evaluateTraceContract: spans must be an array, got ${typeof spans}`);
|
|
2174
|
-
let subject = spans;
|
|
2175
|
-
let run;
|
|
2176
|
-
let scopeError;
|
|
2177
|
-
if (contract.scope) {
|
|
2178
|
-
const roots = spans.filter((s) => predicateMatches(s, contract.scope.root));
|
|
2179
|
-
if (roots.length === 1) {
|
|
2180
|
-
subject = subtree(spans, roots[0]);
|
|
2181
|
-
run = { run: runOfSpan(roots[0]) };
|
|
2182
|
-
} else {
|
|
2183
|
-
scopeError = `scope root ${describePredicate(contract.scope.root)} matched ${roots.length} spans; exactly one is required`;
|
|
2184
|
-
run = { unknown: scopeError };
|
|
2185
|
-
}
|
|
2186
|
-
} else if (options.run) run = { run: options.run };
|
|
2187
|
-
else {
|
|
2188
|
-
const roots = rootsOf(spans);
|
|
2189
|
-
run = roots.length === 1 ? { run: runOfSpan(roots[0]) } : { unknown: `the trace has ${roots.length} root spans and no run record was passed` };
|
|
2190
|
-
}
|
|
2191
|
-
const ctx = {
|
|
2192
|
-
spans: subject,
|
|
2193
|
-
run
|
|
2194
|
-
};
|
|
2195
|
-
const execute = (rule) => scopeError === void 0 ? executeRule(rule, ctx) : {
|
|
2196
|
-
status: "error",
|
|
2197
|
-
violations: [],
|
|
2198
|
-
error: scopeError
|
|
2199
|
-
};
|
|
2200
|
-
const base = contract.rules.map(execute);
|
|
2201
|
-
const branches = (contract.alternatives ?? []).map((alternative) => ({
|
|
2202
|
-
alternative,
|
|
2203
|
-
outcomes: alternative.rules.map(execute)
|
|
2204
|
-
}));
|
|
2205
|
-
const passedBranch = branches.find((b) => statusOf(b.outcomes) === "pass");
|
|
2206
|
-
const baseStatus = statusOf(base);
|
|
2207
|
-
let status = baseStatus;
|
|
2208
|
-
if (baseStatus === "pass" && branches.length > 0 && !passedBranch) status = branches.some((b) => statusOf(b.outcomes) === "error") ? "error" : "fail";
|
|
2209
|
-
const ruleExecutions = [...contract.rules.map((rule, i) => execution(rule.label, void 0, base[i])), ...branches.flatMap((b) => b.alternative.rules.map((rule, i) => execution(rule.label, b.alternative.id, b.outcomes[i])))];
|
|
2210
|
-
const violations = base.flatMap((o) => o.violations);
|
|
2211
|
-
if (branches.length > 0 && !passedBranch) for (const b of branches) for (const o of b.outcomes) violations.push(...o.violations.map((v) => ({
|
|
2212
|
-
...v,
|
|
2213
|
-
rule: `${b.alternative.id}/${v.rule}`
|
|
2214
|
-
})));
|
|
2215
|
-
const errors = ruleExecutions.filter((e) => e.status === "error").map((e) => `${e.alternative ? `${e.alternative}/` : ""}${e.rule}: ${e.error}`);
|
|
2216
|
-
const scores = {};
|
|
2217
|
-
contract.rules.forEach((rule, i) => {
|
|
2218
|
-
const s = base[i].status;
|
|
2219
|
-
if (s !== "error") scores[rule.label] = s === "pass" ? 1 : 0;
|
|
2220
|
-
});
|
|
2221
|
-
if (branches.length > 0 && (passedBranch || status !== "error")) scores.anyOf = passedBranch ? 1 : 0;
|
|
2222
|
-
const total = contract.rules.length + (branches.length > 0 ? 1 : 0);
|
|
2223
|
-
const passCount = Object.values(scores).filter((s) => s === 1).length;
|
|
2224
|
-
const assumptions = [];
|
|
2225
|
-
for (const rule of [...contract.rules, ...branches.flatMap((b) => b.alternative.rules)]) if (rulePredicates(rule).some(usesCustom)) assumptions.push(`rule '${rule.label}' rests on a custom predicate function`);
|
|
2226
|
-
return {
|
|
2227
|
-
contract: contract.name,
|
|
2228
|
-
status,
|
|
2229
|
-
valid: status === "pass",
|
|
2230
|
-
score: passCount / total,
|
|
2231
|
-
scores,
|
|
2232
|
-
violations,
|
|
2233
|
-
ruleExecutions,
|
|
2234
|
-
errors,
|
|
2235
|
-
notes: `${passCount}/${total} rules passed` + (errors.length > 0 ? `; ${errors.length} could not be evaluated` : ""),
|
|
2236
|
-
certification: {
|
|
2237
|
-
strategy: "invariant",
|
|
2238
|
-
checker: {
|
|
2239
|
-
name: "agent-eval:trace-contracts",
|
|
2240
|
-
version: packageVersion$1()
|
|
2241
|
-
},
|
|
2242
|
-
assumptions,
|
|
2243
|
-
evidenceDigest: certificationEvidenceDigest({
|
|
2244
|
-
contract: contract.name,
|
|
2245
|
-
status,
|
|
2246
|
-
scores,
|
|
2247
|
-
violations,
|
|
2248
|
-
ruleExecutions
|
|
2249
|
-
})
|
|
2250
|
-
}
|
|
2251
|
-
};
|
|
2252
|
-
}
|
|
2253
|
-
function execution(rule, alternative, outcome) {
|
|
2254
|
-
return {
|
|
2255
|
-
rule,
|
|
2256
|
-
...alternative === void 0 ? {} : { alternative },
|
|
2257
|
-
status: outcome.status,
|
|
2258
|
-
violations: outcome.violations.length,
|
|
2259
|
-
...outcome.error === void 0 ? {} : { error: outcome.error }
|
|
2260
|
-
};
|
|
2261
|
-
}
|
|
2262
|
-
function rulePredicates(rule) {
|
|
2263
|
-
switch (rule.kind) {
|
|
2264
|
-
case "precedes": return [rule.a, rule.b];
|
|
2265
|
-
case "neverUnless": return [rule.p, rule.prior];
|
|
2266
|
-
case "run":
|
|
2267
|
-
case "toolsOffered":
|
|
2268
|
-
case "retrySafe": return [];
|
|
2269
|
-
default: return [rule.p];
|
|
2270
|
-
}
|
|
2271
|
-
}
|
|
2272
|
-
function usesCustom(p) {
|
|
2273
|
-
return typeof p.custom === "function" || p.not !== void 0 && usesCustom(p.not);
|
|
2274
|
-
}
|
|
2275
|
-
/**
|
|
2276
|
-
* Evaluate many contracts over one span sequence. Throws on an empty
|
|
2277
|
-
* contract list — `allValid: true` over zero contracts is a silent pass.
|
|
2278
|
-
*/
|
|
2279
|
-
function checkTraceContracts(spans, contracts, options = {}) {
|
|
2280
|
-
if (contracts.length === 0) throw new ValidationError("checkTraceContracts: empty contract list would vacuously pass — supply at least one contract");
|
|
2281
|
-
const verdicts = contracts.map((c) => evaluateTraceContract(c, spans, options));
|
|
2282
|
-
const status = verdicts.some((v) => v.status === "error") ? "error" : verdicts.every((v) => v.status === "pass") ? "pass" : "fail";
|
|
2283
|
-
return {
|
|
2284
|
-
verdicts,
|
|
2285
|
-
status,
|
|
2286
|
-
allValid: status === "pass"
|
|
2287
|
-
};
|
|
2288
|
-
}
|
|
2289
1207
|
// src/trace-contracts/spec.ts
|
|
2290
1208
|
/**
|
|
2291
1209
|
* The declarative contract form: a JSON document that names tools, model
|
|
@@ -9123,6 +8041,6 @@ function assertHasField(name, obj, field) {
|
|
|
9123
8041
|
actual: `keys: ${Object.keys(obj).join(", ")}`
|
|
9124
8042
|
};
|
|
9125
8043
|
}
|
|
9126
|
-
export { AGENT_PROFILE_KINDS, ATTESTATION_ALGORITHM, AgentEvalError, AnalystRegistry, BOOTSTRAP_GATE_MIN_N, BackendIntegrityError, BudgetBreachError, BudgetGuard, CODING_HARNESSES, ConfigError, CostAccountingIncompleteError, CostCeilingReachedError, CostLedger, CostTracker, CrossFamilyError, DEFAULT_BOUNDED_PROCESS_TIMEOUT_MS, DEFAULT_JUDGE_GATE_POLICY, DEFAULT_RED_TEAM_CORPUS, DEFAULT_TRACE_ANALYST_BUDGETS, DEFAULT_TRACE_ANALYST_KINDS, Dataset, ERROR_COUNT_PATTERNS, EquivalenceProtocolError, FAILURE_CLASSES, FAILURE_MODE_KIND_SPEC, FileSystemFeedbackTrajectoryStore, FileSystemRawProviderSink, FileSystemTraceStore, FindingsStore, HARNESS_NATIVE_MODEL, HeldOutGate, InMemoryFeedbackTrajectoryStore, InMemoryRawProviderSink, InMemoryTraceStore, JudgeError, JudgeGateRefusedError, LlmCallError, LlmResponseError, MODEL_PRICING, ModelSubstitutionError, MultiLayerVerifier, NoopRawProviderSink, NotFoundError, OUTPUT_VALUE, OtlpFileTraceStore, PairwiseSteeringOptimizer, ProductClient, PromptRegistry, REDACTION_VERSION, RunIntegrityError, RunRecordValidationError, SEMANTIC_CONCEPT_JUDGE_VERSION, TraceEmitter, UNKNOWN_MODEL, VERIFICATION_STRATEGIES, VERIFICATION_STRATEGY_SOURCES, ValidationError, acquisitionPlansForKnowledgeGaps, addCalibrationVerdicts, agentProfileCellKey, agentProfileHash, agentProfileId, aggregateJudgeVerdicts, aggregateRunScore, analystRunDigest, analystRunToFeedbackTrajectory, analystRunToReviewRequests, analyzeAntiSlop, analyzeRuns, analyzeSeries, analyzeTraces, argHash, assertCapabilityHeadroom, assertContains, assertCrossFamily, assertCrossFamilyServed, assertEventCount, assertExists, assertHasField, assertHttpOk, assertJudgeMayGate, assertLatencyUnder, assertNoHiddenLeak, assertNotContains, assertProductBenchmarkRun, assertRealBackend, assertRunCaptured, assertServedModel, assertServedModels, assertSingleBackend, assertStatus, assessShareSafety, assignFeedbackSplit, attest, benjaminiHochberg, blendHeldout, blockingKnowledgeEval, bonferroni, bootstrapCi, budgetBreachView, buildAgentProfileCell, buildDefaultAnalystRegistry, buildReflectionPrompt, buildTraceInsightContext, buildTraceInsightPrompt, buildTrajectory, calibrateJudge, calibrateJudgeContinuous, canonicalJson, capabilityHeadroom, captureFetchToRawSink, certificationEvidenceDigest, checkCanaries, checkServedModel, checkTraceContracts, chiSquared, chiSquaredPValue, clamp01, classifyFailure, classifyFailureReason, cliffsDelta, cohensD, comparePairedArms, compileTraceContractSpec, completionVerdict, computeFindingId, computeToolUseMetrics, confidenceInterval, contentHash, continuousAgreement, controlRunToFeedbackTrajectory, corpusInterRaterAgreement, corpusInterRaterAgreementFromJudgeScores, costForTokenPricing, costForUsage, costReceiptFromLlm, costReceiptFromLlmError, createAntiSlopJudge, createBoundedTraceAnalysisStore, createChatClient, createChatTraceEngine, createDspyRlmTraceEngine, createFeedbackTrajectory, createLlmCorrectnessChecker, createLlmReviewer, createTraceAnalyst, decidePairedPromotion, defineAgentEval, defineEquivalenceCheck, deployGateLayer, describeServedModelCheck, describeTraceInsightScope, diffFindings, diffScorecard, discoverPersonas, domainEvidencePattern, dominates, eProcess, ensembleJudge, equivalenceVerdict, errorStreakDetector, estimateCost, estimateTokens, evaluateActionPolicy, evaluateInterimReleaseConfidence, evaluateOracles, evaluateReleaseConfidence, evaluateTraceContract, expandProfileAxes, explainTraceContract, exportProductBenchmark, exportProductBenchmarkRuns, exportRunAsOtlp, extractErrorCount, extractProducedState, extractUsage, extractUsageFromSse, failureBlame, failureClusterView, feedbackTrajectoriesToDatasetScenarios, feedbackTrajectoriesToOptimizerRows, feedbackTrajectoryToOptimizerRow, fileVerdictCache, fisherExactTwoSided, formatScorecardDiff, gainHistogram, gateTreatmentApplied, gradeSemanticStatus, groupRunsByAgentProfileCell, harnessAxisOf, hashContent, hashJson, holm, inMemoryReviewStore, inferDomainKeywords, interRaterReliability, interpretCliffs, iqr, isJudgeSpan, isLlmSpan, isModelPriced, isRunRecord, isToolSpan, isTransientLlmError, jsonShape, jsonlReviewStore, jsonlRunRecordBackend, judgeAgreementView, judgeFamily, judgeGateDecision, judgeSpans, knowledgeReadinessTracePayload, leaderboard, linearRegressionSlope, lintTraceContractSpec, llmJudge, loadScorecard, localCommandRunner, makeFinding, makePolicyEditCandidateRecord, makeProposalFinding, manifestContentDigest, mannWhitneyU, maximumChargeForLlmRequest, mcnemar, mcnemarPower, mcnemarRequiredN, meanConfidenceInterval, measureJudgeAgreement, minimumPairsForPairedDeltaTest, mintRolloutRows, modelHasSnapshot, mulberry32, normalTwoSidedPValue, objectiveEval, observeAll, otlpTextToTraceAnalysisStore, pairArms, pairRunRecords, pairedBootstrap, pairedCohensDz, pairedDeltaTest, pairedEvalueSequence, pairedMde, pairedPromotionPower, pairedRiskDifference, pairedRiskDifferenceExact, pairedRiskDifferenceScore, pairedSignTest, pairedTTest, paretoFrontier, parseReflectionResponse, parseRunRecordSafe, partialCredit, partitionHeldOut, passAtK, passHatK, pearsonR, percentileNearestRank, preflightModels, productBenchmarkRepoIdentity, profile_exports as profile, projectRuntimeTrajectoryEvidence, proposeSynthesisTargets, ranks, readProductBenchmarkManifest, recordRuns, recordRunsToScorecard, redTeamDataset, redTeamReport, redact, redactForShare, redactText, registerCalibrationSet, renderPreferenceMemoryMarkdown, repeatedActionDetector, requiredPairedSampleSize, requiredPairsForPairedPromotion, requiredSampleSize, resolveModelPricing, resolveSeat, rocAuc, runAgentControlLoop, runBoundedProcess, runCampaign, runCanaries, runEquivalenceCheck, runEvalCampaign, runIntentMatchJudge, runKeywordCoverageJudge, runKeywordCoverageJudgeUrl, runProposeReview, runSemanticConceptJudge, runSkillEval, runTaskScore, runsForScenario, sampleMedian, scoreKnowledgeReadiness, scoreRedTeamOutput, scoreTraceInsightReadiness, seatPresets, selfImprove, sequentialCrossingHorizon, sequentialPairedPower, shareAllowed, skillEvalTraceFromRun, snapshotFromJudgeAgreement, spanRecordsToTraceAnalysisStore, spearmanR, stripFencedJson, studentTCritical, studentTTwoSidedPValue, subjectiveEval, summarizeBackendIntegrity, summarizeDistribution, summarizeNumberSeries, summarizePreferenceMemory, summarizeSample, summaryTable, toAgentProfileJson, tokenizeDomainWords, toolSpansToTraceAnalysisStore, toolWasteView, traceContract, trajectoryTimingBoundary, transientDispatchFailure, twoByTwoPValue, userQuestionsForKnowledgeGaps, validateRunRecord, verbosityBias, verifyAgentProfileCell, verifyAttestation, verifyCompletion, viteDeployRunner, weightedComposite, weightedMean, welchsTTest, wilcoxonSignedRank, wilson, withAssignedFeedbackSplit, withJudgeRetry, wranglerDeployRunner };
|
|
8044
|
+
export { AGENT_PROFILE_KINDS, ATTESTATION_ALGORITHM, AgentEvalError, AnalystRegistry, BOOTSTRAP_GATE_MIN_N, BackendIntegrityError, BudgetBreachError, BudgetGuard, CODING_HARNESSES, ConfigError, CostAccountingIncompleteError, CostCeilingReachedError, CostLedger, CostTracker, CrossFamilyError, DEFAULT_BOUNDED_PROCESS_TIMEOUT_MS, DEFAULT_JUDGE_GATE_POLICY, DEFAULT_RED_TEAM_CORPUS, DEFAULT_TRACE_ANALYST_BUDGETS, DEFAULT_TRACE_ANALYST_KINDS, Dataset, ERROR_COUNT_PATTERNS, EquivalenceProtocolError, FAILURE_CLASSES, FAILURE_MODE_KIND_SPEC, FileSystemFeedbackTrajectoryStore, FileSystemRawProviderSink, FileSystemTraceStore, FindingsStore, HARNESS_NATIVE_MODEL, HeldOutGate, InMemoryFeedbackTrajectoryStore, InMemoryRawProviderSink, InMemoryTraceStore, JudgeError, JudgeGateRefusedError, LlmCallError, LlmResponseError, MODEL_PRICING, ModelSubstitutionError, MultiLayerVerifier, NoopRawProviderSink, NotFoundError, OUTPUT_VALUE, OtlpFileTraceStore, PairwiseSteeringOptimizer, ProductClient, PromptRegistry, REDACTION_VERSION, RunIntegrityError, RunRecordValidationError, SEMANTIC_CONCEPT_JUDGE_VERSION, TraceEmitter, UNKNOWN_MODEL, VERIFICATION_STRATEGIES, VERIFICATION_STRATEGY_SOURCES, ValidationError, acquisitionPlansForKnowledgeGaps, addCalibrationVerdicts, agentProfileCellKey, agentProfileHash, agentProfileId, aggregateJudgeVerdicts, aggregateRunScore, analystRunDigest, analystRunToFeedbackTrajectory, analystRunToReviewRequests, analyzeAntiSlop, analyzeRuns, analyzeSeries, analyzeTraces, argHash, assertCapabilityHeadroom, assertContains, assertCrossFamily, assertCrossFamilyServed, assertEventCount, assertExists, assertHasField, assertHttpOk, assertJudgeMayGate, assertLatencyUnder, assertNoHiddenLeak, assertNotContains, assertProductBenchmarkRun, assertRealBackend, assertRunCaptured, assertServedModel, assertServedModels, assertSingleBackend, assertStatus, assessShareSafety, assignFeedbackSplit, attest, benjaminiHochberg, blendHeldout, blockingKnowledgeEval, bonferroni, bootstrapCi, budgetBreachView, buildAgentProfileCell, buildDefaultAnalystRegistry, buildReflectionPrompt, buildTraceInsightContext, buildTraceInsightPrompt, buildTrajectory, calibrateJudge, calibrateJudgeContinuous, canonicalJson, capabilityHeadroom, captureFetchToRawSink, certificationEvidenceDigest, checkCanaries, checkServedModel, checkTraceContracts, chiSquared, chiSquaredPValue, clamp01, classifyFailure, classifyFailureReason, cliffsDelta, cohensD, comparePairedArms, compileTraceContractSpec, completionVerdict, computeFindingId, computeToolUseMetrics, confidenceInterval, contentHash, continuousAgreement, contractSpansFromHarnessSession, controlRunToFeedbackTrajectory, corpusInterRaterAgreement, corpusInterRaterAgreementFromJudgeScores, costForTokenPricing, costForUsage, costReceiptFromLlm, costReceiptFromLlmError, createAntiSlopJudge, createBoundedTraceAnalysisStore, createChatClient, createChatTraceEngine, createDspyRlmTraceEngine, createFeedbackTrajectory, createLlmCorrectnessChecker, createLlmReviewer, createTraceAnalyst, decidePairedPromotion, defineAgentEval, defineEquivalenceCheck, deployGateLayer, describeServedModelCheck, describeTraceInsightScope, diffFindings, diffScorecard, discoverPersonas, domainEvidencePattern, dominates, eProcess, ensembleJudge, equivalenceVerdict, errorStreakDetector, estimateCost, estimateTokens, evaluateActionPolicy, evaluateInterimReleaseConfidence, evaluateOracles, evaluateReleaseConfidence, evaluateTraceContract, expandProfileAxes, explainTraceContract, exportProductBenchmark, exportProductBenchmarkRuns, exportRunAsOtlp, extractErrorCount, extractProducedState, extractUsage, extractUsageFromSse, failureBlame, failureClusterView, feedbackTrajectoriesToDatasetScenarios, feedbackTrajectoriesToOptimizerRows, feedbackTrajectoryToOptimizerRow, fileVerdictCache, fisherExactTwoSided, formatScorecardDiff, gainHistogram, gateTreatmentApplied, gradeSemanticStatus, groupRunsByAgentProfileCell, harnessAxisOf, hashContent, hashJson, holm, inMemoryReviewStore, inferDomainKeywords, interRaterReliability, interpretCliffs, iqr, isJudgeSpan, isLlmSpan, isModelPriced, isRunRecord, isToolSpan, isTransientLlmError, jsonShape, jsonlReviewStore, jsonlRunRecordBackend, judgeAgreementView, judgeFamily, judgeGateDecision, judgeSpans, knowledgeReadinessTracePayload, leaderboard, linearRegressionSlope, lintTraceContractSpec, llmJudge, loadScorecard, localCommandRunner, makeFinding, makePolicyEditCandidateRecord, makeProposalFinding, manifestContentDigest, mannWhitneyU, maximumChargeForLlmRequest, mcnemar, mcnemarPower, mcnemarRequiredN, meanConfidenceInterval, measureJudgeAgreement, minimumPairsForPairedDeltaTest, mintRolloutRows, modelHasSnapshot, mulberry32, normalTwoSidedPValue, objectiveEval, observeAll, otlpTextToTraceAnalysisStore, pairArms, pairRunRecords, pairedBootstrap, pairedCohensDz, pairedDeltaTest, pairedEvalueSequence, pairedMde, pairedPromotionPower, pairedRiskDifference, pairedRiskDifferenceExact, pairedRiskDifferenceScore, pairedSignTest, pairedTTest, paretoFrontier, parseReflectionResponse, parseRunRecordSafe, partialCredit, partitionHeldOut, passAtK, passHatK, pearsonR, percentileNearestRank, preflightModels, productBenchmarkRepoIdentity, profile_exports as profile, projectRuntimeTrajectoryEvidence, proposeSynthesisTargets, ranks, readProductBenchmarkManifest, recordRuns, recordRunsToScorecard, redTeamDataset, redTeamReport, redact, redactForShare, redactText, registerCalibrationSet, renderPreferenceMemoryMarkdown, repeatedActionDetector, requiredPairedSampleSize, requiredPairsForPairedPromotion, requiredSampleSize, resolveModelPricing, resolveSeat, rocAuc, runAgentControlLoop, runBoundedProcess, runCampaign, runCanaries, runEquivalenceCheck, runEvalCampaign, runIntentMatchJudge, runKeywordCoverageJudge, runKeywordCoverageJudgeUrl, runProposeReview, runSemanticConceptJudge, runSkillEval, runTaskScore, runsForScenario, sampleMedian, scoreKnowledgeReadiness, scoreRedTeamOutput, scoreTraceInsightReadiness, seatPresets, selfImprove, sequentialCrossingHorizon, sequentialPairedPower, shareAllowed, skillEvalTraceFromRun, snapshotFromJudgeAgreement, spanRecordsToTraceAnalysisStore, spearmanR, stripFencedJson, studentTCritical, studentTTwoSidedPValue, subjectiveEval, summarizeBackendIntegrity, summarizeDistribution, summarizeNumberSeries, summarizePreferenceMemory, summarizeSample, summaryTable, toAgentProfileJson, tokenizeDomainWords, toolSpansToTraceAnalysisStore, toolWasteView, traceContract, trajectoryTimingBoundary, transientDispatchFailure, twoByTwoPValue, userQuestionsForKnowledgeGaps, validateRunRecord, verbosityBias, verifyAgentProfileCell, verifyAttestation, verifyCompletion, viteDeployRunner, weightedComposite, weightedMean, welchsTTest, wilcoxonSignedRank, wilson, withAssignedFeedbackSplit, withJudgeRetry, wranglerDeployRunner };
|
|
9127
8045
|
|
|
9128
8046
|
//# sourceMappingURL=index.js.map
|