@agent-inspect/vitest 6.19.1 → 6.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -170,6 +170,24 @@ interface TraceReadResult {
170
170
  sourceFiles: string[];
171
171
  }
172
172
 
173
+ /**
174
+ * Explicit actor/run projection for TraceContract evaluation (#320).
175
+ *
176
+ * Selectors use only declared metadata (or explicit event ids). Zero matches
177
+ * and singular-actor ambiguity fail closed. No timestamp or display-name
178
+ * inference.
179
+ *
180
+ * @experimental
181
+ */
182
+ interface TraceContractScope {
183
+ runId?: string;
184
+ subAgentId?: string;
185
+ groupId?: string;
186
+ workflowStep?: string;
187
+ /** Explicit root event id; evaluation projects to that event and descendants. */
188
+ rootEventId?: string;
189
+ }
190
+
173
191
  /**
174
192
  * @experimental Typed trace contract input. Evolves during v6.5.x.
175
193
  */
@@ -182,7 +200,8 @@ interface TraceContractToolRules {
182
200
  /**
183
201
  * Unconditional tool presence invariant. Every named tool must appear at least
184
202
  * once. Do not use for cache-hit or alternate-path shortcuts — prefer
185
- * `observations.required` until `alternatives.anyOf` ships (planned 6.20.0).
203
+ * `alternatives.anyOf` or `observations.required` when a legitimate path may
204
+ * skip the tool.
186
205
  *
187
206
  * @see docs/TRACE-CONTRACTS.md
188
207
  */
@@ -195,40 +214,110 @@ interface TraceContractToolRules {
195
214
  allowed?: string[];
196
215
  maxCalls?: number;
197
216
  /**
198
- * Required tool order as adjacent first-occurrence pairs (start/encounter order).
217
+ * Required tool order expanded into adjacent pairs.
199
218
  *
200
219
  * `[A, B, C]` expands to “A before B” and “B before C”, each comparing the
201
- * first occurrence of the named tool. Unlisted intermediate tools are
202
- * allowed. Later repetitions do not invalidate an earlier valid order.
220
+ * selected `requiredOrderMode` to every pair. Unlisted intermediate tools
221
+ * are allowed.
203
222
  *
204
223
  * TraceContract `requiredOrder` **implies presence**: every listed name is
205
224
  * added to the effective required-tool set. Low-level `createToolOrderingRule`
206
225
  * alone may still pass vacuously when an endpoint is missing.
207
226
  *
208
- * This is **not** causal happens-before. Overlapping intervals emit a
209
- * non-failing overlap warning. Planned modes (6.20.0, GitHub #308):
210
- * `happens-before`, `all-occurrences`.
227
+ * The default `first-occurrence` mode preserves first-occurrence encounter
228
+ * ordering; overlapping intervals emit a non-failing warning. `happens-before`
229
+ * requires the first before event to finish before the first after event starts.
230
+ * `all-occurrences` applies that causal boundary to every occurrence.
211
231
  *
212
232
  * @see docs/TRACE-CONTRACTS.md
213
233
  * @beta Available through `agent-inspect/checks`. Additive changes may ship
214
234
  * in minor releases; breaking changes require a future major.
215
235
  */
216
236
  requiredOrder?: string[];
237
+ /**
238
+ * Ordering semantics applied to every adjacent pair in `requiredOrder`.
239
+ * Causal modes fail closed when a required interval boundary is unavailable.
240
+ *
241
+ * @defaultValue `"first-occurrence"`
242
+ * @beta Available through `agent-inspect/checks`.
243
+ */
244
+ requiredOrderMode?: "first-occurrence" | "happens-before" | "all-occurrences";
217
245
  }
218
246
  interface TraceContractLlmRules {
219
247
  maxCalls?: number;
220
248
  maxTotalTokens?: number;
221
249
  allowedModels?: string[];
222
250
  }
251
+ /**
252
+ * Structural provenance requirements for named observed outcomes (#321).
253
+ *
254
+ * These checks prove method/evidence linkage was recorded. They do **not**
255
+ * prove the claim is semantically true, authorized, complete, or externally
256
+ * trusted.
257
+ *
258
+ * @experimental
259
+ */
260
+ interface TraceContractObservationProvenance {
261
+ /** Require a non-empty method from the bounded ObservedOutcomeMethod vocabulary. */
262
+ method?: boolean;
263
+ /**
264
+ * Require bounded evidence references. Supported shapes:
265
+ * `string` event id, `{ eventId }`, or `{ eventIds: string[] }` (max 16 ids).
266
+ */
267
+ evidence?: boolean;
268
+ /** When true with evidence, each referenced event id must exist in the same run. */
269
+ sameRunEventReference?: boolean;
270
+ }
223
271
  interface TraceContractObservationRules {
224
272
  required?: string[];
225
273
  failOn?: Array<"failed" | "unknown" | "skipped">;
274
+ /**
275
+ * Structural provenance gates for `required` observation names.
276
+ *
277
+ * @experimental
278
+ */
279
+ requireProvenance?: TraceContractObservationProvenance;
280
+ }
281
+ /**
282
+ * One deterministic alternate path. Branch contracts are one level only —
283
+ * nested `alternatives` are rejected.
284
+ *
285
+ * @experimental
286
+ */
287
+ interface TraceContractAlternativeBranch {
288
+ /** Unique branch id within `alternatives.anyOf`. */
289
+ id: string;
290
+ description?: string;
291
+ /** Branch body: run/tools/llm/observations only (no nested alternatives). */
292
+ contract: TraceContractBody;
293
+ }
294
+ /**
295
+ * Bounded alternative valid paths for legitimate shortcuts (GitHub #309).
296
+ *
297
+ * @experimental
298
+ */
299
+ interface TraceContractAlternatives {
300
+ /**
301
+ * One level of named branches. The overall contract passes when the base
302
+ * rules pass and **at least one** complete branch passes.
303
+ */
304
+ anyOf: TraceContractAlternativeBranch[];
226
305
  }
227
- interface TraceContractInput {
306
+ /** Contract body without alternatives (base or branch). */
307
+ type TraceContractBody = {
228
308
  run?: TraceContractRunRules;
229
309
  tools?: TraceContractToolRules;
230
310
  llm?: TraceContractLlmRules;
231
311
  observations?: TraceContractObservationRules;
312
+ };
313
+ interface TraceContractInput extends TraceContractBody {
314
+ /**
315
+ * Optional actor/run projection applied before evaluation (#320).
316
+ *
317
+ * @experimental
318
+ */
319
+ scope?: TraceContractScope;
320
+ alternatives?: TraceContractAlternatives;
232
321
  }
233
322
 
234
323
  /**
package/dist/index.d.ts CHANGED
@@ -170,6 +170,24 @@ interface TraceReadResult {
170
170
  sourceFiles: string[];
171
171
  }
172
172
 
173
+ /**
174
+ * Explicit actor/run projection for TraceContract evaluation (#320).
175
+ *
176
+ * Selectors use only declared metadata (or explicit event ids). Zero matches
177
+ * and singular-actor ambiguity fail closed. No timestamp or display-name
178
+ * inference.
179
+ *
180
+ * @experimental
181
+ */
182
+ interface TraceContractScope {
183
+ runId?: string;
184
+ subAgentId?: string;
185
+ groupId?: string;
186
+ workflowStep?: string;
187
+ /** Explicit root event id; evaluation projects to that event and descendants. */
188
+ rootEventId?: string;
189
+ }
190
+
173
191
  /**
174
192
  * @experimental Typed trace contract input. Evolves during v6.5.x.
175
193
  */
@@ -182,7 +200,8 @@ interface TraceContractToolRules {
182
200
  /**
183
201
  * Unconditional tool presence invariant. Every named tool must appear at least
184
202
  * once. Do not use for cache-hit or alternate-path shortcuts — prefer
185
- * `observations.required` until `alternatives.anyOf` ships (planned 6.20.0).
203
+ * `alternatives.anyOf` or `observations.required` when a legitimate path may
204
+ * skip the tool.
186
205
  *
187
206
  * @see docs/TRACE-CONTRACTS.md
188
207
  */
@@ -195,40 +214,110 @@ interface TraceContractToolRules {
195
214
  allowed?: string[];
196
215
  maxCalls?: number;
197
216
  /**
198
- * Required tool order as adjacent first-occurrence pairs (start/encounter order).
217
+ * Required tool order expanded into adjacent pairs.
199
218
  *
200
219
  * `[A, B, C]` expands to “A before B” and “B before C”, each comparing the
201
- * first occurrence of the named tool. Unlisted intermediate tools are
202
- * allowed. Later repetitions do not invalidate an earlier valid order.
220
+ * selected `requiredOrderMode` to every pair. Unlisted intermediate tools
221
+ * are allowed.
203
222
  *
204
223
  * TraceContract `requiredOrder` **implies presence**: every listed name is
205
224
  * added to the effective required-tool set. Low-level `createToolOrderingRule`
206
225
  * alone may still pass vacuously when an endpoint is missing.
207
226
  *
208
- * This is **not** causal happens-before. Overlapping intervals emit a
209
- * non-failing overlap warning. Planned modes (6.20.0, GitHub #308):
210
- * `happens-before`, `all-occurrences`.
227
+ * The default `first-occurrence` mode preserves first-occurrence encounter
228
+ * ordering; overlapping intervals emit a non-failing warning. `happens-before`
229
+ * requires the first before event to finish before the first after event starts.
230
+ * `all-occurrences` applies that causal boundary to every occurrence.
211
231
  *
212
232
  * @see docs/TRACE-CONTRACTS.md
213
233
  * @beta Available through `agent-inspect/checks`. Additive changes may ship
214
234
  * in minor releases; breaking changes require a future major.
215
235
  */
216
236
  requiredOrder?: string[];
237
+ /**
238
+ * Ordering semantics applied to every adjacent pair in `requiredOrder`.
239
+ * Causal modes fail closed when a required interval boundary is unavailable.
240
+ *
241
+ * @defaultValue `"first-occurrence"`
242
+ * @beta Available through `agent-inspect/checks`.
243
+ */
244
+ requiredOrderMode?: "first-occurrence" | "happens-before" | "all-occurrences";
217
245
  }
218
246
  interface TraceContractLlmRules {
219
247
  maxCalls?: number;
220
248
  maxTotalTokens?: number;
221
249
  allowedModels?: string[];
222
250
  }
251
+ /**
252
+ * Structural provenance requirements for named observed outcomes (#321).
253
+ *
254
+ * These checks prove method/evidence linkage was recorded. They do **not**
255
+ * prove the claim is semantically true, authorized, complete, or externally
256
+ * trusted.
257
+ *
258
+ * @experimental
259
+ */
260
+ interface TraceContractObservationProvenance {
261
+ /** Require a non-empty method from the bounded ObservedOutcomeMethod vocabulary. */
262
+ method?: boolean;
263
+ /**
264
+ * Require bounded evidence references. Supported shapes:
265
+ * `string` event id, `{ eventId }`, or `{ eventIds: string[] }` (max 16 ids).
266
+ */
267
+ evidence?: boolean;
268
+ /** When true with evidence, each referenced event id must exist in the same run. */
269
+ sameRunEventReference?: boolean;
270
+ }
223
271
  interface TraceContractObservationRules {
224
272
  required?: string[];
225
273
  failOn?: Array<"failed" | "unknown" | "skipped">;
274
+ /**
275
+ * Structural provenance gates for `required` observation names.
276
+ *
277
+ * @experimental
278
+ */
279
+ requireProvenance?: TraceContractObservationProvenance;
280
+ }
281
+ /**
282
+ * One deterministic alternate path. Branch contracts are one level only —
283
+ * nested `alternatives` are rejected.
284
+ *
285
+ * @experimental
286
+ */
287
+ interface TraceContractAlternativeBranch {
288
+ /** Unique branch id within `alternatives.anyOf`. */
289
+ id: string;
290
+ description?: string;
291
+ /** Branch body: run/tools/llm/observations only (no nested alternatives). */
292
+ contract: TraceContractBody;
293
+ }
294
+ /**
295
+ * Bounded alternative valid paths for legitimate shortcuts (GitHub #309).
296
+ *
297
+ * @experimental
298
+ */
299
+ interface TraceContractAlternatives {
300
+ /**
301
+ * One level of named branches. The overall contract passes when the base
302
+ * rules pass and **at least one** complete branch passes.
303
+ */
304
+ anyOf: TraceContractAlternativeBranch[];
226
305
  }
227
- interface TraceContractInput {
306
+ /** Contract body without alternatives (base or branch). */
307
+ type TraceContractBody = {
228
308
  run?: TraceContractRunRules;
229
309
  tools?: TraceContractToolRules;
230
310
  llm?: TraceContractLlmRules;
231
311
  observations?: TraceContractObservationRules;
312
+ };
313
+ interface TraceContractInput extends TraceContractBody {
314
+ /**
315
+ * Optional actor/run projection applied before evaluation (#320).
316
+ *
317
+ * @experimental
318
+ */
319
+ scope?: TraceContractScope;
320
+ alternatives?: TraceContractAlternatives;
232
321
  }
233
322
 
234
323
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-inspect/vitest",
3
- "version": "6.19.1",
3
+ "version": "6.21.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Vitest reporter and experimental TraceContract matchers for AgentInspect local evidence",
@@ -37,7 +37,7 @@
37
37
  "vitest": "^2.1.0 || ^3.2.6"
38
38
  },
39
39
  "dependencies": {
40
- "agent-inspect": "6.19.1"
40
+ "agent-inspect": "6.21.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "vitest": "^3.2.7"