@tangle-network/agent-eval 0.49.0 → 0.50.1
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 +135 -0
- package/README.md +235 -331
- package/dist/adapters/http.d.ts +1 -1
- package/dist/adapters/langchain.d.ts +1 -1
- package/dist/adapters/otel.d.ts +8 -2
- package/dist/campaign/index.d.ts +3 -3
- package/dist/{chunk-PD3MH6WU.js → chunk-5KSDYBYH.js} +2 -2
- package/dist/{chunk-MNL6LXGQ.js → chunk-EGIPWXHL.js} +2 -98
- package/dist/chunk-EGIPWXHL.js.map +1 -0
- package/dist/{chunk-OYI6RZJK.js → chunk-FQK2CCIM.js} +1 -1
- package/dist/chunk-FQK2CCIM.js.map +1 -0
- package/dist/chunk-MAZ26DC7.js +99 -0
- package/dist/chunk-MAZ26DC7.js.map +1 -0
- package/dist/chunk-SHTXZ4O2.js +113 -0
- package/dist/chunk-SHTXZ4O2.js.map +1 -0
- package/dist/{chunk-KQ26DYTQ.js → chunk-UBQGWD3O.js} +2 -2
- package/dist/contract/index.d.ts +206 -9
- package/dist/contract/index.js +751 -3
- package/dist/contract/index.js.map +1 -1
- package/dist/governance/index.d.ts +1 -1
- package/dist/hosted/index.d.ts +8 -192
- package/dist/hosted/index.js +1 -1
- package/dist/index-BRxz6qov.d.ts +409 -0
- package/dist/index.d.ts +18 -462
- package/dist/index.js +14 -106
- package/dist/index.js.map +1 -1
- package/dist/meta-eval/index.d.ts +3 -3
- package/dist/openapi.json +1 -1
- package/dist/{outcome-store-BxJ3DQKJ.d.ts → outcome-store-D6KWmYvj.d.ts} +1 -1
- package/dist/registry-8KAs18kY.d.ts +457 -0
- package/dist/{release-report-DBB8lB1P.d.ts → release-report-DSu0DWy8.d.ts} +3 -296
- package/dist/reporting.d.ts +6 -4
- package/dist/reporting.js +6 -4
- package/dist/{researcher-CHMO56K0.d.ts → researcher-LZD0qHEa.d.ts} +1 -1
- package/dist/rl.d.ts +9 -8
- package/dist/rl.js +3 -2
- package/dist/rl.js.map +1 -1
- package/dist/{rubric-predictive-validity-CJ08tGwq.d.ts → rubric-predictive-validity-ByZEC3BX.d.ts} +1 -1
- package/dist/{run-improvement-loop-B-L8GgpW.d.ts → run-improvement-loop-BPMjNKMJ.d.ts} +2 -2
- package/dist/sequential-5iSVfzl2.d.ts +139 -0
- package/dist/store-CJbzDxZ2.d.ts +220 -0
- package/dist/{sequential-CbFH___X.d.ts → summary-report-B7gNRX-r.d.ts} +1 -139
- package/dist/traces.d.ts +3 -220
- package/dist/{types-8u72Gc76.d.ts → types-Dbj5gu8n.d.ts} +1 -1
- package/dist/types-DhqpAi_z.d.ts +296 -0
- package/docs/concepts.md +20 -0
- package/docs/customer-journeys.md +208 -0
- package/docs/insight-report.md +337 -0
- package/package.json +1 -1
- package/dist/chunk-MNL6LXGQ.js.map +0 -1
- package/dist/chunk-OYI6RZJK.js.map +0 -1
- /package/dist/{chunk-PD3MH6WU.js.map → chunk-5KSDYBYH.js.map} +0 -0
- /package/dist/{chunk-KQ26DYTQ.js.map → chunk-UBQGWD3O.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/contamination-guard.ts"],"sourcesContent":["/**\n * ContaminationGuard — ensures held-out scenarios don't leak into\n * training/prompt paths, and flags model memorization.\n *\n * Three probes:\n * 1. `checkCanaries(output, scenario)` — if the scenario carries a\n * canary token, it MUST NOT appear in the agent's output.\n * Canaries are strings that are statistically impossible to\n * reconstruct from the scenario description alone — so if they\n * echo back, the model memorized them.\n * 2. `canaryLeakView(store)` — cross-corpus view of every run whose\n * output contained a canary, with the offending scenario + run.\n * 3. `HoldoutAuditor` — wraps a Dataset and emits a structured error\n * on any code path that reads holdout scenarios but doesn't flag\n * `purpose: 'evaluation'`. Keeps engineers honest.\n */\n\nimport type { DatasetScenario } from './dataset'\nimport { llmSpans } from './trace/query'\nimport type { TraceStore } from './trace/store'\n\nexport interface CanaryLeak {\n scenarioId: string\n canary: string\n runId?: string\n evidence: string\n}\n\nexport function checkCanaries(output: string, scenarios: DatasetScenario[]): CanaryLeak[] {\n const leaks: CanaryLeak[] = []\n for (const s of scenarios) {\n if (!s.canary) continue\n if (output.includes(s.canary)) {\n leaks.push({ scenarioId: s.id, canary: s.canary, evidence: excerpt(output, s.canary) })\n }\n }\n return leaks\n}\n\n/**\n * Behavioral canary: tests the AGENT, not the eval grep.\n *\n * - `forbiddenPattern` PRESENT in output ⇒ AGENT EMITTED BAD CONTENT ⇒ LEAK.\n * - `forbiddenPattern` ABSENT from output ⇒ AGENT HELD THE LINE ⇒ PASS.\n *\n * Use when running known-bad-prompt scenarios against the agent under\n * test and you want to know if the agent misbehaved. The classical\n * {@link checkCanaries} / {@link import('./canary').runCanaries | runCanaries}\n * test whether the eval check fires when the bad output is forced\n * into the eval flow — different question, different answer.\n *\n * Pattern resolution order (first match wins):\n * 1. `scenario.forbiddenPattern` — if it parses as `/body/flags`,\n * treated as a regex; otherwise a literal substring.\n * 2. `scenario.canary` — literal substring fallback so the helper\n * works on existing scenario fixtures.\n *\n * Returns `null` when nothing forbidden was found OR the scenario\n * declared no pattern.\n */\nexport function checkBehavioralCanary(\n output: string,\n scenario: DatasetScenario,\n): CanaryLeak | null {\n const pattern = scenario.forbiddenPattern ?? scenario.canary\n if (!pattern) return null\n const hit = matchForbidden(output, pattern)\n if (!hit) return null\n return {\n scenarioId: scenario.id,\n canary: pattern,\n evidence: excerpt(output, hit),\n }\n}\n\n/**\n * Behavioral canary over many (scenario, output) pairs. Sibling to\n * {@link import('./canary').runCanaries | runCanaries} — same idea\n * (run-many → report) but the question being answered is \"did the\n * AGENT misbehave?\" rather than \"did the EVAL grep fire?\".\n *\n * Returns one `CanaryLeak` per pair where the agent's output\n * contained its scenario's `forbiddenPattern` (or `canary` fallback).\n */\nexport function runBehavioralCanaries(\n cases: Array<{ scenario: DatasetScenario; output: string; runId?: string }>,\n): CanaryLeak[] {\n const leaks: CanaryLeak[] = []\n for (const c of cases) {\n const leak = checkBehavioralCanary(c.output, c.scenario)\n if (leak) leaks.push({ ...leak, runId: c.runId ?? leak.runId })\n }\n return leaks\n}\n\n/**\n * Resolve a forbidden-pattern string to the matched substring inside\n * `output`. `/body/flags` notation is interpreted as a regex; anything\n * else is a literal substring.\n */\nfunction matchForbidden(output: string, pattern: string): string | null {\n const re = tryParseRegex(pattern)\n if (re) {\n const m = output.match(re)\n return m && m[0].length > 0 ? m[0] : null\n }\n return output.includes(pattern) ? pattern : null\n}\n\nfunction tryParseRegex(pattern: string): RegExp | null {\n if (pattern.length < 2 || pattern[0] !== '/') return null\n const last = pattern.lastIndexOf('/')\n if (last <= 0) return null\n const body = pattern.slice(1, last)\n const flags = pattern.slice(last + 1)\n if (!/^[gimsuy]*$/.test(flags)) return null\n try {\n return new RegExp(body, flags)\n } catch {\n return null\n }\n}\n\n/**\n * Scan the LLM-output history in a corpus; returns every case where a\n * canary from a known scenario appeared in agent output. Pass the full\n * set of scenarios whose canaries you care about (typically the whole\n * held-out slice).\n */\nexport async function canaryLeakView(\n store: TraceStore,\n scenarios: DatasetScenario[],\n): Promise<CanaryLeak[]> {\n const targets = scenarios.filter((s) => !!s.canary)\n if (targets.length === 0) return []\n const spans = await llmSpans(store)\n const leaks: CanaryLeak[] = []\n for (const span of spans) {\n const output = span.output ?? ''\n for (const s of targets) {\n if (s.canary && output.includes(s.canary)) {\n leaks.push({\n scenarioId: s.id,\n canary: s.canary,\n runId: span.runId,\n evidence: excerpt(output, s.canary),\n })\n }\n }\n }\n return leaks\n}\n\nexport class HoldoutAuditor {\n private scenarios: DatasetScenario[]\n private accessLog: Array<{ scenarioId: string; purpose: string; at: number }> = []\n\n constructor(scenarios: DatasetScenario[]) {\n this.scenarios = scenarios\n }\n\n /** Retrieve a holdout scenario for a declared purpose. Non-'evaluation' throws. */\n get(scenarioId: string, purpose: 'evaluation' | 'debugging'): DatasetScenario {\n if (purpose !== 'evaluation' && purpose !== 'debugging') {\n throw new Error(\n `HoldoutAuditor.get: purpose must be 'evaluation' or 'debugging', got ${purpose}`,\n )\n }\n const s = this.scenarios.find((x) => x.id === scenarioId)\n if (!s) throw new Error(`holdout scenario \"${scenarioId}\" not found`)\n this.accessLog.push({ scenarioId, purpose, at: Date.now() })\n return s\n }\n\n getAccessLog(): ReadonlyArray<{ scenarioId: string; purpose: string; at: number }> {\n return this.accessLog\n }\n}\n\nfunction excerpt(source: string, needle: string): string {\n const at = source.indexOf(needle)\n if (at < 0) return ''\n const start = Math.max(0, at - 30)\n const end = Math.min(source.length, at + needle.length + 30)\n return (start > 0 ? '…' : '') + source.slice(start, end) + (end < source.length ? '…' : '')\n}\n"],"mappings":"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","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
summaryTable
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EGIPWXHL.js";
|
|
4
4
|
import {
|
|
5
5
|
VerificationError
|
|
6
6
|
} from "./chunk-QYJT52YW.js";
|
|
@@ -574,4 +574,4 @@ export {
|
|
|
574
574
|
judgeReplayGate,
|
|
575
575
|
renderReleaseReport
|
|
576
576
|
};
|
|
577
|
-
//# sourceMappingURL=chunk-
|
|
577
|
+
//# sourceMappingURL=chunk-UBQGWD3O.js.map
|
package/dist/contract/index.d.ts
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { S as Scenario, M as MutableSurface,
|
|
2
|
-
export {
|
|
3
|
-
import { C as CampaignStorage,
|
|
4
|
-
export { D as DefaultProductionGateOptions, E as EvolutionaryDriverOptions, G as GepaDriverOptions, H as HeldOutGateOptions,
|
|
5
|
-
export { D as DeploymentOutcome, F as FileSystemOutcomeStore,
|
|
6
|
-
import { HostedTenant } from '../
|
|
1
|
+
import { S as Scenario, M as MutableSurface, b as DispatchContext, a as JudgeConfig, I as ImprovementDriver, G as Gate } from '../types-Dbj5gu8n.js';
|
|
2
|
+
export { f as CampaignAggregates, g as CampaignArtifactWriter, h as CampaignCellResult, i as CampaignCostMeter, j as CampaignResult, k as CampaignTraceWriter, C as CodeSurface, D as Dispatch, l as GateContext, m as GateDecision, n as GateResult, o as GenerationCandidate, p as GenerationRecord, r as JudgeDimension, J as JudgeScore, t as Mutator, O as OptimizerConfig, v as SessionScript } from '../types-Dbj5gu8n.js';
|
|
3
|
+
import { C as CampaignStorage, d as RunImprovementLoopResult } from '../run-improvement-loop-BPMjNKMJ.js';
|
|
4
|
+
export { D as DefaultProductionGateOptions, E as EvolutionaryDriverOptions, G as GepaDriverOptions, H as HeldOutGateOptions, R as RunCampaignOptions, b as RunEvalOptions, c as RunImprovementLoopOptions, g as composeGate, h as defaultProductionGate, i as evolutionaryDriver, j as fsCampaignStorage, k as gepaDriver, l as heldOutGate, m as inMemoryCampaignStorage, r as runCampaign, n as runEval, p as runImprovementLoop } from '../run-improvement-loop-BPMjNKMJ.js';
|
|
5
|
+
export { D as DeploymentOutcome, F as FileSystemOutcomeStore, b as FileSystemOutcomeStoreOptions, I as InMemoryOutcomeStore, O as OutcomeStore } from '../outcome-store-D6KWmYvj.js';
|
|
6
|
+
import { a as HostedTenant, I as InsightReport, T as TraceSpanEvent } from '../index-BRxz6qov.js';
|
|
7
|
+
export { F as FailureClusterInsight, b as InterRaterInsight, J as JudgeInsight, L as LiftInsight, O as OutcomeCorrelationInsight, R as Recommendation, c as ReleaseSummary, S as ScalarDistribution } from '../index-BRxz6qov.js';
|
|
8
|
+
import { A as AnalystRegistry } from '../registry-8KAs18kY.js';
|
|
9
|
+
import { a as DatasetScenario } from '../dataset-BlwAtYYf.js';
|
|
10
|
+
import { R as RunRecord, a as RunSplitTag } from '../run-record-BGY6bHRh.js';
|
|
7
11
|
import '../llm-client-BXVRUZyX.js';
|
|
8
12
|
import '../errors-mje_cKOs.js';
|
|
9
13
|
import '../raw-provider-sink-C46HDghv.js';
|
|
10
14
|
import '../red-team-30II1T4o.js';
|
|
11
|
-
import '../dataset-BlwAtYYf.js';
|
|
12
15
|
import '../store-Db2Bv8Cf.js';
|
|
13
|
-
import '../
|
|
16
|
+
import '../summary-report-B7gNRX-r.js';
|
|
17
|
+
import '../failure-cluster-Cw65_5FY.js';
|
|
18
|
+
import '../judge-calibration-DilmB3Ml.js';
|
|
19
|
+
import '../store-CJbzDxZ2.js';
|
|
20
|
+
import '../types-DhqpAi_z.js';
|
|
21
|
+
import '@tangle-network/tcloud';
|
|
14
22
|
|
|
15
23
|
/**
|
|
16
24
|
* # `selfImprove()` — the LAND-tier one-shot.
|
|
@@ -188,6 +196,13 @@ interface SelfImproveResult<TScenario extends Scenario, TArtifact> {
|
|
|
188
196
|
durationMs: number;
|
|
189
197
|
/** Total cost across baseline + every generation. */
|
|
190
198
|
totalCostUsd: number;
|
|
199
|
+
/**
|
|
200
|
+
* Rigor packet: distributional summary, paired-bootstrap lift CI,
|
|
201
|
+
* judge stats, contamination check, recommendations. Wired through
|
|
202
|
+
* `analyzeRuns()` on the baseline + winner cells of the campaign.
|
|
203
|
+
* Hosted-tier dashboards render this as the v3-vs-v4 decision view.
|
|
204
|
+
*/
|
|
205
|
+
insight: InsightReport;
|
|
191
206
|
/**
|
|
192
207
|
* Raw substrate result for advanced inspection — full per-generation
|
|
193
208
|
* candidates, full campaign artifacts, all judge scores. Useful for
|
|
@@ -222,4 +237,186 @@ interface SelfImproveResult<TScenario extends Scenario, TArtifact> {
|
|
|
222
237
|
*/
|
|
223
238
|
declare function selfImprove<TScenario extends Scenario, TArtifact>(opts: SelfImproveOptions<TScenario, TArtifact>): Promise<SelfImproveResult<TScenario, TArtifact>>;
|
|
224
239
|
|
|
225
|
-
|
|
240
|
+
/**
|
|
241
|
+
* # `analyzeRuns()` — turn a set of agent runs into an actionable decision packet.
|
|
242
|
+
*
|
|
243
|
+
* Wires the substrate's statistical, calibration, clustering, Pareto, and
|
|
244
|
+
* release-confidence primitives into one `InsightReport`. Two top-level
|
|
245
|
+
* entry points use this function:
|
|
246
|
+
*
|
|
247
|
+
* - `selfImprove()` calls it on the campaign output to attach a packet
|
|
248
|
+
* to every run.
|
|
249
|
+
* - Consumers with observed `RunRecord[]` (production traces, gold
|
|
250
|
+
* corpora, approve/reject tables) call it directly via `analyzeRuns()`
|
|
251
|
+
* for analysis without a closed loop.
|
|
252
|
+
*
|
|
253
|
+
* Every section is opt-in based on what the input data supports — the
|
|
254
|
+
* function never invents signal. If runs carry no judge scores, `judges`
|
|
255
|
+
* is empty. If there's no baseline/candidate split, `lift` is undefined.
|
|
256
|
+
* If no `analyst` is wired, `failureClusters` is undefined.
|
|
257
|
+
*
|
|
258
|
+
* The `recommendations` array is the human-readable layer; everything
|
|
259
|
+
* else is the evidence backing each recommendation.
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
interface AnalyzeRunsOptions {
|
|
263
|
+
/** The runs to analyze. */
|
|
264
|
+
runs: RunRecord[];
|
|
265
|
+
/** Which split to score against when reading composite from RunOutcome.
|
|
266
|
+
* Default: holdout when ANY run has a `holdoutScore`, else search. */
|
|
267
|
+
split?: 'search' | 'holdout' | 'auto';
|
|
268
|
+
/** Pairwise analysis configuration. When both `baselineCandidateId` and
|
|
269
|
+
* `candidateCandidateId` are present, lift is computed on paired
|
|
270
|
+
* (experimentId, seed) tuples shared between the two sides. */
|
|
271
|
+
baselineCandidateId?: string;
|
|
272
|
+
candidateCandidateId?: string;
|
|
273
|
+
/** Canary scenarios — checked against every run's raw output for
|
|
274
|
+
* holdout contamination. */
|
|
275
|
+
canaryScenarios?: DatasetScenario[];
|
|
276
|
+
/** Analyst registry for failure clustering. When omitted, the
|
|
277
|
+
* `failureClusters` section is left undefined. */
|
|
278
|
+
analyst?: AnalystRegistry;
|
|
279
|
+
/** Downstream outcome metric per run (e.g. engagement rate, approval
|
|
280
|
+
* rate, downstream pass rate). When present, the report includes
|
|
281
|
+
* `outcomeCorrelation` + a simple linear reward model fit. */
|
|
282
|
+
outcomeSignal?: {
|
|
283
|
+
metric: string;
|
|
284
|
+
valueByRunId: Record<string, number>;
|
|
285
|
+
};
|
|
286
|
+
/** Multi-rater feedback for inter-rater agreement. Each entry is one
|
|
287
|
+
* rater's score for one run. Two or more raters → kappa + disagreement
|
|
288
|
+
* triage list. */
|
|
289
|
+
raterScores?: Array<{
|
|
290
|
+
runId: string;
|
|
291
|
+
rater: string;
|
|
292
|
+
score: number;
|
|
293
|
+
}>;
|
|
294
|
+
/** Number of histogram bins for distributional summaries. Default 12. */
|
|
295
|
+
histogramBins?: number;
|
|
296
|
+
/** Decision threshold — the smallest composite lift the caller cares
|
|
297
|
+
* about. Used by the recommendations engine to call ship vs hold.
|
|
298
|
+
* Default 0.02. */
|
|
299
|
+
decisionThreshold?: number;
|
|
300
|
+
}
|
|
301
|
+
declare function analyzeRuns(opts: AnalyzeRunsOptions): Promise<InsightReport>;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* # `intake/feedback-table` — multi-rater approve/reject corpus → `RunRecord[]`.
|
|
305
|
+
*
|
|
306
|
+
* The generic shape behind Obsidian's `#approved` / `#rejected` tags, a
|
|
307
|
+
* Google Sheet, a Postgres `feedback` table, or any CSV with ratings.
|
|
308
|
+
*
|
|
309
|
+
* Caller supplies one row per (run, rater) tuple plus per-run metadata; the
|
|
310
|
+
* adapter rolls them up into the substrate-canonical `RunRecord` shape so
|
|
311
|
+
* `analyzeRuns({ runs, raterScores })` can produce inter-rater agreement,
|
|
312
|
+
* disagreement triage, and downstream recommendations.
|
|
313
|
+
*
|
|
314
|
+
* Per-run `RunRecord.outcome.searchScore` is the rater-mean rating
|
|
315
|
+
* (normalised to 0..1 when scale is supplied); `outcome.raw` carries the
|
|
316
|
+
* per-rater scores keyed by rater id for downstream attribution.
|
|
317
|
+
*/
|
|
318
|
+
|
|
319
|
+
interface FeedbackTableRow {
|
|
320
|
+
/** Stable id for this run — the unit a rater scored. Drives pairing
|
|
321
|
+
* across analysis primitives. */
|
|
322
|
+
runId: string;
|
|
323
|
+
/** Identifier of the rater that produced this rating. */
|
|
324
|
+
rater: string;
|
|
325
|
+
/** The rating itself. Accepts boolean (approve/reject), 0..1 scalar,
|
|
326
|
+
* or any numeric scale — see `scale`. */
|
|
327
|
+
rating: number | boolean;
|
|
328
|
+
/** Optional metadata carried through to `RunRecord.outcome.raw` and the
|
|
329
|
+
* custom-shape metadata bag. */
|
|
330
|
+
metadata?: Record<string, unknown>;
|
|
331
|
+
}
|
|
332
|
+
interface FeedbackTableMeta {
|
|
333
|
+
runId: string;
|
|
334
|
+
/** When omitted, defaults to `'feedback-corpus'`. Used to group related
|
|
335
|
+
* runs in `analyzeRuns()` lift analysis. */
|
|
336
|
+
experimentId?: string;
|
|
337
|
+
/** When omitted, defaults to `runId` — each run is its own candidate. */
|
|
338
|
+
candidateId?: string;
|
|
339
|
+
/** Cost in USD, when available. Set to 0 when unknown — the consumer's
|
|
340
|
+
* cost analysis sections will collapse gracefully. */
|
|
341
|
+
costUsd?: number;
|
|
342
|
+
/** Wall-clock ms, when available. Defaults to 0. */
|
|
343
|
+
wallMs?: number;
|
|
344
|
+
/** Model identifier including snapshot. Default `unknown@unknown`. */
|
|
345
|
+
model?: string;
|
|
346
|
+
/** Optional sha256 of the prompt; default `'sha256:unknown'`. */
|
|
347
|
+
promptHash?: string;
|
|
348
|
+
/** Default `'sha256:unknown'`. */
|
|
349
|
+
configHash?: string;
|
|
350
|
+
/** Default `'unknown'`. */
|
|
351
|
+
commitSha?: string;
|
|
352
|
+
/** Default `'holdout'` — feedback corpora are by nature the holdout
|
|
353
|
+
* signal a closed-loop improvement aims at. */
|
|
354
|
+
splitTag?: RunSplitTag;
|
|
355
|
+
/** Free-form metadata available to consumers via the cast-out path on
|
|
356
|
+
* the resulting RunRecord. */
|
|
357
|
+
extras?: Record<string, unknown>;
|
|
358
|
+
}
|
|
359
|
+
interface FromFeedbackTableOptions {
|
|
360
|
+
/** Per-(run, rater) ratings. */
|
|
361
|
+
ratings: FeedbackTableRow[];
|
|
362
|
+
/** Per-run metadata. When a runId appears in `ratings` but not here, the
|
|
363
|
+
* adapter synthesises minimal metadata with defaults documented above. */
|
|
364
|
+
meta?: FeedbackTableMeta[];
|
|
365
|
+
/** Rating scale. Provide `{ min, max }` for non-0..1 numeric scales.
|
|
366
|
+
* Booleans are normalised: true → 1, false → 0. Default: assumes
|
|
367
|
+
* ratings are already 0..1. */
|
|
368
|
+
scale?: {
|
|
369
|
+
min: number;
|
|
370
|
+
max: number;
|
|
371
|
+
};
|
|
372
|
+
/** When true, the rater scores are emitted into `raterScores` (a sibling
|
|
373
|
+
* array `analyzeRuns()` accepts) instead of being averaged into the
|
|
374
|
+
* run's `outcome.searchScore`. Default `true` — preserves rater-level
|
|
375
|
+
* signal for inter-rater analysis. */
|
|
376
|
+
emitRaterScores?: boolean;
|
|
377
|
+
}
|
|
378
|
+
interface FromFeedbackTableResult {
|
|
379
|
+
runs: RunRecord[];
|
|
380
|
+
/** Rater-level scores ready to pass into `analyzeRuns({ raterScores })`
|
|
381
|
+
* for inter-rater agreement + disagreement triage. */
|
|
382
|
+
raterScores: Array<{
|
|
383
|
+
runId: string;
|
|
384
|
+
rater: string;
|
|
385
|
+
score: number;
|
|
386
|
+
}>;
|
|
387
|
+
}
|
|
388
|
+
declare function fromFeedbackTable(opts: FromFeedbackTableOptions): FromFeedbackTableResult;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* # `intake/otel-spans` — OTel `TraceSpanEvent[]` → `RunRecord[]`.
|
|
392
|
+
*
|
|
393
|
+
* Turns an existing observability stream into the substrate-canonical
|
|
394
|
+
* `RunRecord` shape so consumers with logs but no eval discipline can
|
|
395
|
+
* call `analyzeRuns()` against their production traffic immediately.
|
|
396
|
+
*
|
|
397
|
+
* Pivot rule: spans are grouped by `tangle.runId` (the same attribute the
|
|
398
|
+
* hosted-tier wire format uses) or, when absent, by `traceId`. One group
|
|
399
|
+
* becomes one `RunRecord`. The root span (no `parentSpanId`) supplies:
|
|
400
|
+
*
|
|
401
|
+
* - `runId` (the group key)
|
|
402
|
+
* - `wallMs` from `endTimeUnixNano - startTimeUnixNano`
|
|
403
|
+
* - `model` from `gen_ai.request.model` / `llm.model` / `tangle.model`
|
|
404
|
+
* - cost from `cost.usd` / `gen_ai.usage.cost_usd` / `tangle.cost.usd`
|
|
405
|
+
* - token usage from `gen_ai.usage.{input,output}_tokens`
|
|
406
|
+
* - `outcome.searchScore` from `tangle.score` / `eval.score` when
|
|
407
|
+
* present; `outcome.raw` collects every numeric attribute.
|
|
408
|
+
*
|
|
409
|
+
* Spans that ERRORed (`status.code === 'ERROR'`) populate `failureMode`
|
|
410
|
+
* with their `name` so `analyzeRuns()`'s failure clustering sees them.
|
|
411
|
+
*/
|
|
412
|
+
|
|
413
|
+
interface FromOtelSpansOptions {
|
|
414
|
+
spans: TraceSpanEvent[];
|
|
415
|
+
/** Default split tag for synthesized records. Defaults to `'holdout'`. */
|
|
416
|
+
defaultSplit?: RunSplitTag;
|
|
417
|
+
/** Default `experimentId` when not present on any span. */
|
|
418
|
+
experimentId?: string;
|
|
419
|
+
}
|
|
420
|
+
declare function fromOtelSpans(opts: FromOtelSpansOptions): RunRecord[];
|
|
421
|
+
|
|
422
|
+
export { type AnalyzeRunsOptions, CampaignStorage, DispatchContext, type FeedbackTableMeta, type FeedbackTableRow, type FromFeedbackTableOptions, type FromFeedbackTableResult, type FromOtelSpansOptions, Gate, ImprovementDriver, InsightReport, JudgeConfig, MutableSurface, RunImprovementLoopResult, Scenario, type SelfImproveBudget, type SelfImproveLlm, type SelfImproveOptions, type SelfImproveProgressEvent, type SelfImproveResult, analyzeRuns, fromFeedbackTable, fromOtelSpans, selfImprove };
|