@attest-ai/core 1.0.0-rc.2 → 1.0.0-rc.4

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.
@@ -1,12 +1,12 @@
1
- import { InitializeResult, ProtocolLogger, ProtocolDiagnostic, Trace, Assertion, BatchBudget, EvaluateBatchResult, DriftReport, SimulatePersona, ConversationMessage, SimulateFaultConfig, Step, AssertionResult, Usage, Outcome } from './proto/index.cjs';
2
- export { AgentId, AssertionId, AssertionSpec, BiasProbe, ConstraintSpec, ContentSpec, ERR_ASSERTION_ERROR, ERR_ENGINE_ERROR, ERR_INVALID_TRACE, ERR_PROVIDER_ERROR, ERR_SESSION_ERROR, ERR_TIMEOUT, EmbeddingSpec, EngineTimeoutError, ErrorData, EvaluateBatchParams, Exchange, FailureClass, GenerateUserMessageParams, GenerateUserMessageResult, Handoff, InitializeParams, JudgeAgreement, JudgeMetadata, LlmJudgeSpec, OTLPConversionError, OUTCOME_FAIL, OUTCOME_PASS, OUTCOME_SKIP, PluginSpec, ProtocolDesyncError, ProtocolDiagnosticBuffer, ProtocolDiagnosticKind, ProtocolError, QueryDriftParams, QueryDriftResult, REASON_BUDGET_EXHAUSTED, REASON_JUDGE_ABSTAINED, REASON_MISSING_EVIDENCE, REASON_PROVIDER_NOT_CONFIGURED, REASON_PROVIDER_UNAVAILABLE, REASON_SHORT_CIRCUITED, REASON_SIMULATION, RPCError, RPCRequest, RPCResponse, STATUS_HARD_FAIL, STATUS_NOT_EVALUATED, STATUS_PASS, STATUS_SOFT_FAIL, STEP_AGENT_CALL, STEP_LLM_CALL, STEP_RETRIEVAL, STEP_TOOL_CALL, SchemaSpec, ShutdownResult, StepError, SubmitPluginResultParams, TYPE_CONSTRAINT, TYPE_CONTENT, TYPE_EMBEDDING, TYPE_LLM_JUDGE, TYPE_PLUGIN, TYPE_SCHEMA, TYPE_TRACE, TYPE_TRACE_TREE, TraceId, TraceMetadata, TraceSpec, TraceTreeSpec, Turn, agentId, assertionId, decodeResponse, encodeRequest, extractId, extractResult, layerForType, previewLine, traceId } from './proto/index.cjs';
1
+ import { InitializeResult, ProtocolLogger, ProtocolDiagnostic, Trace, Assertion, BatchBudget, BatchContext, EvaluateBatchResult, DriftReport, SimulatePersona, ConversationMessage, SimulateFaultConfig, Step, AssertionResult, Usage, Outcome } from './proto/index.cjs';
2
+ export { AgentId, AssertionId, AssertionSpec, BiasProbe, ConstraintSpec, ContentSpec, ERR_ASSERTION_ERROR, ERR_ENGINE_ERROR, ERR_INVALID_TRACE, ERR_PROVIDER_ERROR, ERR_SESSION_ERROR, ERR_TIMEOUT, EffectSpec, EmbeddingSpec, EngineTimeoutError, ErrorData, EvaluateBatchParams, Exchange, FailureClass, GenerateUserMessageParams, GenerateUserMessageResult, Handoff, InitializeParams, JudgeAgreement, JudgeMetadata, LlmJudgeSpec, OTLPConversionError, OUTCOME_FAIL, OUTCOME_PASS, OUTCOME_SKIP, PluginSpec, ProtocolDesyncError, ProtocolDiagnosticBuffer, ProtocolDiagnosticKind, ProtocolError, QueryDriftParams, QueryDriftResult, REASON_BUDGET_EXHAUSTED, REASON_JUDGE_ABSTAINED, REASON_MISSING_EVIDENCE, REASON_PROVIDER_NOT_CONFIGURED, REASON_PROVIDER_UNAVAILABLE, REASON_REPLAY_MISS, REASON_SHORT_CIRCUITED, REASON_SIMULATION, RPCError, RPCRequest, RPCResponse, STATUS_HARD_FAIL, STATUS_NOT_EVALUATED, STATUS_PASS, STATUS_SOFT_FAIL, STEP_AGENT_CALL, STEP_LLM_CALL, STEP_RETRIEVAL, STEP_TOOL_CALL, SchemaSpec, ShutdownResult, StepError, SubmitPluginResultParams, TYPE_CONSTRAINT, TYPE_CONTENT, TYPE_EFFECT, TYPE_EMBEDDING, TYPE_LLM_JUDGE, TYPE_PLUGIN, TYPE_SCHEMA, TYPE_TRACE, TYPE_TRACE_TREE, TraceId, TraceMetadata, TraceSpec, TraceTreeSpec, Turn, agentId, assertionId, decodeResponse, encodeRequest, extractId, extractResult, layerForType, previewLine, traceId } from './proto/index.cjs';
3
3
  import { ChildProcess } from 'node:child_process';
4
4
  import { Interface } from 'node:readline';
5
5
  import { AsyncLocalStorage } from 'node:async_hooks';
6
6
  import { EventEmitter } from 'node:events';
7
7
 
8
- declare const VERSION = "1.0.0-rc.2";
9
- declare const ENGINE_VERSION = "1.0.0-rc.2";
8
+ declare const VERSION = "1.0.0-rc.4";
9
+ declare const ENGINE_VERSION = "1.0.0-rc.4";
10
10
 
11
11
  declare class EngineManager {
12
12
  private enginePath;
@@ -84,6 +84,7 @@ declare class AttestClient {
84
84
  evaluateBatch(trace: Trace, assertions: readonly Assertion[], options?: {
85
85
  timeout?: number;
86
86
  budget?: BatchBudget;
87
+ context?: BatchContext;
87
88
  }): Promise<EvaluateBatchResult>;
88
89
  submitPluginResult(traceId: string, pluginName: string, assertionId: string, status: string, score: number, explanation: string, options?: {
89
90
  timeout?: number;
@@ -248,9 +249,52 @@ declare class TraceTree {
248
249
 
249
250
  type TrajectoryMode = "strict" | "unordered" | "subset" | "superset";
250
251
  type ArgOperator = "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in";
252
+ /** A resource's records filtered by exact field values. */
253
+ type Where = Record<string, unknown>;
254
+ /**
255
+ * Effect checks against one world snapshot, from {@link ExpectChain.world}. Each method adds
256
+ * an `effect` assertion (Layer 3) to the parent chain and returns it.
257
+ */
258
+ declare class WorldChecks<C> {
259
+ private readonly _snapshot;
260
+ private readonly _add;
261
+ constructor(snapshot: Record<string, unknown> | null, add: (spec: Record<string, unknown>) => C);
262
+ private addCheck;
263
+ /**
264
+ * Assert how many records of `resource` match `where`. Give `equals`, or `atMost` and/or
265
+ * `atLeast`. A violation reads `effect violated: 2 refunds for O-1042 (expected 1)`.
266
+ *
267
+ * @throws Error when no bound is given, or `equals` is combined with another bound.
268
+ *
269
+ * @example
270
+ * ```ts
271
+ * expect(trace).world(await world.state()).count("refunds", { equals: 1, where: { order_id: "O-1042" } });
272
+ * ```
273
+ */
274
+ count(resource: string, opts: {
275
+ equals?: number;
276
+ atMost?: number;
277
+ atLeast?: number;
278
+ where?: Where;
279
+ }): C;
280
+ /** Assert no two matching records share the same values for field(s) `by`. */
281
+ unique(resource: string, opts: {
282
+ by: string | string[];
283
+ where?: Where;
284
+ }): C;
285
+ /**
286
+ * Assert every matching record carries a distinct value in field `key` (default
287
+ * `idempotency_key`), the record field that stores the idempotency key.
288
+ */
289
+ idempotent(resource: string, opts?: {
290
+ key?: string;
291
+ where?: Where;
292
+ }): C;
293
+ }
251
294
  declare class ExpectChain {
252
295
  private readonly _result;
253
296
  private readonly _assertions;
297
+ private _worldBytes;
254
298
  constructor(result: AgentResult);
255
299
  get assertions(): Assertion[];
256
300
  get trace(): Trace;
@@ -565,6 +609,12 @@ declare class ExpectChain {
565
609
  toolArgSatisfies(tool: string, arg: string, op: ArgOperator, value: unknown, opts?: {
566
610
  soft?: boolean;
567
611
  }): this;
612
+ /**
613
+ * Check effects in a world snapshot:
614
+ * `expect(trace).world(await world.state()).count(...)`. `null` means the test ran without
615
+ * a world helper: the checks are `not_evaluated` (`missing_evidence`).
616
+ */
617
+ world(snapshot: Record<string, unknown> | null): WorldChecks<this>;
568
618
  /**
569
619
  * Assert the output message contains the given string.
570
620
  *
@@ -955,6 +1005,264 @@ declare class ExpectChain {
955
1005
  */
956
1006
  declare function attestExpect(result: AgentResult | Trace): ExpectChain;
957
1007
 
1008
+ /**
1009
+ * Capture: turn a run into a verified fixture, and fixtures into tests.
1010
+ *
1011
+ * `attest capture --name <name> -- <command>` (the engine) records a run's trace and model
1012
+ * exchanges into `tests/attest/fixtures/<name>.attest.json`. This module is the TypeScript
1013
+ * side:
1014
+ *
1015
+ * - `record()` captures the code in a callback in this process.
1016
+ * - `loadFixture()` reads a fixture (`proto/attest/v1/fixture-v1.schema.json`).
1017
+ * - `emitVitest()` writes the fixture's drafted contracts as a Vitest file, using the
1018
+ * `attestExpect()` DSL. `attest capture` and `record()` call it.
1019
+ */
1020
+
1021
+ /** A capture did not produce a fixture, or produced one that is not verified. */
1022
+ declare class CaptureError extends Error {
1023
+ /** The fixture written, when the engine wrote one. */
1024
+ readonly fixture: string | null;
1025
+ constructor(message: string, fixture?: string | null);
1026
+ }
1027
+ /** A drafted contract: an engine assertion spec plus its id and description. */
1028
+ interface Contract {
1029
+ id: string;
1030
+ kind: string;
1031
+ description: string;
1032
+ type: string;
1033
+ spec: Record<string, unknown>;
1034
+ }
1035
+ /** A contract's status on the captured trace. */
1036
+ interface ContractResult {
1037
+ contract: string;
1038
+ status: string;
1039
+ explanation: string;
1040
+ }
1041
+ /** A capture fixture (fixture-v1). */
1042
+ interface Fixture {
1043
+ name: string;
1044
+ source: {
1045
+ kind: string;
1046
+ replay_capable: boolean;
1047
+ command?: string[];
1048
+ exit_code?: number;
1049
+ };
1050
+ trace: Trace;
1051
+ exchanges: Record<string, unknown>[];
1052
+ contracts: Contract[];
1053
+ verification: {
1054
+ verified: boolean;
1055
+ expect_fail: boolean;
1056
+ trace_check: {
1057
+ ok: boolean;
1058
+ errors: number;
1059
+ warnings: number;
1060
+ };
1061
+ results: ContractResult[];
1062
+ expected_failures: string[];
1063
+ };
1064
+ world: Record<string, unknown> | null;
1065
+ }
1066
+ /** Read a capture fixture written by `attest capture` or `record()`. */
1067
+ declare function loadFixture(file: string | URL): Fixture;
1068
+ /** The `ExpectChain` method call that emits `contract`'s spec; throws when there is none. */
1069
+ declare function dslCall(contract: Contract): string;
1070
+ /**
1071
+ * Where the drafted test for a fixture goes: `tests/attest/<name>.test.ts` for
1072
+ * `tests/attest/fixtures/<name>.attest.json`.
1073
+ */
1074
+ declare function testPathFor(fixturePath: string): string;
1075
+ /**
1076
+ * Render a fixture's drafted contracts as a Vitest module.
1077
+ *
1078
+ * A verified fixture becomes a test that enforces every contract with `evaluate`. An
1079
+ * incident reproduction (`expect_fail`) becomes a test that checks, with `inspect`, that
1080
+ * the expected failures still fail and the other contracts still pass; it stays green
1081
+ * while it reproduces the incident.
1082
+ */
1083
+ declare function renderVitest(fixture: Fixture, fixturePath: string, testPath: string): string;
1084
+ /**
1085
+ * Write the drafted Vitest file for a fixture unless it already exists. Returns the path
1086
+ * written, or null when a test file is already there (re-capturing never overwrites an
1087
+ * edited test).
1088
+ */
1089
+ declare function emitVitest(fixturePath: string): string | null;
1090
+ /** A running in-process capture. */
1091
+ interface Capture {
1092
+ name: string;
1093
+ /** The variables `record()` set in `process.env` for the callback. */
1094
+ env: Record<string, string>;
1095
+ }
1096
+ interface RecordOptions {
1097
+ /** Fixture directory (default `tests/attest/fixtures`). */
1098
+ outDir?: string;
1099
+ /** Save an incident reproduction: verified when drafted contracts fail. */
1100
+ expectFail?: boolean;
1101
+ /** Trace `agent_id` (default: the first turn's agent name). */
1102
+ agentId?: string;
1103
+ /** Write the drafted Vitest file (default true). */
1104
+ emitTest?: boolean;
1105
+ /** Engine binary (default: the SDK's engine discovery). */
1106
+ enginePath?: string;
1107
+ /**
1108
+ * A `world.yaml` to host for the callback (the engine's `--world`): its base URL variable
1109
+ * (`PAYMENTS_BASE_URL`) is set for the callback and the world's final state is saved in
1110
+ * the fixture's `world` section.
1111
+ */
1112
+ world?: string;
1113
+ /**
1114
+ * Called after the callback returns and before the fixture is built; pass the tracer
1115
+ * provider's `forceFlush` so batched spans reach the receiver.
1116
+ */
1117
+ flush?: () => unknown;
1118
+ }
1119
+ interface RecordResult<T> {
1120
+ value: T;
1121
+ fixture: string;
1122
+ verified: boolean;
1123
+ testFile: string | null;
1124
+ }
1125
+ /**
1126
+ * Capture `fn` as fixture `<outDir>/<name>.attest.json`.
1127
+ *
1128
+ * Starts `attest-engine capture --serve`, which hosts the recording proxy and the
1129
+ * OTLP/HTTP receiver on 127.0.0.1, and sets `OPENAI_BASE_URL`, `ANTHROPIC_BASE_URL` and
1130
+ * `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` while `fn` runs. Model clients and the
1131
+ * OpenTelemetry exporter read these when they are constructed, so construct them inside
1132
+ * `fn`, and pass the tracer provider's `forceFlush` as `flush`. Afterwards the variables
1133
+ * are restored and the engine writes the fixture; for a verified fixture with `emitTest`
1134
+ * the drafted Vitest file is written unless one exists. If `fn` throws, the capture is
1135
+ * abandoned and no fixture is written. Captures cannot overlap.
1136
+ *
1137
+ * @throws CaptureError when another capture is running, the engine writes no fixture,
1138
+ * or the fixture is not verified (its drafted contracts did not hold; the fixture is
1139
+ * still written and no test is drafted).
1140
+ */
1141
+ declare function record<T>(name: string, fn: (capture: Capture) => T | Promise<T>, opts?: RecordOptions): Promise<RecordResult<T>>;
1142
+
1143
+ /**
1144
+ * Replay: run the agent's real code with model responses served from a fixture.
1145
+ *
1146
+ * `startReplay(name)` starts `attest-engine replay --serve`, which hosts the replay
1147
+ * proxy on 127.0.0.1, and sets `OPENAI_BASE_URL`, `ANTHROPIC_BASE_URL` and
1148
+ * `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` until `finish()`. The proxy answers every model
1149
+ * request from `<fixturesDir>/<name>.attest.json` and makes no provider call. A request
1150
+ * that matches no recording is a miss; `finish()` returns the engine's summary.
1151
+ */
1152
+ type ReplayMode = "strict" | "auto";
1153
+ type ReplayModeSetting = ReplayMode | "off";
1154
+ /** One request the agent made during the replay. */
1155
+ interface ReplayRecord {
1156
+ seq: number;
1157
+ provider: string;
1158
+ api: string;
1159
+ outcome: "replayed" | "live" | "miss";
1160
+ exchange?: number;
1161
+ message?: string;
1162
+ }
1163
+ /** What the replay session served, as the engine reports it. */
1164
+ interface ReplaySummary {
1165
+ fixture: string;
1166
+ mode: ReplayMode;
1167
+ replayed: number;
1168
+ live: number;
1169
+ misses: number;
1170
+ unused: number;
1171
+ live_cost_usd: number;
1172
+ unpriced_live_calls: number;
1173
+ records: ReplayRecord[];
1174
+ }
1175
+ /** A strict-mode replay request matched no recording. `message` is the engine's miss message. */
1176
+ declare class ReplayMissError extends Error {
1177
+ readonly summary: ReplaySummary;
1178
+ constructor(message: string, summary: ReplaySummary);
1179
+ }
1180
+ /** An auto-mode replay request matched no recording and no provider key was set: `not_evaluated: replay_miss`. */
1181
+ declare class ReplayNotEvaluatedError extends Error {
1182
+ readonly summary: ReplaySummary;
1183
+ constructor(message: string, summary: ReplaySummary);
1184
+ }
1185
+ declare class ReplayError extends Error {
1186
+ constructor(message: string);
1187
+ }
1188
+ interface ReplayOptions {
1189
+ /** Fixture directory (default `tests/attest/fixtures`). */
1190
+ fixturesDir?: string;
1191
+ /** `strict`, `auto` or `off`; default per `resolveMode`. `off` starts nothing. */
1192
+ mode?: ReplayModeSetting;
1193
+ /**
1194
+ * Pass `--no-live` to the engine: no miss is forwarded live. Default: `ATTEST_EGRESS=block`.
1195
+ * An installed egress guard always implies it.
1196
+ */
1197
+ noLive?: boolean;
1198
+ /** Engine binary (default: the SDK's engine discovery). */
1199
+ enginePath?: string;
1200
+ }
1201
+ interface ReplaySession {
1202
+ readonly name: string;
1203
+ readonly mode: ReplayModeSetting;
1204
+ /** The variables the session set in `process.env`. */
1205
+ readonly env: Record<string, string>;
1206
+ /** The summary once `finish()` has run, else `null`. */
1207
+ readonly summary: ReplaySummary | null;
1208
+ /** Stop the engine, restore the environment and return the summary (`null` for `off`). Idempotent. */
1209
+ finish(): Promise<ReplaySummary | null>;
1210
+ /** The error a miss raises (valid after `finish()`): strict => miss, auto => not evaluated. */
1211
+ error(): ReplayMissError | ReplayNotEvaluatedError | null;
1212
+ /** `finish()`, then throw `error()` if any. */
1213
+ check(): Promise<void>;
1214
+ }
1215
+ /**
1216
+ * Replay mode from `explicit`, else `ATTEST_REPLAY` (`strict|auto|off`), else `strict`
1217
+ * when `CI` is set, else `auto`.
1218
+ */
1219
+ declare function resolveMode(explicit?: ReplayModeSetting, env?: NodeJS.ProcessEnv): ReplayModeSetting;
1220
+ /** Start a replay session for fixture `name`. Sessions cannot overlap. */
1221
+ declare function startReplay(name: string, opts?: ReplayOptions): Promise<ReplaySession>;
1222
+ /** The first miss message of a summary, or `null`. */
1223
+ declare function firstMiss(summary: ReplaySummary): string | null;
1224
+ /** `N live model calls · $X.XX`, plus ` (+N unpriced)`. */
1225
+ declare function liveLine(live: number, costUsd: number, unpriced?: number): string;
1226
+
1227
+ /** A world-v1 snapshot. */
1228
+ type WorldSnapshot = Record<string, unknown>;
1229
+ declare class WorldError extends Error {
1230
+ constructor(message: string);
1231
+ }
1232
+ interface WorldOptions {
1233
+ /** Engine binary (default: the SDK's engine discovery). */
1234
+ enginePath?: string;
1235
+ }
1236
+ interface WorldSession {
1237
+ /** The absolute `world.yaml` path. */
1238
+ readonly path: string;
1239
+ /** The variable the session set in `process.env`: the world's base URL. */
1240
+ readonly env: Record<string, string>;
1241
+ /** The world's base URL. */
1242
+ readonly baseUrl: string;
1243
+ /** The current world-v1 snapshot, read from the running world. */
1244
+ state(): Promise<WorldSnapshot>;
1245
+ /** Stop the world, restore the environment and return the final snapshot. Idempotent. */
1246
+ stop(): Promise<WorldSnapshot>;
1247
+ }
1248
+ /** Host the world defined by `worldFile` until the session stops. Worlds cannot overlap. */
1249
+ declare function startWorld(worldFile: string, opts?: WorldOptions): Promise<WorldSession>;
1250
+
1251
+ declare class EgressBlockedError extends Error {
1252
+ readonly host: string;
1253
+ constructor(host: string);
1254
+ }
1255
+ declare function isProviderHost(host: string): boolean;
1256
+ /** True when `ATTEST_EGRESS=block`. */
1257
+ declare function egressBlockRequested(env?: NodeJS.ProcessEnv): boolean;
1258
+ /**
1259
+ * Install the guard. Installs are counted: the returned function releases only this
1260
+ * install (once), and the guard comes off when every install has been released.
1261
+ */
1262
+ declare function installEgressGuard(): () => void;
1263
+ /** Remove the guard now, whatever the install count. */
1264
+ declare function uninstallEgressGuard(): void;
1265
+
958
1266
  declare class Agent {
959
1267
  readonly name: string;
960
1268
  private readonly fn;
@@ -1286,7 +1594,7 @@ declare class OTelAdapter {
1286
1594
  * @throws RangeError when a parsed export holds a non-finite number.
1287
1595
  * @throws OTLPConversionError when the engine times out, overflows the output buffer or
1288
1596
  * prints no trace.
1289
- * @throws Error from `spawnSync` when the engine cannot start.
1597
+ * @throws Error when the engine cannot start.
1290
1598
  */
1291
1599
  static fromOtlp(otlp: OTLPInput, agentId?: string): Promise<Trace>;
1292
1600
  }
@@ -1355,4 +1663,5 @@ interface TraceAdapter {
1355
1663
  traceFromResponse(response: unknown, options?: Record<string, unknown>): Trace;
1356
1664
  }
1357
1665
 
1358
- export { ADVERSARIAL_USER, Agent, AgentResult, type AgreementResult, AlertDispatcher, type AlertPayload, AnthropicAdapter, Assertion, AssertionResult, AttestClient, type AttestClientOptions, type AttestPlugin, BatchBudget, CONFUSED_USER, COOPERATIVE_USER, ContinuousEvalRunner, ConversationMessage, DriftReport, ENGINE_VERSION, EngineManager, EvaluateBatchResult, ExpectChain, FRIENDLY_USER, GeminiAdapter, InitializeResult, type LabelPair, type LabeledRecord, LangChainAdapter, ManualAdapter, OTelAdapter, OllamaAdapter, OpenAIAdapter, Outcome, PluginRegistry, type PluginResult, ProtocolDiagnostic, ProtocolLogger, type RenderOptions, Sampler, SimulateFaultConfig, SimulatePersona, Step, TIER_1, TIER_2, TIER_3, Trace, type TraceAdapter, TraceBuilder, TraceTree, Usage, VERSION, activeBuilder, addUsage, agent, attestExpect, computeAgreement, config, delegate, executePluginAssertion, formatUsage, getSampleRate, isSimulationMode, loadLabelsCSV, loadLabelsJSONL, parseUsage, promptHash, renderAssertionFailure, renderDiagnostics, renderSummary, requireSimulationCapability, resetConfig, simulationEnvEnabled, sumUsage, tier, usageSummaryLine, zeroUsage };
1666
+ export { ADVERSARIAL_USER, Agent, AgentResult, AlertDispatcher, AnthropicAdapter, Assertion, AssertionResult, AttestClient, BatchBudget, BatchContext, CONFUSED_USER, COOPERATIVE_USER, CaptureError, ContinuousEvalRunner, ConversationMessage, DriftReport, ENGINE_VERSION, EgressBlockedError, EngineManager, EvaluateBatchResult, ExpectChain, FRIENDLY_USER, GeminiAdapter, InitializeResult, LangChainAdapter, ManualAdapter, OTelAdapter, OllamaAdapter, OpenAIAdapter, Outcome, PluginRegistry, ProtocolDiagnostic, ProtocolLogger, ReplayError, ReplayMissError, ReplayNotEvaluatedError, Sampler, SimulateFaultConfig, SimulatePersona, Step, TIER_1, TIER_2, TIER_3, Trace, TraceBuilder, TraceTree, Usage, VERSION, WorldChecks, WorldError, activeBuilder, addUsage, agent, attestExpect, computeAgreement, config, delegate, dslCall, egressBlockRequested, emitVitest, executePluginAssertion, firstMiss, formatUsage, getSampleRate, installEgressGuard, isProviderHost, isSimulationMode, liveLine, loadFixture, loadLabelsCSV, loadLabelsJSONL, parseUsage, promptHash, record, renderAssertionFailure, renderDiagnostics, renderSummary, renderVitest, requireSimulationCapability, resetConfig, resolveMode, simulationEnvEnabled, startReplay, startWorld, sumUsage, testPathFor, tier, uninstallEgressGuard, usageSummaryLine, zeroUsage };
1667
+ export type { AgreementResult, AlertPayload, AttestClientOptions, AttestPlugin, Capture, Contract, ContractResult, Fixture, LabelPair, LabeledRecord, PluginResult, RecordOptions, RecordResult, RenderOptions, ReplayMode, ReplayModeSetting, ReplayOptions, ReplayRecord, ReplaySession, ReplaySummary, TraceAdapter, WorldOptions, WorldSession, WorldSnapshot };
@@ -40,6 +40,7 @@ __export(proto_exports, {
40
40
  REASON_MISSING_EVIDENCE: () => REASON_MISSING_EVIDENCE,
41
41
  REASON_PROVIDER_NOT_CONFIGURED: () => REASON_PROVIDER_NOT_CONFIGURED,
42
42
  REASON_PROVIDER_UNAVAILABLE: () => REASON_PROVIDER_UNAVAILABLE,
43
+ REASON_REPLAY_MISS: () => REASON_REPLAY_MISS,
43
44
  REASON_SHORT_CIRCUITED: () => REASON_SHORT_CIRCUITED,
44
45
  REASON_SIMULATION: () => REASON_SIMULATION,
45
46
  STATUS_HARD_FAIL: () => STATUS_HARD_FAIL,
@@ -52,6 +53,7 @@ __export(proto_exports, {
52
53
  STEP_TOOL_CALL: () => STEP_TOOL_CALL,
53
54
  TYPE_CONSTRAINT: () => TYPE_CONSTRAINT,
54
55
  TYPE_CONTENT: () => TYPE_CONTENT,
56
+ TYPE_EFFECT: () => TYPE_EFFECT,
55
57
  TYPE_EMBEDDING: () => TYPE_EMBEDDING,
56
58
  TYPE_LLM_JUDGE: () => TYPE_LLM_JUDGE,
57
59
  TYPE_PLUGIN: () => TYPE_PLUGIN,
@@ -86,12 +88,14 @@ var REASON_MISSING_EVIDENCE = "missing_evidence";
86
88
  var REASON_SHORT_CIRCUITED = "short_circuited";
87
89
  var REASON_BUDGET_EXHAUSTED = "budget_exhausted";
88
90
  var REASON_JUDGE_ABSTAINED = "judge_abstained";
91
+ var REASON_REPLAY_MISS = "replay_miss";
89
92
  var OUTCOME_PASS = "pass";
90
93
  var OUTCOME_FAIL = "fail";
91
94
  var OUTCOME_SKIP = "skip";
92
95
  var TYPE_SCHEMA = "schema";
93
96
  var TYPE_CONSTRAINT = "constraint";
94
97
  var TYPE_TRACE = "trace";
98
+ var TYPE_EFFECT = "effect";
95
99
  var TYPE_CONTENT = "content";
96
100
  var TYPE_EMBEDDING = "embedding";
97
101
  var TYPE_LLM_JUDGE = "llm_judge";
@@ -129,6 +133,7 @@ function layerForType(assertionType) {
129
133
  return 2;
130
134
  case "trace":
131
135
  case "trace_tree":
136
+ case "effect":
132
137
  return 3;
133
138
  case "content":
134
139
  return 4;
@@ -308,6 +313,7 @@ function extractId(response) {
308
313
  REASON_MISSING_EVIDENCE,
309
314
  REASON_PROVIDER_NOT_CONFIGURED,
310
315
  REASON_PROVIDER_UNAVAILABLE,
316
+ REASON_REPLAY_MISS,
311
317
  REASON_SHORT_CIRCUITED,
312
318
  REASON_SIMULATION,
313
319
  STATUS_HARD_FAIL,
@@ -320,6 +326,7 @@ function extractId(response) {
320
326
  STEP_TOOL_CALL,
321
327
  TYPE_CONSTRAINT,
322
328
  TYPE_CONTENT,
329
+ TYPE_EFFECT,
323
330
  TYPE_EMBEDDING,
324
331
  TYPE_LLM_JUDGE,
325
332
  TYPE_PLUGIN,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/proto/index.ts","../../../src/proto/constants.ts","../../../src/proto/types.ts","../../../src/proto/errors.ts","../../../src/proto/diagnostics.ts","../../../src/proto/codec.ts"],"sourcesContent":["export * from \"./constants.js\";\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport {\n ProtocolDiagnosticBuffer,\n previewLine,\n} from \"./diagnostics.js\";\nexport type {\n ProtocolDiagnostic,\n ProtocolDiagnosticKind,\n ProtocolLogger,\n} from \"./diagnostics.js\";\nexport { encodeRequest, decodeResponse, extractResult, extractId } from \"./codec.js\";\n","// Step type constants\nexport const STEP_LLM_CALL = \"llm_call\" as const;\nexport const STEP_TOOL_CALL = \"tool_call\" as const;\nexport const STEP_RETRIEVAL = \"retrieval\" as const;\nexport const STEP_AGENT_CALL = \"agent_call\" as const;\n\n// Status constants\nexport const STATUS_PASS = \"pass\" as const;\nexport const STATUS_SOFT_FAIL = \"soft_fail\" as const;\nexport const STATUS_HARD_FAIL = \"hard_fail\" as const;\nexport const STATUS_NOT_EVALUATED = \"not_evaluated\" as const;\n\n// Reasons carried by a not_evaluated result (AssertionResult.reason)\nexport const REASON_PROVIDER_UNAVAILABLE = \"provider_unavailable\" as const;\nexport const REASON_PROVIDER_NOT_CONFIGURED = \"provider_not_configured\" as const;\nexport const REASON_SIMULATION = \"simulation\" as const;\nexport const REASON_MISSING_EVIDENCE = \"missing_evidence\" as const;\nexport const REASON_SHORT_CIRCUITED = \"short_circuited\" as const;\nexport const REASON_BUDGET_EXHAUSTED = \"budget_exhausted\" as const;\nexport const REASON_JUDGE_ABSTAINED = \"judge_abstained\" as const;\n\n// Test outcomes derived from a batch of assertion results (AgentResult.outcome)\nexport const OUTCOME_PASS = \"pass\" as const;\nexport const OUTCOME_FAIL = \"fail\" as const;\nexport const OUTCOME_SKIP = \"skip\" as const;\nexport type Outcome = typeof OUTCOME_PASS | typeof OUTCOME_FAIL | typeof OUTCOME_SKIP;\n\n// Assertion type constants\nexport const TYPE_SCHEMA = \"schema\" as const;\nexport const TYPE_CONSTRAINT = \"constraint\" as const;\nexport const TYPE_TRACE = \"trace\" as const;\nexport const TYPE_CONTENT = \"content\" as const;\nexport const TYPE_EMBEDDING = \"embedding\" as const;\nexport const TYPE_LLM_JUDGE = \"llm_judge\" as const;\nexport const TYPE_TRACE_TREE = \"trace_tree\" as const;\nexport const TYPE_PLUGIN = \"plugin\" as const;\n\n// Error code constants\nexport const ERR_INVALID_TRACE = 1001 as const;\nexport const ERR_ASSERTION_ERROR = 1002 as const;\nexport const ERR_PROVIDER_ERROR = 2001 as const;\nexport const ERR_ENGINE_ERROR = 3001 as const;\nexport const ERR_TIMEOUT = 3002 as const;\nexport const ERR_SESSION_ERROR = 3003 as const;\n","// ---------------------------------------------------------------------------\n// Branded ID types (T6)\n// ---------------------------------------------------------------------------\n\ndeclare const __brand: unique symbol;\ntype Brand<T, B extends string> = T & { readonly [__brand]: B };\n\nexport type TraceId = Brand<string, \"TraceId\">;\nexport type AssertionId = Brand<string, \"AssertionId\">;\nexport type AgentId = Brand<string, \"AgentId\">;\n\nexport function traceId(id: string): TraceId {\n return id as TraceId;\n}\n\nexport function assertionId(id: string): AssertionId {\n return id as AssertionId;\n}\n\nexport function agentId(id: string): AgentId {\n return id as AgentId;\n}\n\n// ---------------------------------------------------------------------------\n// Assertion spec discriminated unions (T5)\n// ---------------------------------------------------------------------------\n\nexport interface SchemaSpec {\n readonly type: \"schema\";\n readonly target: string;\n readonly schema: Record<string, unknown>;\n}\n\nexport interface ConstraintSpec {\n readonly type: \"constraint\";\n readonly field: string;\n readonly operator: string;\n readonly value?: number;\n readonly min?: number;\n readonly max?: number;\n readonly soft: boolean;\n}\n\nexport interface TraceSpec {\n readonly type: \"trace\";\n readonly check: string;\n readonly tools?: string[];\n readonly tool?: string;\n readonly max_repetitions?: number;\n readonly soft: boolean;\n}\n\nexport interface ContentSpec {\n readonly type: \"content\";\n readonly target: string;\n readonly check: string;\n readonly value?: string;\n readonly values?: string[];\n readonly case_sensitive?: boolean;\n readonly soft?: boolean;\n}\n\nexport interface EmbeddingSpec {\n readonly type: \"embedding\";\n readonly target: string;\n readonly reference: string;\n readonly threshold: number | \"dynamic\";\n readonly model?: string;\n readonly soft: boolean;\n}\n\nexport interface LlmJudgeSpec {\n readonly type: \"llm_judge\";\n readonly target: string;\n readonly criteria: string;\n readonly rubric: string;\n readonly threshold: number | \"dynamic\";\n readonly model?: string;\n readonly soft: boolean;\n}\n\nexport interface TraceTreeSpec {\n readonly type: \"trace_tree\";\n readonly check: string;\n readonly [key: string]: unknown;\n}\n\nexport interface PluginSpec {\n readonly type: \"plugin\";\n readonly plugin_id: string;\n readonly config?: Record<string, unknown>;\n readonly soft: boolean;\n}\n\nexport type AssertionSpec =\n | SchemaSpec\n | ConstraintSpec\n | TraceSpec\n | ContentSpec\n | EmbeddingSpec\n | LlmJudgeSpec\n | TraceTreeSpec\n | PluginSpec;\n\n// ---------------------------------------------------------------------------\n// Core protocol types\n// ---------------------------------------------------------------------------\n\nexport interface TraceMetadata {\n readonly total_tokens?: number;\n readonly cost_usd?: number;\n readonly latency_ms?: number;\n readonly model?: string;\n readonly timestamp?: string;\n}\n\n/** Trace v2: a step whose span ended in error. */\nexport interface StepError {\n readonly type: string;\n readonly message?: string;\n}\n\n/** Trace v2: a recorded model request/response pair. */\nexport interface Exchange {\n readonly request: Record<string, unknown>;\n readonly response: Record<string, unknown>;\n}\n\n/** Trace v2: one conversation turn and the indices of its steps. */\nexport interface Turn {\n readonly index: number;\n readonly span_id?: string;\n readonly input?: unknown;\n readonly output?: unknown;\n readonly step_indices: readonly number[];\n}\n\n/** Trace v2: control passing from one agent to another at an agent_call step. */\nexport interface Handoff {\n readonly from_agent: string;\n readonly to_agent: string;\n readonly step_index: number;\n}\n\nexport interface Step {\n readonly type: string;\n readonly name: string;\n readonly args?: Record<string, unknown>;\n readonly result?: Record<string, unknown>;\n readonly sub_trace?: Trace;\n readonly metadata?: Record<string, unknown>;\n readonly started_at_ms?: number;\n readonly ended_at_ms?: number;\n readonly agent_id?: string;\n readonly agent_role?: string;\n // Trace v2 (schema_version 2) fields.\n readonly span_id?: string;\n readonly parent_span_id?: string;\n readonly tool_call_id?: string;\n readonly retry_of?: number;\n readonly error?: StepError;\n readonly exchange?: Exchange;\n}\n\nexport interface Trace {\n readonly trace_id: string;\n readonly output: Record<string, unknown>;\n readonly schema_version?: number;\n readonly agent_id?: string;\n readonly input?: Record<string, unknown>;\n readonly steps: readonly Step[];\n readonly metadata?: TraceMetadata;\n readonly parent_trace_id?: string;\n // Trace v2 (schema_version 2) fields.\n readonly conversation_id?: string;\n readonly turns?: readonly Turn[];\n readonly handoffs?: readonly Handoff[];\n}\n\nexport interface Assertion {\n readonly assertion_id: string;\n readonly type: string;\n readonly spec: Record<string, unknown>;\n readonly request_id?: string;\n}\n\n/**\n * Audit trail for an LLM-judge evaluation. Mirrors\n * engine/pkg/types/assertion.go::JudgeMetadata so report v2 payloads\n * round-trip without losing the model / rubric / variance evidence\n * reviewers need to triage a judge failure.\n */\nexport interface JudgeMetadata {\n readonly provider?: string;\n readonly model?: string;\n readonly rubric_name?: string;\n readonly rubric_version?: string;\n readonly prompt_hash?: string;\n readonly sample_scores?: readonly number[];\n readonly score_mean?: number;\n readonly score_stddev?: number;\n readonly high_variance?: boolean;\n readonly bias_probes?: readonly BiasProbe[];\n readonly calibration?: JudgeAgreement;\n}\n\n/**\n * One judge-bias probe result. Score is the score the judge produced on\n * the mutated input; delta is `score - baseline`. A well-calibrated\n * judge has |delta| close to zero. Mirrors\n * engine/pkg/types/assertion.go::BiasProbe.\n */\nexport interface BiasProbe {\n readonly name: string;\n readonly score: number;\n readonly delta: number;\n}\n\n/**\n * Calibration agreement summary keyed by\n * (rubric_name, rubric_version, prompt_hash). Mirrors\n * engine/pkg/types/assertion.go::JudgeAgreement.\n */\nexport interface JudgeAgreement {\n readonly label_count: number;\n readonly agreement: number;\n readonly cohen_kappa: number;\n readonly roc_auc?: number;\n}\n\nexport interface AssertionResult {\n readonly assertion_id: string;\n readonly status: string;\n readonly score: number;\n readonly explanation: string;\n readonly cost?: number;\n readonly duration_ms?: number;\n readonly request_id?: string;\n /** Set only when status is \"not_evaluated\" (REASON_* constants). */\n readonly reason?: string;\n readonly threshold_source?: string;\n readonly layer?: number;\n readonly type?: string;\n readonly trace_node_path?: string;\n readonly expected?: string;\n readonly actual?: string;\n readonly suggested_action?: string;\n readonly judge_metadata?: JudgeMetadata;\n /**\n * Heuristic root-cause label set by the engine\n * (broken_code / flaky_judge / bad_rubric / missing_trace_data /\n * stochastic_variance). Empty/undefined for passes and any result the\n * engine declined to label. Mirrors\n * engine/pkg/types/failure_class.go.\n */\n readonly failure_class?: string;\n}\n\n/**\n * FailureClass values mirror engine/pkg/types/failure_class.go. Use\n * these constants when matching on AssertionResult.failure_class so a\n * typo in either codebase fails fast.\n */\nexport const FailureClass = {\n BrokenCode: \"broken_code\",\n FlakyJudge: \"flaky_judge\",\n BadRubric: \"bad_rubric\",\n MissingTraceData: \"missing_trace_data\",\n StochasticVariance: \"stochastic_variance\",\n} as const;\nexport type FailureClass = (typeof FailureClass)[keyof typeof FailureClass];\n\n/**\n * Map an assertion-type string to its pipeline layer (1–8). Returns 0\n * when the type is unknown so callers can route uncategorised results\n * into their own bucket.\n */\nexport function layerForType(assertionType: string | undefined): number {\n switch (assertionType) {\n case \"schema\":\n return 1;\n case \"constraint\":\n return 2;\n case \"trace\":\n case \"trace_tree\":\n return 3;\n case \"content\":\n return 4;\n case \"embedding\":\n return 5;\n case \"llm_judge\":\n return 6;\n case \"plugin\":\n return 8;\n default:\n return 0;\n }\n}\n\nexport interface ErrorData {\n readonly error_type: string;\n readonly retryable: boolean;\n readonly detail: string;\n}\n\nexport interface RPCError {\n readonly code: number;\n readonly message: string;\n readonly data?: ErrorData;\n}\n\nexport interface RPCRequest {\n readonly jsonrpc: \"2.0\";\n readonly id: number;\n readonly method: string;\n readonly params: Record<string, unknown>;\n}\n\nexport interface RPCResponse {\n readonly jsonrpc: \"2.0\";\n readonly id: number;\n readonly result?: unknown;\n readonly error?: RPCError;\n}\n\nexport interface InitializeParams {\n readonly sdk_name: string;\n readonly sdk_version: string;\n readonly protocol_version: number;\n readonly required_capabilities: readonly string[];\n readonly preferred_encoding?: string;\n}\n\nexport interface InitializeResult {\n readonly engine_version: string;\n readonly protocol_version: number;\n readonly capabilities: readonly string[];\n readonly missing: readonly string[];\n readonly compatible: boolean;\n readonly encoding?: string;\n readonly max_concurrent_requests?: number;\n readonly max_trace_size_bytes?: number;\n readonly max_steps_per_trace?: number;\n}\n\n/**\n * Limits for one evaluate_batch call on top of the session budget. A judge or\n * embedding call that cannot reserve against them is not sent and its\n * assertion is not_evaluated with reason \"budget_exhausted\".\n */\nexport interface BatchBudget {\n readonly max_judge_calls?: number;\n readonly max_cost_usd?: number;\n}\n\nexport interface EvaluateBatchParams {\n readonly trace: Trace;\n readonly assertions: readonly Assertion[];\n /** Omitted when no per-batch budget applies. */\n readonly budget?: BatchBudget;\n}\n\n/**\n * Attest-initiated model usage (embeddings, judges, judge repeats, bias\n * probes, simulated-user messages). Agent calls not routed through attest\n * are not counted.\n */\nexport interface Usage {\n readonly model_calls: number;\n /** Judge-provider requests, the part of model_calls that max_judge_calls limits. */\n readonly judge_calls: number;\n readonly input_tokens: number;\n readonly output_tokens: number;\n readonly cached_tokens: number;\n readonly cost_usd: number;\n readonly retry_cost_usd: number;\n readonly unpriced_calls: number;\n readonly budget_refused: number;\n}\n\nexport interface EvaluateBatchResult {\n readonly results: readonly AssertionResult[];\n readonly total_cost?: number;\n readonly total_duration_ms?: number;\n /** Always sent by the engine; validated by AttestClient.evaluateBatch. */\n readonly usage: Usage;\n /**\n * True when this result was produced by an SDK simulation shim rather\n * than a real engine evaluation. Engine-produced results always carry\n * simulated=false. CI gates can fail builds that accidentally evaluate\n * against the simulator by checking this flag.\n */\n readonly simulated?: boolean;\n}\n\nexport interface ShutdownResult {\n readonly sessions_completed: number;\n readonly assertions_evaluated: number;\n}\n\nexport interface SubmitPluginResultParams {\n readonly trace_id: string;\n readonly plugin_name: string;\n readonly assertion_id: string;\n readonly result: AssertionResult;\n}\n\n// ---------------------------------------------------------------------------\n// Drift detection types\n// ---------------------------------------------------------------------------\n\nexport interface DriftReport {\n readonly assertion_id: string;\n readonly mean: number;\n readonly stddev: number;\n readonly count: number;\n readonly latest_score: number;\n readonly deviation: number;\n readonly status: string;\n}\n\nexport interface QueryDriftParams {\n readonly assertion_id: string;\n readonly window_size: number;\n}\n\nexport interface QueryDriftResult {\n readonly report: DriftReport;\n}\n\n// ---------------------------------------------------------------------------\n// Simulation types\n// ---------------------------------------------------------------------------\n\nexport interface SimulatePersona {\n readonly name: string;\n readonly system_prompt: string;\n readonly style: string;\n readonly temperature: number;\n readonly max_tokens?: number;\n}\n\nexport interface SimulateFaultConfig {\n readonly error_rate: number;\n readonly latency_jitter_ms: number;\n readonly content_corruption: boolean;\n readonly timeout_after_ms: number;\n}\n\nexport interface ConversationMessage {\n readonly role: string;\n readonly content: string;\n}\n\nexport interface GenerateUserMessageParams {\n readonly persona: SimulatePersona;\n readonly conversation_history: readonly ConversationMessage[];\n readonly fault_config?: SimulateFaultConfig;\n}\n\nexport interface GenerateUserMessageResult {\n readonly message: string;\n}\n","import type { ErrorData } from \"./types.js\";\nimport type { ProtocolDiagnostic } from \"./diagnostics.js\";\n\nexport class ProtocolError extends Error {\n readonly code: number;\n readonly errorMessage: string;\n readonly data: ErrorData | undefined;\n\n constructor(code: number, message: string, data?: ErrorData) {\n super(message);\n this.name = \"ProtocolError\";\n this.code = code;\n this.errorMessage = message;\n this.data = data;\n }\n}\n\nexport class EngineTimeoutError extends Error {\n readonly method: string;\n readonly timeoutMs: number;\n\n constructor(method: string, timeoutMs: number) {\n super(\n `Engine request '${method}' timed out after ${timeoutMs}ms. ` +\n \"Set ATTEST_ENGINE_TIMEOUT to increase the limit.\",\n );\n this.name = \"EngineTimeoutError\";\n this.method = method;\n this.timeoutMs = timeoutMs;\n }\n}\n\n/**\n * Raised when the reader loop detects that engine output has lost\n * framing or contains repeated unparseable lines. All in-flight requests\n * are rejected with this error so callers see a visible failure rather\n * than a hung promise.\n */\nexport class ProtocolDesyncError extends Error {\n readonly diagnostics: readonly ProtocolDiagnostic[];\n\n constructor(message: string, diagnostics: readonly ProtocolDiagnostic[]) {\n super(message);\n this.name = \"ProtocolDesyncError\";\n this.diagnostics = diagnostics;\n }\n}\n\n/**\n * The engine rejected an OTLP/JSON export (`attest-engine trace convert`). The message is\n * the engine's error, which names the offending span or field.\n */\nexport class OTLPConversionError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"OTLPConversionError\";\n }\n}\n","/**\n * Protocol diagnostic types for client-side observability.\n *\n * The reader loop emits diagnostics whenever it cannot route a response\n * line: malformed JSON, missing id, unknown id, or non-routable protocol\n * errors. Diagnostics are buffered in a bounded ring (32 entries) and\n * trigger a desync error when the rate exceeds the configured threshold.\n */\n\nexport type ProtocolDiagnosticKind =\n | \"malformed_json\"\n | \"non_object_response\"\n | \"invalid_jsonrpc_version\"\n | \"missing_id\"\n | \"unknown_id\"\n | \"non_routable_error\";\n\nexport interface ProtocolDiagnostic {\n readonly kind: ProtocolDiagnosticKind;\n readonly message: string;\n readonly rawLine: string;\n readonly timestampMs: number;\n}\n\nexport interface ProtocolLogger {\n warn(message: string, ...args: unknown[]): void;\n error(message: string, ...args: unknown[]): void;\n}\n\nconst DEFAULT_BUFFER_SIZE = 32;\nconst MAX_LINE_PREVIEW = 512;\n\nexport class ProtocolDiagnosticBuffer {\n private readonly capacity: number;\n private readonly entries: ProtocolDiagnostic[] = [];\n\n constructor(capacity: number = DEFAULT_BUFFER_SIZE) {\n if (capacity <= 0) {\n throw new Error(\n `ProtocolDiagnosticBuffer capacity must be positive, got ${capacity}`,\n );\n }\n this.capacity = capacity;\n }\n\n push(diagnostic: ProtocolDiagnostic): void {\n if (this.entries.length >= this.capacity) {\n this.entries.shift();\n }\n this.entries.push(diagnostic);\n }\n\n snapshot(): readonly ProtocolDiagnostic[] {\n return this.entries.slice();\n }\n\n countWithin(windowMs: number, nowMs: number): number {\n const cutoff = nowMs - windowMs;\n let count = 0;\n for (let i = this.entries.length - 1; i >= 0; i -= 1) {\n if (this.entries[i]!.timestampMs >= cutoff) {\n count += 1;\n } else {\n break;\n }\n }\n return count;\n }\n\n clear(): void {\n this.entries.length = 0;\n }\n}\n\nexport function previewLine(line: string): string {\n if (line.length <= MAX_LINE_PREVIEW) return line;\n return line.slice(0, MAX_LINE_PREVIEW) + \"…\";\n}\n","import type { ErrorData, RPCResponse } from \"./types.js\";\nimport { ProtocolError } from \"./errors.js\";\n\n/**\n * Encode a JSON-RPC 2.0 request as an NDJSON line.\n */\nexport function encodeRequest(\n id: number,\n method: string,\n params: Record<string, unknown>,\n): string {\n const msg = {\n jsonrpc: \"2.0\" as const,\n id,\n method,\n params,\n };\n return JSON.stringify(msg) + \"\\n\";\n}\n\n/**\n * Decode a JSON-RPC 2.0 response from an NDJSON line.\n * Throws ProtocolError if the response contains an error.\n * Throws Error for malformed JSON or invalid responses.\n */\nexport function decodeResponse(line: string): RPCResponse {\n const text = line.trim();\n if (!text) {\n throw new Error(\"empty response line\");\n }\n\n let data: unknown;\n try {\n data = JSON.parse(text);\n } catch (e) {\n throw new Error(`malformed JSON response: ${e instanceof Error ? e.message : String(e)}`);\n }\n\n if (typeof data !== \"object\" || data === null || Array.isArray(data)) {\n throw new Error(`expected JSON object, got ${Array.isArray(data) ? \"array\" : typeof data}`);\n }\n\n const obj = data as Record<string, unknown>;\n\n if (obj.jsonrpc !== \"2.0\") {\n throw new Error(`invalid jsonrpc version: ${String(obj.jsonrpc)}`);\n }\n\n if (obj.error != null) {\n const err = obj.error as Record<string, unknown>;\n let errorData: ErrorData | undefined;\n\n if (err.data != null) {\n const raw = err.data as Record<string, unknown>;\n errorData = {\n error_type: (raw.error_type as string) ?? \"\",\n retryable: (raw.retryable as boolean) ?? false,\n detail: (raw.detail as string) ?? \"\",\n };\n }\n\n throw new ProtocolError(\n (err.code as number) ?? -1,\n (err.message as string) ?? \"unknown error\",\n errorData,\n );\n }\n\n return obj as unknown as RPCResponse;\n}\n\n/**\n * Extract the result field from a decoded response.\n */\nexport function extractResult(response: RPCResponse): unknown {\n if (response.result === undefined) {\n throw new Error(\"response missing 'result' field\");\n }\n return response.result;\n}\n\n/**\n * Extract the request ID from a decoded response.\n */\nexport function extractId(response: RPCResponse): number {\n if (response.id === undefined) {\n throw new Error(\"response missing 'id' field\");\n }\n return Number(response.id);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAM,gBAAgB;AACtB,IAAM,iBAAiB;AACvB,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AAGxB,IAAM,cAAc;AACpB,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AACzB,IAAM,uBAAuB;AAG7B,IAAM,8BAA8B;AACpC,IAAM,iCAAiC;AACvC,IAAM,oBAAoB;AAC1B,IAAM,0BAA0B;AAChC,IAAM,yBAAyB;AAC/B,IAAM,0BAA0B;AAChC,IAAM,yBAAyB;AAG/B,IAAM,eAAe;AACrB,IAAM,eAAe;AACrB,IAAM,eAAe;AAIrB,IAAM,cAAc;AACpB,IAAM,kBAAkB;AACxB,IAAM,aAAa;AACnB,IAAM,eAAe;AACrB,IAAM,iBAAiB;AACvB,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AACxB,IAAM,cAAc;AAGpB,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAC5B,IAAM,qBAAqB;AAC3B,IAAM,mBAAmB;AACzB,IAAM,c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AAEA,MAAI;AACJ,MAAI;AACF,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,SAAS,GAAG;AACV,UAAM,IAAI,MAAM,4BAA4B,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC,EAAE;AAAA,EAC1F;AAEA,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,QAAQ,IAAI,GAAG;AACpE,UAAM,IAAI,MAAM,6BAA6B,MAAM,QAAQ,IAAI,IAAI,UAAU,OAAO,IAAI,EAAE;AAAA,EAC5F;AAEA,QAAM,MAAM;AAEZ,MAAI,IAAI,YAAY,OAAO;AACzB,UAAM,IAAI,MAAM,4BAA4B,OAAO,IAAI,OAAO,CAAC,EAAE;AAAA,EACnE;AAEA,MAAI,IAAI,SAAS,MAAM;AACrB,UAAM,MAAM,IAAI;AAChB,QAAI;AAEJ,QAAI,IAAI,QAAQ,MAAM;AACpB,YAAM,MAAM,IAAI;AAChB,kBAAY;AAAA,QACV,YAAa,IAAI,cAAyB;AAAA,QAC1C,WAAY,IAAI,aAAyB;AAAA,QACzC,QAAS,IAAI,UAAqB;AAAA,MACpC;AAAA,IACF;AAEA,UAAM,IAAI;AAAA,MACP,IAAI,QAAmB;AAAA,MACvB,IAAI,WAAsB;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAKO,SAAS,cAAc,UAAgC;AAC5D,MAAI,SAAS,WAAW,QAAW;AACjC,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AACA,SAAO,SAAS;AAClB;AAKO,SAAS,UAAU,UAA+B;AACvD,MAAI,SAAS,OAAO,QAAW;AAC7B,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AACA,SAAO,OAAO,SAAS,EAAE;AAC3B;","names":[]}
1
+ {"version":3,"sources":["../../../src/proto/index.ts","../../../src/proto/constants.ts","../../../src/proto/types.ts","../../../src/proto/errors.ts","../../../src/proto/diagnostics.ts","../../../src/proto/codec.ts"],"sourcesContent":["export * from \"./constants.js\";\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport {\n ProtocolDiagnosticBuffer,\n previewLine,\n} from \"./diagnostics.js\";\nexport type {\n ProtocolDiagnostic,\n ProtocolDiagnosticKind,\n ProtocolLogger,\n} from \"./diagnostics.js\";\nexport { encodeRequest, decodeResponse, extractResult, extractId } from \"./codec.js\";\n","// Step type constants\nexport const STEP_LLM_CALL = \"llm_call\" as const;\nexport const STEP_TOOL_CALL = \"tool_call\" as const;\nexport const STEP_RETRIEVAL = \"retrieval\" as const;\nexport const STEP_AGENT_CALL = \"agent_call\" as const;\n\n// Status constants\nexport const STATUS_PASS = \"pass\" as const;\nexport const STATUS_SOFT_FAIL = \"soft_fail\" as const;\nexport const STATUS_HARD_FAIL = \"hard_fail\" as const;\nexport const STATUS_NOT_EVALUATED = \"not_evaluated\" as const;\n\n// Reasons carried by a not_evaluated result (AssertionResult.reason)\nexport const REASON_PROVIDER_UNAVAILABLE = \"provider_unavailable\" as const;\nexport const REASON_PROVIDER_NOT_CONFIGURED = \"provider_not_configured\" as const;\nexport const REASON_SIMULATION = \"simulation\" as const;\nexport const REASON_MISSING_EVIDENCE = \"missing_evidence\" as const;\nexport const REASON_SHORT_CIRCUITED = \"short_circuited\" as const;\nexport const REASON_BUDGET_EXHAUSTED = \"budget_exhausted\" as const;\nexport const REASON_JUDGE_ABSTAINED = \"judge_abstained\" as const;\nexport const REASON_REPLAY_MISS = \"replay_miss\" as const;\n\n// Test outcomes derived from a batch of assertion results (AgentResult.outcome)\nexport const OUTCOME_PASS = \"pass\" as const;\nexport const OUTCOME_FAIL = \"fail\" as const;\nexport const OUTCOME_SKIP = \"skip\" as const;\nexport type Outcome = typeof OUTCOME_PASS | typeof OUTCOME_FAIL | typeof OUTCOME_SKIP;\n\n// Assertion type constants\nexport const TYPE_SCHEMA = \"schema\" as const;\nexport const TYPE_CONSTRAINT = \"constraint\" as const;\nexport const TYPE_TRACE = \"trace\" as const;\nexport const TYPE_EFFECT = \"effect\" as const;\nexport const TYPE_CONTENT = \"content\" as const;\nexport const TYPE_EMBEDDING = \"embedding\" as const;\nexport const TYPE_LLM_JUDGE = \"llm_judge\" as const;\nexport const TYPE_TRACE_TREE = \"trace_tree\" as const;\nexport const TYPE_PLUGIN = \"plugin\" as const;\n\n// Error code constants\nexport const ERR_INVALID_TRACE = 1001 as const;\nexport const ERR_ASSERTION_ERROR = 1002 as const;\nexport const ERR_PROVIDER_ERROR = 2001 as const;\nexport const ERR_ENGINE_ERROR = 3001 as const;\nexport const ERR_TIMEOUT = 3002 as const;\nexport const ERR_SESSION_ERROR = 3003 as const;\n","// ---------------------------------------------------------------------------\n// Branded ID types (T6)\n// ---------------------------------------------------------------------------\n\ndeclare const __brand: unique symbol;\ntype Brand<T, B extends string> = T & { readonly [__brand]: B };\n\nexport type TraceId = Brand<string, \"TraceId\">;\nexport type AssertionId = Brand<string, \"AssertionId\">;\nexport type AgentId = Brand<string, \"AgentId\">;\n\nexport function traceId(id: string): TraceId {\n return id as TraceId;\n}\n\nexport function assertionId(id: string): AssertionId {\n return id as AssertionId;\n}\n\nexport function agentId(id: string): AgentId {\n return id as AgentId;\n}\n\n// ---------------------------------------------------------------------------\n// Assertion spec discriminated unions (T5)\n// ---------------------------------------------------------------------------\n\nexport interface SchemaSpec {\n readonly type: \"schema\";\n readonly target: string;\n readonly schema: Record<string, unknown>;\n}\n\nexport interface ConstraintSpec {\n readonly type: \"constraint\";\n readonly field: string;\n readonly operator: string;\n readonly value?: number;\n readonly min?: number;\n readonly max?: number;\n readonly soft: boolean;\n}\n\nexport interface TraceSpec {\n readonly type: \"trace\";\n readonly check: string;\n readonly tools?: string[];\n readonly tool?: string;\n readonly max_repetitions?: number;\n readonly soft: boolean;\n}\n\nexport interface EffectSpec {\n readonly type: \"effect\";\n readonly check: \"count\" | \"unique\" | \"idempotent\";\n /** A world-v1 snapshot, or `null` when the test ran without a world helper. */\n readonly world: Record<string, unknown> | null;\n readonly resource: string;\n readonly where?: Record<string, unknown>;\n readonly equals?: number;\n readonly at_most?: number;\n readonly at_least?: number;\n readonly fields?: string[];\n readonly field?: string;\n}\n\nexport interface ContentSpec {\n readonly type: \"content\";\n readonly target: string;\n readonly check: string;\n readonly value?: string;\n readonly values?: string[];\n readonly case_sensitive?: boolean;\n readonly soft?: boolean;\n}\n\nexport interface EmbeddingSpec {\n readonly type: \"embedding\";\n readonly target: string;\n readonly reference: string;\n readonly threshold: number | \"dynamic\";\n readonly model?: string;\n readonly soft: boolean;\n}\n\nexport interface LlmJudgeSpec {\n readonly type: \"llm_judge\";\n readonly target: string;\n readonly criteria: string;\n readonly rubric: string;\n readonly threshold: number | \"dynamic\";\n readonly model?: string;\n readonly soft: boolean;\n}\n\nexport interface TraceTreeSpec {\n readonly type: \"trace_tree\";\n readonly check: string;\n readonly [key: string]: unknown;\n}\n\nexport interface PluginSpec {\n readonly type: \"plugin\";\n readonly plugin_id: string;\n readonly config?: Record<string, unknown>;\n readonly soft: boolean;\n}\n\nexport type AssertionSpec =\n | SchemaSpec\n | ConstraintSpec\n | TraceSpec\n | EffectSpec\n | ContentSpec\n | EmbeddingSpec\n | LlmJudgeSpec\n | TraceTreeSpec\n | PluginSpec;\n\n// ---------------------------------------------------------------------------\n// Core protocol types\n// ---------------------------------------------------------------------------\n\nexport interface TraceMetadata {\n readonly total_tokens?: number;\n readonly cost_usd?: number;\n readonly latency_ms?: number;\n readonly model?: string;\n readonly timestamp?: string;\n}\n\n/** Trace v2: a step whose span ended in error. */\nexport interface StepError {\n readonly type: string;\n readonly message?: string;\n}\n\n/** Trace v2: a recorded model request/response pair. */\nexport interface Exchange {\n readonly request: Record<string, unknown>;\n readonly response: Record<string, unknown>;\n}\n\n/** Trace v2: one conversation turn and the indices of its steps. */\nexport interface Turn {\n readonly index: number;\n readonly span_id?: string;\n readonly input?: unknown;\n readonly output?: unknown;\n readonly step_indices: readonly number[];\n}\n\n/** Trace v2: control passing from one agent to another at an agent_call step. */\nexport interface Handoff {\n readonly from_agent: string;\n readonly to_agent: string;\n readonly step_index: number;\n}\n\nexport interface Step {\n readonly type: string;\n readonly name: string;\n readonly args?: Record<string, unknown>;\n readonly result?: Record<string, unknown>;\n readonly sub_trace?: Trace;\n readonly metadata?: Record<string, unknown>;\n readonly started_at_ms?: number;\n readonly ended_at_ms?: number;\n readonly agent_id?: string;\n readonly agent_role?: string;\n // Trace v2 (schema_version 2) fields.\n readonly span_id?: string;\n readonly parent_span_id?: string;\n readonly tool_call_id?: string;\n readonly retry_of?: number;\n readonly error?: StepError;\n readonly exchange?: Exchange;\n}\n\nexport interface Trace {\n readonly trace_id: string;\n readonly output: Record<string, unknown>;\n readonly schema_version?: number;\n readonly agent_id?: string;\n readonly input?: Record<string, unknown>;\n readonly steps: readonly Step[];\n readonly metadata?: TraceMetadata;\n readonly parent_trace_id?: string;\n // Trace v2 (schema_version 2) fields.\n readonly conversation_id?: string;\n readonly turns?: readonly Turn[];\n readonly handoffs?: readonly Handoff[];\n}\n\nexport interface Assertion {\n readonly assertion_id: string;\n readonly type: string;\n readonly spec: Record<string, unknown>;\n readonly request_id?: string;\n}\n\n/**\n * Audit trail for an LLM-judge evaluation. Mirrors\n * engine/pkg/types/assertion.go::JudgeMetadata so report v2 payloads\n * round-trip without losing the model / rubric / variance evidence\n * reviewers need to triage a judge failure.\n */\nexport interface JudgeMetadata {\n readonly provider?: string;\n readonly model?: string;\n readonly rubric_name?: string;\n readonly rubric_version?: string;\n readonly prompt_hash?: string;\n readonly sample_scores?: readonly number[];\n readonly score_mean?: number;\n readonly score_stddev?: number;\n readonly high_variance?: boolean;\n readonly bias_probes?: readonly BiasProbe[];\n readonly calibration?: JudgeAgreement;\n}\n\n/**\n * One judge-bias probe result. Score is the score the judge produced on\n * the mutated input; delta is `score - baseline`. A well-calibrated\n * judge has |delta| close to zero. Mirrors\n * engine/pkg/types/assertion.go::BiasProbe.\n */\nexport interface BiasProbe {\n readonly name: string;\n readonly score: number;\n readonly delta: number;\n}\n\n/**\n * Calibration agreement summary keyed by\n * (rubric_name, rubric_version, prompt_hash). Mirrors\n * engine/pkg/types/assertion.go::JudgeAgreement.\n */\nexport interface JudgeAgreement {\n readonly label_count: number;\n readonly agreement: number;\n readonly cohen_kappa: number;\n readonly roc_auc?: number;\n}\n\nexport interface AssertionResult {\n readonly assertion_id: string;\n readonly status: string;\n readonly score: number;\n readonly explanation: string;\n readonly cost?: number;\n readonly duration_ms?: number;\n readonly request_id?: string;\n /** Set only when status is \"not_evaluated\" (REASON_* constants). */\n readonly reason?: string;\n readonly threshold_source?: string;\n readonly layer?: number;\n readonly type?: string;\n readonly trace_node_path?: string;\n readonly expected?: string;\n readonly actual?: string;\n readonly suggested_action?: string;\n readonly judge_metadata?: JudgeMetadata;\n /**\n * Heuristic root-cause label set by the engine\n * (broken_code / flaky_judge / bad_rubric / missing_trace_data /\n * stochastic_variance). Empty/undefined for passes and any result the\n * engine declined to label. Mirrors\n * engine/pkg/types/failure_class.go.\n */\n readonly failure_class?: string;\n}\n\n/**\n * FailureClass values mirror engine/pkg/types/failure_class.go. Use\n * these constants when matching on AssertionResult.failure_class so a\n * typo in either codebase fails fast.\n */\nexport const FailureClass = {\n BrokenCode: \"broken_code\",\n FlakyJudge: \"flaky_judge\",\n BadRubric: \"bad_rubric\",\n MissingTraceData: \"missing_trace_data\",\n StochasticVariance: \"stochastic_variance\",\n} as const;\nexport type FailureClass = (typeof FailureClass)[keyof typeof FailureClass];\n\n/**\n * Map an assertion-type string to its pipeline layer (1–8). Returns 0\n * when the type is unknown so callers can route uncategorised results\n * into their own bucket.\n */\nexport function layerForType(assertionType: string | undefined): number {\n switch (assertionType) {\n case \"schema\":\n return 1;\n case \"constraint\":\n return 2;\n case \"trace\":\n case \"trace_tree\":\n case \"effect\":\n return 3;\n case \"content\":\n return 4;\n case \"embedding\":\n return 5;\n case \"llm_judge\":\n return 6;\n case \"plugin\":\n return 8;\n default:\n return 0;\n }\n}\n\nexport interface ErrorData {\n readonly error_type: string;\n readonly retryable: boolean;\n readonly detail: string;\n}\n\nexport interface RPCError {\n readonly code: number;\n readonly message: string;\n readonly data?: ErrorData;\n}\n\nexport interface RPCRequest {\n readonly jsonrpc: \"2.0\";\n readonly id: number;\n readonly method: string;\n readonly params: Record<string, unknown>;\n}\n\nexport interface RPCResponse {\n readonly jsonrpc: \"2.0\";\n readonly id: number;\n readonly result?: unknown;\n readonly error?: RPCError;\n}\n\nexport interface InitializeParams {\n readonly sdk_name: string;\n readonly sdk_version: string;\n readonly protocol_version: number;\n readonly required_capabilities: readonly string[];\n readonly preferred_encoding?: string;\n}\n\nexport interface InitializeResult {\n readonly engine_version: string;\n readonly protocol_version: number;\n readonly capabilities: readonly string[];\n readonly missing: readonly string[];\n readonly compatible: boolean;\n readonly encoding?: string;\n readonly max_concurrent_requests?: number;\n readonly max_trace_size_bytes?: number;\n readonly max_steps_per_trace?: number;\n}\n\n/**\n * Limits for one evaluate_batch call on top of the session budget. A judge or\n * embedding call that cannot reserve against them is not sent and its\n * assertion is not_evaluated with reason \"budget_exhausted\".\n */\nexport interface BatchBudget {\n readonly max_judge_calls?: number;\n readonly max_cost_usd?: number;\n}\n\n/**\n * The test an evaluate_batch call belongs to. The engine records it next to\n * each assertion spec when ATTEST_CONTRACTS_DIR is set and uses it for\n * nothing else.\n */\nexport interface BatchContext {\n readonly test_id?: string;\n readonly file?: string;\n /** 1-based line the test starts on. */\n readonly line?: number;\n}\n\nexport interface EvaluateBatchParams {\n readonly trace: Trace;\n readonly assertions: readonly Assertion[];\n /** Omitted when no per-batch budget applies. */\n readonly budget?: BatchBudget;\n /** Omitted outside a test. */\n readonly context?: BatchContext;\n}\n\n/**\n * Attest-initiated model usage (embeddings, judges, judge repeats, bias\n * probes, simulated-user messages). Agent calls not routed through attest\n * are not counted.\n */\nexport interface Usage {\n readonly model_calls: number;\n /** Judge-provider requests, the part of model_calls that max_judge_calls limits. */\n readonly judge_calls: number;\n readonly input_tokens: number;\n readonly output_tokens: number;\n readonly cached_tokens: number;\n readonly cost_usd: number;\n readonly retry_cost_usd: number;\n readonly unpriced_calls: number;\n readonly budget_refused: number;\n}\n\nexport interface EvaluateBatchResult {\n readonly results: readonly AssertionResult[];\n readonly total_cost?: number;\n readonly total_duration_ms?: number;\n /** Always sent by the engine; validated by AttestClient.evaluateBatch. */\n readonly usage: Usage;\n /**\n * True when this result was produced by an SDK simulation shim rather\n * than a real engine evaluation. Engine-produced results always carry\n * simulated=false. CI gates can fail builds that accidentally evaluate\n * against the simulator by checking this flag.\n */\n readonly simulated?: boolean;\n}\n\nexport interface ShutdownResult {\n readonly sessions_completed: number;\n readonly assertions_evaluated: number;\n}\n\nexport interface SubmitPluginResultParams {\n readonly trace_id: string;\n readonly plugin_name: string;\n readonly assertion_id: string;\n readonly result: AssertionResult;\n}\n\n// ---------------------------------------------------------------------------\n// Drift detection types\n// ---------------------------------------------------------------------------\n\nexport interface DriftReport {\n readonly assertion_id: string;\n readonly mean: number;\n readonly stddev: number;\n readonly count: number;\n readonly latest_score: number;\n readonly deviation: number;\n readonly status: string;\n}\n\nexport interface QueryDriftParams {\n readonly assertion_id: string;\n readonly window_size: number;\n}\n\nexport interface QueryDriftResult {\n readonly report: DriftReport;\n}\n\n// ---------------------------------------------------------------------------\n// Simulation types\n// ---------------------------------------------------------------------------\n\nexport interface SimulatePersona {\n readonly name: string;\n readonly system_prompt: string;\n readonly style: string;\n readonly temperature: number;\n readonly max_tokens?: number;\n}\n\nexport interface SimulateFaultConfig {\n readonly error_rate: number;\n readonly latency_jitter_ms: number;\n readonly content_corruption: boolean;\n readonly timeout_after_ms: number;\n}\n\nexport interface ConversationMessage {\n readonly role: string;\n readonly content: string;\n}\n\nexport interface GenerateUserMessageParams {\n readonly persona: SimulatePersona;\n readonly conversation_history: readonly ConversationMessage[];\n readonly fault_config?: SimulateFaultConfig;\n}\n\nexport interface GenerateUserMessageResult {\n readonly message: string;\n}\n","import type { ErrorData } from \"./types.js\";\nimport type { ProtocolDiagnostic } from \"./diagnostics.js\";\n\nexport class ProtocolError extends Error {\n readonly code: number;\n readonly errorMessage: string;\n readonly data: ErrorData | undefined;\n\n constructor(code: number, message: string, data?: ErrorData) {\n super(message);\n this.name = \"ProtocolError\";\n this.code = code;\n this.errorMessage = message;\n this.data = data;\n }\n}\n\nexport class EngineTimeoutError extends Error {\n readonly method: string;\n readonly timeoutMs: number;\n\n constructor(method: string, timeoutMs: number) {\n super(\n `Engine request '${method}' timed out after ${timeoutMs}ms. ` +\n \"Set ATTEST_ENGINE_TIMEOUT to increase the limit.\",\n );\n this.name = \"EngineTimeoutError\";\n this.method = method;\n this.timeoutMs = timeoutMs;\n }\n}\n\n/**\n * Raised when the reader loop detects that engine output has lost\n * framing or contains repeated unparseable lines. All in-flight requests\n * are rejected with this error so callers see a visible failure rather\n * than a hung promise.\n */\nexport class ProtocolDesyncError extends Error {\n readonly diagnostics: readonly ProtocolDiagnostic[];\n\n constructor(message: string, diagnostics: readonly ProtocolDiagnostic[]) {\n super(message);\n this.name = \"ProtocolDesyncError\";\n this.diagnostics = diagnostics;\n }\n}\n\n/**\n * The engine rejected an OTLP/JSON export (`attest-engine trace convert`). The message is\n * the engine's error, which names the offending span or field.\n */\nexport class OTLPConversionError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"OTLPConversionError\";\n }\n}\n","/**\n * Protocol diagnostic types for client-side observability.\n *\n * The reader loop emits diagnostics whenever it cannot route a response\n * line: malformed JSON, missing id, unknown id, or non-routable protocol\n * errors. Diagnostics are buffered in a bounded ring (32 entries) and\n * trigger a desync error when the rate exceeds the configured threshold.\n */\n\nexport type ProtocolDiagnosticKind =\n | \"malformed_json\"\n | \"non_object_response\"\n | \"invalid_jsonrpc_version\"\n | \"missing_id\"\n | \"unknown_id\"\n | \"non_routable_error\";\n\nexport interface ProtocolDiagnostic {\n readonly kind: ProtocolDiagnosticKind;\n readonly message: string;\n readonly rawLine: string;\n readonly timestampMs: number;\n}\n\nexport interface ProtocolLogger {\n warn(message: string, ...args: unknown[]): void;\n error(message: string, ...args: unknown[]): void;\n}\n\nconst DEFAULT_BUFFER_SIZE = 32;\nconst MAX_LINE_PREVIEW = 512;\n\nexport class ProtocolDiagnosticBuffer {\n private readonly capacity: number;\n private readonly entries: ProtocolDiagnostic[] = [];\n\n constructor(capacity: number = DEFAULT_BUFFER_SIZE) {\n if (capacity <= 0) {\n throw new Error(\n `ProtocolDiagnosticBuffer capacity must be positive, got ${capacity}`,\n );\n }\n this.capacity = capacity;\n }\n\n push(diagnostic: ProtocolDiagnostic): void {\n if (this.entries.length >= this.capacity) {\n this.entries.shift();\n }\n this.entries.push(diagnostic);\n }\n\n snapshot(): readonly ProtocolDiagnostic[] {\n return this.entries.slice();\n }\n\n countWithin(windowMs: number, nowMs: number): number {\n const cutoff = nowMs - windowMs;\n let count = 0;\n for (let i = this.entries.length - 1; i >= 0; i -= 1) {\n if (this.entries[i]!.timestampMs >= cutoff) {\n count += 1;\n } else {\n break;\n }\n }\n return count;\n }\n\n clear(): void {\n this.entries.length = 0;\n }\n}\n\nexport function previewLine(line: string): string {\n if (line.length <= MAX_LINE_PREVIEW) return line;\n return line.slice(0, MAX_LINE_PREVIEW) + \"…\";\n}\n","import type { ErrorData, RPCResponse } from \"./types.js\";\nimport { ProtocolError } from \"./errors.js\";\n\n/**\n * Encode a JSON-RPC 2.0 request as an NDJSON line.\n */\nexport function encodeRequest(\n id: number,\n method: string,\n params: Record<string, unknown>,\n): string {\n const msg = {\n jsonrpc: \"2.0\" as const,\n id,\n method,\n params,\n };\n return JSON.stringify(msg) + \"\\n\";\n}\n\n/**\n * Decode a JSON-RPC 2.0 response from an NDJSON line.\n * Throws ProtocolError if the response contains an error.\n * Throws Error for malformed JSON or invalid responses.\n */\nexport function decodeResponse(line: string): RPCResponse {\n const text = line.trim();\n if (!text) {\n throw new Error(\"empty response line\");\n }\n\n let data: unknown;\n try {\n data = JSON.parse(text);\n } catch (e) {\n throw new Error(`malformed JSON response: ${e instanceof Error ? e.message : String(e)}`);\n }\n\n if (typeof data !== \"object\" || data === null || Array.isArray(data)) {\n throw new Error(`expected JSON object, got ${Array.isArray(data) ? \"array\" : typeof data}`);\n }\n\n const obj = data as Record<string, unknown>;\n\n if (obj.jsonrpc !== \"2.0\") {\n throw new Error(`invalid jsonrpc version: ${String(obj.jsonrpc)}`);\n }\n\n if (obj.error != null) {\n const err = obj.error as Record<string, unknown>;\n let errorData: ErrorData | undefined;\n\n if (err.data != null) {\n const raw = err.data as Record<string, unknown>;\n errorData = {\n error_type: (raw.error_type as string) ?? \"\",\n retryable: (raw.retryable as boolean) ?? false,\n detail: (raw.detail as string) ?? \"\",\n };\n }\n\n throw new ProtocolError(\n (err.code as number) ?? -1,\n (err.message as string) ?? \"unknown error\",\n errorData,\n );\n }\n\n return obj as unknown as RPCResponse;\n}\n\n/**\n * Extract the result field from a decoded response.\n */\nexport function extractResult(response: RPCResponse): unknown {\n if (response.result === undefined) {\n throw new Error(\"response missing 'result' field\");\n }\n return response.result;\n}\n\n/**\n * Extract the request ID from a decoded response.\n */\nexport function extractId(response: RPCResponse): number {\n if (response.id === undefined) {\n throw new Error(\"response missing 'id' field\");\n }\n return Number(response.id);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAM,gBAAgB;AACtB,IAAM,iBAAiB;AACvB,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AAGxB,IAAM,cAAc;AACpB,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AACzB,IAAM,uBAAuB;AAG7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IAAI;AAAA,MACP,IAAI,QAAmB;AAAA,MACvB,IAAI,WAAsB;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAKO,SAAS,cAAc,UAAgC;AAC5D,MAAI,SAAS,WAAW,QAAW;AACjC,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AACA,SAAO,SAAS;AAClB;AAKO,SAAS,UAAU,UAA+B;AACvD,MAAI,SAAS,OAAO,QAAW;AAC7B,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AACA,SAAO,OAAO,SAAS,EAAE;AAC3B;","names":[]}
@@ -13,6 +13,7 @@ declare const REASON_MISSING_EVIDENCE: "missing_evidence";
13
13
  declare const REASON_SHORT_CIRCUITED: "short_circuited";
14
14
  declare const REASON_BUDGET_EXHAUSTED: "budget_exhausted";
15
15
  declare const REASON_JUDGE_ABSTAINED: "judge_abstained";
16
+ declare const REASON_REPLAY_MISS: "replay_miss";
16
17
  declare const OUTCOME_PASS: "pass";
17
18
  declare const OUTCOME_FAIL: "fail";
18
19
  declare const OUTCOME_SKIP: "skip";
@@ -20,6 +21,7 @@ type Outcome = typeof OUTCOME_PASS | typeof OUTCOME_FAIL | typeof OUTCOME_SKIP;
20
21
  declare const TYPE_SCHEMA: "schema";
21
22
  declare const TYPE_CONSTRAINT: "constraint";
22
23
  declare const TYPE_TRACE: "trace";
24
+ declare const TYPE_EFFECT: "effect";
23
25
  declare const TYPE_CONTENT: "content";
24
26
  declare const TYPE_EMBEDDING: "embedding";
25
27
  declare const TYPE_LLM_JUDGE: "llm_judge";
@@ -64,6 +66,19 @@ interface TraceSpec {
64
66
  readonly max_repetitions?: number;
65
67
  readonly soft: boolean;
66
68
  }
69
+ interface EffectSpec {
70
+ readonly type: "effect";
71
+ readonly check: "count" | "unique" | "idempotent";
72
+ /** A world-v1 snapshot, or `null` when the test ran without a world helper. */
73
+ readonly world: Record<string, unknown> | null;
74
+ readonly resource: string;
75
+ readonly where?: Record<string, unknown>;
76
+ readonly equals?: number;
77
+ readonly at_most?: number;
78
+ readonly at_least?: number;
79
+ readonly fields?: string[];
80
+ readonly field?: string;
81
+ }
67
82
  interface ContentSpec {
68
83
  readonly type: "content";
69
84
  readonly target: string;
@@ -101,7 +116,7 @@ interface PluginSpec {
101
116
  readonly config?: Record<string, unknown>;
102
117
  readonly soft: boolean;
103
118
  }
104
- type AssertionSpec = SchemaSpec | ConstraintSpec | TraceSpec | ContentSpec | EmbeddingSpec | LlmJudgeSpec | TraceTreeSpec | PluginSpec;
119
+ type AssertionSpec = SchemaSpec | ConstraintSpec | TraceSpec | EffectSpec | ContentSpec | EmbeddingSpec | LlmJudgeSpec | TraceTreeSpec | PluginSpec;
105
120
  interface TraceMetadata {
106
121
  readonly total_tokens?: number;
107
122
  readonly cost_usd?: number;
@@ -306,11 +321,24 @@ interface BatchBudget {
306
321
  readonly max_judge_calls?: number;
307
322
  readonly max_cost_usd?: number;
308
323
  }
324
+ /**
325
+ * The test an evaluate_batch call belongs to. The engine records it next to
326
+ * each assertion spec when ATTEST_CONTRACTS_DIR is set and uses it for
327
+ * nothing else.
328
+ */
329
+ interface BatchContext {
330
+ readonly test_id?: string;
331
+ readonly file?: string;
332
+ /** 1-based line the test starts on. */
333
+ readonly line?: number;
334
+ }
309
335
  interface EvaluateBatchParams {
310
336
  readonly trace: Trace;
311
337
  readonly assertions: readonly Assertion[];
312
338
  /** Omitted when no per-batch budget applies. */
313
339
  readonly budget?: BatchBudget;
340
+ /** Omitted outside a test. */
341
+ readonly context?: BatchContext;
314
342
  }
315
343
  /**
316
344
  * Attest-initiated model usage (embeddings, judges, judge repeats, bias
@@ -473,4 +501,5 @@ declare function extractResult(response: RPCResponse): unknown;
473
501
  */
474
502
  declare function extractId(response: RPCResponse): number;
475
503
 
476
- export { type AgentId, type Assertion, type AssertionId, type AssertionResult, type AssertionSpec, type BatchBudget, type BiasProbe, type ConstraintSpec, type ContentSpec, type ConversationMessage, type DriftReport, ERR_ASSERTION_ERROR, ERR_ENGINE_ERROR, ERR_INVALID_TRACE, ERR_PROVIDER_ERROR, ERR_SESSION_ERROR, ERR_TIMEOUT, type EmbeddingSpec, EngineTimeoutError, type ErrorData, type EvaluateBatchParams, type EvaluateBatchResult, type Exchange, FailureClass, type GenerateUserMessageParams, type GenerateUserMessageResult, type Handoff, type InitializeParams, type InitializeResult, type JudgeAgreement, type JudgeMetadata, type LlmJudgeSpec, OTLPConversionError, OUTCOME_FAIL, OUTCOME_PASS, OUTCOME_SKIP, type Outcome, type PluginSpec, ProtocolDesyncError, type ProtocolDiagnostic, ProtocolDiagnosticBuffer, type ProtocolDiagnosticKind, ProtocolError, type ProtocolLogger, type QueryDriftParams, type QueryDriftResult, REASON_BUDGET_EXHAUSTED, REASON_JUDGE_ABSTAINED, REASON_MISSING_EVIDENCE, REASON_PROVIDER_NOT_CONFIGURED, REASON_PROVIDER_UNAVAILABLE, REASON_SHORT_CIRCUITED, REASON_SIMULATION, type RPCError, type RPCRequest, type RPCResponse, STATUS_HARD_FAIL, STATUS_NOT_EVALUATED, STATUS_PASS, STATUS_SOFT_FAIL, STEP_AGENT_CALL, STEP_LLM_CALL, STEP_RETRIEVAL, STEP_TOOL_CALL, type SchemaSpec, type ShutdownResult, type SimulateFaultConfig, type SimulatePersona, type Step, type StepError, type SubmitPluginResultParams, TYPE_CONSTRAINT, TYPE_CONTENT, TYPE_EMBEDDING, TYPE_LLM_JUDGE, TYPE_PLUGIN, TYPE_SCHEMA, TYPE_TRACE, TYPE_TRACE_TREE, type Trace, type TraceId, type TraceMetadata, type TraceSpec, type TraceTreeSpec, type Turn, type Usage, agentId, assertionId, decodeResponse, encodeRequest, extractId, extractResult, layerForType, previewLine, traceId };
504
+ export { ERR_ASSERTION_ERROR, ERR_ENGINE_ERROR, ERR_INVALID_TRACE, ERR_PROVIDER_ERROR, ERR_SESSION_ERROR, ERR_TIMEOUT, EngineTimeoutError, FailureClass, OTLPConversionError, OUTCOME_FAIL, OUTCOME_PASS, OUTCOME_SKIP, ProtocolDesyncError, ProtocolDiagnosticBuffer, ProtocolError, REASON_BUDGET_EXHAUSTED, REASON_JUDGE_ABSTAINED, REASON_MISSING_EVIDENCE, REASON_PROVIDER_NOT_CONFIGURED, REASON_PROVIDER_UNAVAILABLE, REASON_REPLAY_MISS, REASON_SHORT_CIRCUITED, REASON_SIMULATION, STATUS_HARD_FAIL, STATUS_NOT_EVALUATED, STATUS_PASS, STATUS_SOFT_FAIL, STEP_AGENT_CALL, STEP_LLM_CALL, STEP_RETRIEVAL, STEP_TOOL_CALL, TYPE_CONSTRAINT, TYPE_CONTENT, TYPE_EFFECT, TYPE_EMBEDDING, TYPE_LLM_JUDGE, TYPE_PLUGIN, TYPE_SCHEMA, TYPE_TRACE, TYPE_TRACE_TREE, agentId, assertionId, decodeResponse, encodeRequest, extractId, extractResult, layerForType, previewLine, traceId };
505
+ export type { AgentId, Assertion, AssertionId, AssertionResult, AssertionSpec, BatchBudget, BatchContext, BiasProbe, ConstraintSpec, ContentSpec, ConversationMessage, DriftReport, EffectSpec, EmbeddingSpec, ErrorData, EvaluateBatchParams, EvaluateBatchResult, Exchange, GenerateUserMessageParams, GenerateUserMessageResult, Handoff, InitializeParams, InitializeResult, JudgeAgreement, JudgeMetadata, LlmJudgeSpec, Outcome, PluginSpec, ProtocolDiagnostic, ProtocolDiagnosticKind, ProtocolLogger, QueryDriftParams, QueryDriftResult, RPCError, RPCRequest, RPCResponse, SchemaSpec, ShutdownResult, SimulateFaultConfig, SimulatePersona, Step, StepError, SubmitPluginResultParams, Trace, TraceId, TraceMetadata, TraceSpec, TraceTreeSpec, Turn, Usage };