autotel-schema 2.0.5 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -8
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/contract-Ymh_Q37N.d.cts +305 -0
- package/dist/contract-Ymh_Q37N.d.cts.map +1 -0
- package/dist/contract-Ymh_Q37N.d.ts +305 -0
- package/dist/contract-Ymh_Q37N.d.ts.map +1 -0
- package/dist/{diff-BQPh72vY.d.cts → diff-CAIC04O4.d.ts} +5 -4
- package/dist/diff-CAIC04O4.d.ts.map +1 -0
- package/dist/{diff-D7qkNn0-.d.ts → diff-CfvhW7ux.d.cts} +5 -4
- package/dist/diff-CfvhW7ux.d.cts.map +1 -0
- package/dist/diff.cjs.map +1 -1
- package/dist/diff.d.cts +1 -1
- package/dist/diff.d.ts +1 -1
- package/dist/diff.js.map +1 -1
- package/dist/index.cjs +8 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/processor-BPp_DewZ.js +635 -0
- package/dist/processor-BPp_DewZ.js.map +1 -0
- package/dist/{processor-CkBkzK6y.d.cts → processor-DVcsS6Rz.d.cts} +2 -3
- package/dist/processor-DVcsS6Rz.d.cts.map +1 -0
- package/dist/processor-Gu8Yl_dS.cjs +737 -0
- package/dist/processor-Gu8Yl_dS.cjs.map +1 -0
- package/dist/{processor-CK7LAdaa.d.ts → processor-TpuacLr5.d.ts} +2 -3
- package/dist/processor-TpuacLr5.d.ts.map +1 -0
- package/dist/processor.cjs +1 -1
- package/dist/processor.d.cts +1 -1
- package/dist/processor.d.ts +1 -1
- package/dist/processor.js +1 -1
- package/dist/snapshot-CyWGJaJT.cjs.map +1 -1
- package/dist/snapshot-h8pb_Up_.js.map +1 -1
- package/package.json +4 -4
- package/dist/contract-DGjxR9nb.d.cts +0 -123
- package/dist/contract-DGjxR9nb.d.cts.map +0 -1
- package/dist/contract-DGjxR9nb.d.ts +0 -123
- package/dist/contract-DGjxR9nb.d.ts.map +0 -1
- package/dist/diff-BQPh72vY.d.cts.map +0 -1
- package/dist/diff-D7qkNn0-.d.ts.map +0 -1
- package/dist/processor-CK7LAdaa.d.ts.map +0 -1
- package/dist/processor-CkBkzK6y.d.cts.map +0 -1
- package/dist/processor-D93TAXvZ.cjs +0 -366
- package/dist/processor-D93TAXvZ.cjs.map +0 -1
- package/dist/processor-FmvKYllX.js +0 -306
- package/dist/processor-FmvKYllX.js.map +0 -1
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
//#region src/scenario.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Scenario conformance — a flow-level contract checked against collected spans.
|
|
4
|
+
*
|
|
5
|
+
* Where {@link ./contract} declares the *surface* of your telemetry (span
|
|
6
|
+
* names + attributes), a scenario declares the *behaviour* of one exercised
|
|
7
|
+
* flow: which events must fire, how many times, in what parent/child
|
|
8
|
+
* topology, and — critically — **when the observation is complete**, because
|
|
9
|
+
* for an async flow a missing event and an event that has not fired *yet* are
|
|
10
|
+
* indistinguishable without a completion boundary.
|
|
11
|
+
*
|
|
12
|
+
* Checking a scenario yields one of three outcomes, not two:
|
|
13
|
+
*
|
|
14
|
+
* - `conformant` — the boundary closed and the signature satisfied the contract
|
|
15
|
+
* - `non-conformant` — required behaviour was missing or invalid (definitive)
|
|
16
|
+
* - `incomplete` — the boundary did not close within the observation budget;
|
|
17
|
+
* infrastructure slowness is *not* reported as behavioural regression
|
|
18
|
+
*
|
|
19
|
+
* Absence is definitive only after closure (closed-world semantics). Excess
|
|
20
|
+
* is definitive immediately: a `max` cardinality violation or an unexpected
|
|
21
|
+
* error span fails the check even while the flow is still open.
|
|
22
|
+
*
|
|
23
|
+
* Undeclared events are **additive**: reported in `result.additions`, never a
|
|
24
|
+
* failure — improving instrumentation must not break CI.
|
|
25
|
+
*
|
|
26
|
+
* The span input shape is structurally compatible with `SerializedSpan` from
|
|
27
|
+
* `autotel/test-span-collector`, so a test can feed a collector's output
|
|
28
|
+
* straight in. Like the rest of this package the module is dependency-free —
|
|
29
|
+
* usable from vitest, a deferred reconciliation job, or a CLI alike.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const result = await checkScenario(
|
|
34
|
+
* contract.scenarios!['transfer.accept'],
|
|
35
|
+
* () => collector.peekTrace(traceId),
|
|
36
|
+
* { name: 'transfer.accept' },
|
|
37
|
+
* );
|
|
38
|
+
* if (result.outcome === 'non-conformant') throw new Error(formatScenarioResult(result));
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
/** A finished span/event as the scenario checker sees it. */
|
|
42
|
+
interface ScenarioSpan {
|
|
43
|
+
spanId: string;
|
|
44
|
+
parentSpanId?: string;
|
|
45
|
+
name: string;
|
|
46
|
+
status: 'ok' | 'error' | 'unset';
|
|
47
|
+
attributes?: Record<string, unknown>;
|
|
48
|
+
/** Epoch ms. Optional — used by {@link proposeScenario} to suggest budgets. */
|
|
49
|
+
startTimeMs?: number;
|
|
50
|
+
durationMs?: number;
|
|
51
|
+
}
|
|
52
|
+
/** Canonical cardinality range. `max` omitted = unbounded. */
|
|
53
|
+
interface Cardinality {
|
|
54
|
+
min: number;
|
|
55
|
+
max?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Parse a cardinality shorthand: `'exactly 1'`, `'at least 1'`, `'at most 3'`,
|
|
59
|
+
* `'0..1'`, `'2..'`. A canonical {@link Cardinality} passes through.
|
|
60
|
+
*/
|
|
61
|
+
declare function parseCardinality(input: string | Cardinality): Cardinality;
|
|
62
|
+
/** Declaration for one event (span name) a scenario expects to observe. */
|
|
63
|
+
interface ScenarioEventSpec {
|
|
64
|
+
/** How many occurrences are permitted. Defaults to `'at least 1'`. */
|
|
65
|
+
cardinality?: string | Cardinality;
|
|
66
|
+
/**
|
|
67
|
+
* Expected terminal status. Defaults to non-error: an `error` status on an
|
|
68
|
+
* event not declared `status: 'error'` is a definitive violation.
|
|
69
|
+
*/
|
|
70
|
+
status?: 'ok' | 'error';
|
|
71
|
+
description?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* How the observed phase of a scenario becomes complete. Every async
|
|
75
|
+
* conformance check must declare this — it is what makes absence meaningful.
|
|
76
|
+
*
|
|
77
|
+
* `externally-reconciled` never closes in-process: the phase is verified
|
|
78
|
+
* elsewhere (a deferred reconciliation job keyed by a durable business ID),
|
|
79
|
+
* so an in-process check reports at most definitive violations, never absence.
|
|
80
|
+
*/
|
|
81
|
+
type CompletionBoundary = {
|
|
82
|
+
mode: 'root-span-closed';
|
|
83
|
+
observationBudgetMs: number;
|
|
84
|
+
} | {
|
|
85
|
+
mode: 'terminal-event';
|
|
86
|
+
event: string;
|
|
87
|
+
observationBudgetMs: number;
|
|
88
|
+
} | {
|
|
89
|
+
mode: 'externally-reconciled';
|
|
90
|
+
reconciliationDeadlineMs: number;
|
|
91
|
+
};
|
|
92
|
+
/** The flow-level contract for one exercised scenario (or one phase of one). */
|
|
93
|
+
interface ScenarioSpec {
|
|
94
|
+
description?: string;
|
|
95
|
+
/** When the observed phase is complete. See {@link CompletionBoundary}. */
|
|
96
|
+
completion: CompletionBoundary;
|
|
97
|
+
/** Events this scenario must (or may) observe, keyed by span name. */
|
|
98
|
+
events: Record<string, ScenarioEventSpec>;
|
|
99
|
+
/**
|
|
100
|
+
* Required ancestor→descendant edges by span name. Ancestor — not immediate
|
|
101
|
+
* parent — so a framework span inserted between the two does not break the
|
|
102
|
+
* contract (canonicalisation: infrastructure spans are not behaviour).
|
|
103
|
+
*/
|
|
104
|
+
edges?: ReadonlyArray<readonly [string, string]>;
|
|
105
|
+
/** Edges that may appear but are not required. Documented, never enforced. */
|
|
106
|
+
optionalEdges?: ReadonlyArray<readonly [string, string]>;
|
|
107
|
+
}
|
|
108
|
+
type ScenarioOutcome = 'conformant' | 'non-conformant' | 'incomplete';
|
|
109
|
+
type ScenarioViolationCode = 'missing_event' | 'cardinality_violation' | 'missing_edge' | 'unexpected_error';
|
|
110
|
+
/** A definitive (breaking) discrepancy between observed spans and the scenario. */
|
|
111
|
+
interface ScenarioViolation {
|
|
112
|
+
code: ScenarioViolationCode;
|
|
113
|
+
event?: string;
|
|
114
|
+
edge?: readonly [string, string];
|
|
115
|
+
message: string;
|
|
116
|
+
}
|
|
117
|
+
/** An additive observation — reported, never a failure. */
|
|
118
|
+
interface ScenarioAddition {
|
|
119
|
+
code: 'undeclared_event';
|
|
120
|
+
event: string;
|
|
121
|
+
count: number;
|
|
122
|
+
message: string;
|
|
123
|
+
}
|
|
124
|
+
interface ScenarioResult {
|
|
125
|
+
scenario: string;
|
|
126
|
+
outcome: ScenarioOutcome;
|
|
127
|
+
/** Whether the completion boundary closed within the observation window. */
|
|
128
|
+
closed: boolean;
|
|
129
|
+
violations: ScenarioViolation[];
|
|
130
|
+
additions: ScenarioAddition[];
|
|
131
|
+
/** The evaluated snapshot — assert business values on this in your test. */
|
|
132
|
+
spans: ScenarioSpan[];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Structural validation for one scenario declaration. Called by
|
|
136
|
+
* `defineContract()` so a malformed scenario throws at module load.
|
|
137
|
+
*/
|
|
138
|
+
declare function validateScenarioSpec(name: string, spec: ScenarioSpec): void;
|
|
139
|
+
/** Whether the scenario's completion boundary has closed for these spans. */
|
|
140
|
+
declare function isScenarioClosed(spec: ScenarioSpec, spans: readonly ScenarioSpan[]): boolean;
|
|
141
|
+
interface EvaluateScenarioOptions {
|
|
142
|
+
/** Name used in the result/messages. Defaults to `'scenario'`. */
|
|
143
|
+
name?: string;
|
|
144
|
+
/** Override closure detection (e.g. the poller already knows). */
|
|
145
|
+
closed?: boolean;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Pure three-state evaluation of collected spans against a scenario.
|
|
149
|
+
*
|
|
150
|
+
* Definitive at any time (no closure needed): an unexpected error status, a
|
|
151
|
+
* `max` cardinality exceeded. Meaningful only after closure: a missing event,
|
|
152
|
+
* a `min` cardinality not reached, a missing required edge.
|
|
153
|
+
*/
|
|
154
|
+
declare function evaluateScenario(spec: ScenarioSpec, spans: readonly ScenarioSpan[], options?: EvaluateScenarioOptions): ScenarioResult;
|
|
155
|
+
interface CheckScenarioOptions {
|
|
156
|
+
/** Name used in the result/messages. Defaults to `'scenario'`. */
|
|
157
|
+
name?: string;
|
|
158
|
+
/** Poll interval while waiting for closure. Default 25ms. */
|
|
159
|
+
pollIntervalMs?: number;
|
|
160
|
+
/** Override the boundary's observation budget (how long the checker waits). */
|
|
161
|
+
budgetMs?: number;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Poll `getSpans` until the scenario's completion boundary closes, a
|
|
165
|
+
* definitive violation appears (fail fast), or the observation budget is
|
|
166
|
+
* spent — then evaluate.
|
|
167
|
+
*
|
|
168
|
+
* The observation budget bounds how long *this checker* waits; it is not a
|
|
169
|
+
* statement that the operation is allowed to take that long. Express a
|
|
170
|
+
* business deadline as its own assertion on the returned spans.
|
|
171
|
+
*
|
|
172
|
+
* An `externally-reconciled` boundary never closes in-process: the check
|
|
173
|
+
* evaluates the current snapshot once and reports `incomplete` unless a
|
|
174
|
+
* definitive violation is already present.
|
|
175
|
+
*/
|
|
176
|
+
declare function checkScenario(spec: ScenarioSpec, getSpans: () => readonly ScenarioSpan[] | Promise<readonly ScenarioSpan[]>, options?: CheckScenarioOptions): Promise<ScenarioResult>;
|
|
177
|
+
/** Human-readable summary of a scenario result, for assertion messages. */
|
|
178
|
+
declare function formatScenarioResult(result: ScenarioResult): string;
|
|
179
|
+
interface ScenarioProposal {
|
|
180
|
+
scenario: ScenarioSpec;
|
|
181
|
+
/** Review annotations — what was observed and what to double-check. */
|
|
182
|
+
notes: string[];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Draft a scenario contract from repeated controlled runs (record → propose →
|
|
186
|
+
* commit). Events stable across every run become required with their observed
|
|
187
|
+
* cardinality; variable ones get a range and a review note. The draft is a
|
|
188
|
+
* starting point for human curation, not a finished contract.
|
|
189
|
+
*/
|
|
190
|
+
declare function proposeScenario(runs: ReadonlyArray<ReadonlyArray<ScenarioSpan>>, options?: {
|
|
191
|
+
name?: string;
|
|
192
|
+
}): ScenarioProposal;
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/contract.d.ts
|
|
195
|
+
/** Scalar and array attribute types permitted on a span (OTLP value shapes). */
|
|
196
|
+
type AttributeType = 'string' | 'number' | 'boolean' | 'string[]' | 'number[]' | 'boolean[]';
|
|
197
|
+
declare const ATTRIBUTE_TYPES: readonly AttributeType[];
|
|
198
|
+
/**
|
|
199
|
+
* Lifecycle of a span or attribute, mirroring how the OpenTelemetry semantic
|
|
200
|
+
* conventions stage their own surface. `stable` is a promise to agent readers
|
|
201
|
+
* that the name will not change without a major contract bump.
|
|
202
|
+
*/
|
|
203
|
+
type Stability = 'stable' | 'experimental' | 'deprecated';
|
|
204
|
+
declare const STABILITIES: readonly Stability[];
|
|
205
|
+
/** Declaration for a single attribute key on a span. */
|
|
206
|
+
interface AttributeSpec {
|
|
207
|
+
/** OTLP value shape. Validated at runtime against the emitted value. */
|
|
208
|
+
type: AttributeType;
|
|
209
|
+
/** Lifecycle stage. Defaults to `stable`. */
|
|
210
|
+
stability?: Stability;
|
|
211
|
+
/** When `true`, the attribute must be present on every matching span. */
|
|
212
|
+
required?: boolean;
|
|
213
|
+
/** Human/agent-facing description of what the attribute means. */
|
|
214
|
+
description?: string;
|
|
215
|
+
/**
|
|
216
|
+
* Marks an attribute as intentionally high-cardinality (user id, sender
|
|
217
|
+
* domain, request id). For an agent reader these are the single most useful
|
|
218
|
+
* fields on a trace, so {@link ./redaction.highCardinalityKeys} surfaces them
|
|
219
|
+
* as a *protect* list — telling redactors/normalizers NOT to strip them.
|
|
220
|
+
*/
|
|
221
|
+
highCardinality?: boolean;
|
|
222
|
+
/** Closed set of permitted values. Reported as `enum_violation` if exceeded. */
|
|
223
|
+
enum?: readonly (string | number)[];
|
|
224
|
+
/** Set when `stability: 'deprecated'`; explains what to use instead. */
|
|
225
|
+
replacedBy?: string;
|
|
226
|
+
/** Free-text note shown alongside deprecation warnings. */
|
|
227
|
+
deprecatedReason?: string;
|
|
228
|
+
}
|
|
229
|
+
/** Declaration for a single span name your service emits. */
|
|
230
|
+
interface SpanSpec {
|
|
231
|
+
/** Human/agent-facing description of when this span is produced. */
|
|
232
|
+
description?: string;
|
|
233
|
+
/** Lifecycle stage. Defaults to `stable`. */
|
|
234
|
+
stability?: Stability;
|
|
235
|
+
/** Attributes specific to this span, keyed by attribute name. */
|
|
236
|
+
attributes?: Record<string, AttributeSpec>;
|
|
237
|
+
/**
|
|
238
|
+
* When `true`, attributes not declared here are allowed without an
|
|
239
|
+
* `unknown_attribute` violation. Defaults to the contract-level setting.
|
|
240
|
+
*/
|
|
241
|
+
additionalAttributes?: boolean;
|
|
242
|
+
}
|
|
243
|
+
/** The full telemetry contract for one service. */
|
|
244
|
+
interface TelemetryContract {
|
|
245
|
+
/** `service.name` this contract describes. */
|
|
246
|
+
service: string;
|
|
247
|
+
/**
|
|
248
|
+
* Semver of the *contract itself* (not the app). Bumped when the trace
|
|
249
|
+
* surface changes; surfaced to readers as the `telemetry.schema.version`
|
|
250
|
+
* resource attribute via {@link ./attrs.SCHEMA_ATTRS}.
|
|
251
|
+
*/
|
|
252
|
+
version: string;
|
|
253
|
+
/** Spans this service emits, keyed by span name. */
|
|
254
|
+
spans: Record<string, SpanSpec>;
|
|
255
|
+
/** Attributes permitted on *any* span (e.g. `user.id`, `tenant.id`). */
|
|
256
|
+
commonAttributes?: Record<string, AttributeSpec>;
|
|
257
|
+
/**
|
|
258
|
+
* Default for `SpanSpec.additionalAttributes` when a span does not set it.
|
|
259
|
+
* Defaults to `false` (declared-only — the stricter, agent-friendlier mode).
|
|
260
|
+
*/
|
|
261
|
+
additionalAttributes?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Flow-level scenario contracts, keyed by scenario name: which events one
|
|
264
|
+
* exercised flow must emit, their cardinality and topology, and when the
|
|
265
|
+
* observation is complete. Checked with `checkScenario` ({@link ./scenario}).
|
|
266
|
+
*/
|
|
267
|
+
scenarios?: Record<string, ScenarioSpec>;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Validate and freeze a telemetry contract. Throws on structural mistakes
|
|
271
|
+
* (bad semver, unknown attribute type, deprecation with no replacement) so the
|
|
272
|
+
* contract fails loudly at module load, not silently at runtime.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* export const contract = defineContract({
|
|
277
|
+
* service: 'checkout',
|
|
278
|
+
* version: '1.2.0',
|
|
279
|
+
* commonAttributes: {
|
|
280
|
+
* 'user.id': { type: 'string', highCardinality: true, description: 'Authenticated user' },
|
|
281
|
+
* },
|
|
282
|
+
* spans: {
|
|
283
|
+
* 'checkout.charge': {
|
|
284
|
+
* description: 'Charge a payment method',
|
|
285
|
+
* attributes: {
|
|
286
|
+
* 'payment.provider': { type: 'string', required: true, enum: ['stripe', 'paypal'] },
|
|
287
|
+
* 'payment.amount_cents': { type: 'number', required: true },
|
|
288
|
+
* },
|
|
289
|
+
* },
|
|
290
|
+
* },
|
|
291
|
+
* });
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
declare function defineContract(contract: TelemetryContract): TelemetryContract;
|
|
295
|
+
/**
|
|
296
|
+
* Resolve the effective attribute spec for `key` on `spanName`: span-specific
|
|
297
|
+
* attributes win over common attributes. Returns `undefined` when the key is
|
|
298
|
+
* declared nowhere.
|
|
299
|
+
*/
|
|
300
|
+
declare function resolveAttributeSpec(contract: TelemetryContract, spanName: string, key: string): AttributeSpec | undefined;
|
|
301
|
+
/** Whether attributes outside the declared set are tolerated for a span. */
|
|
302
|
+
declare function allowsAdditionalAttributes(contract: TelemetryContract, spanName: string): boolean;
|
|
303
|
+
//#endregion
|
|
304
|
+
export { validateScenarioSpec as A, ScenarioViolationCode as C, isScenarioClosed as D, formatScenarioResult as E, parseCardinality as O, ScenarioViolation as S, evaluateScenario as T, ScenarioOutcome as _, SpanSpec as a, ScenarioSpan as b, allowsAdditionalAttributes as c, Cardinality as d, CheckScenarioOptions as f, ScenarioEventSpec as g, ScenarioAddition as h, STABILITIES as i, proposeScenario as k, defineContract as l, EvaluateScenarioOptions as m, AttributeSpec as n, Stability as o, CompletionBoundary as p, AttributeType as r, TelemetryContract as s, ATTRIBUTE_TYPES as t, resolveAttributeSpec as u, ScenarioProposal as v, checkScenario as w, ScenarioSpec as x, ScenarioResult as y };
|
|
305
|
+
//# sourceMappingURL=contract-Ymh_Q37N.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-Ymh_Q37N.d.ts","names":[],"sources":["../src/scenario.ts","../src/contract.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAyCiB;EACf;EACA;EACA;EACA;EACA,aAAa;;EAEb;EACA;;;UAIe;EACf;EACA;;;;;;iBAOc,iBAAiB,gBAAgB,cAAc;;UAmC9C;;EAEf,uBAAuB;;;;;EAKvB;EACA;;;;;;;;;;KAWU;EACN;EAA0B;;EAC1B;EAAwB;EAAe;;EACvC;EAA+B;;;UAGpB;EACf;;EAEA,YAAY;;EAEZ,QAAQ,eAAe;;;;;;EAMvB,QAAQ;;EAER,gBAAgB;;KAGN;KAEA;;UAOK;EACf,MAAM;EACN;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;;UAGe;EACf;EACA,SAAS;;EAET;EACA,YAAY;EACZ,WAAW;;EAEX,OAAO;;;;;;iBAmBO,qBAAqB,cAAc,MAAM;;iBA8DzC,iBACd,MAAM,cACN,gBAAgB;UAgCD;;EAEf;;EAEA;;;;;;;;;iBAUc,iBACd,MAAM,cACN,gBAAgB,gBAChB,UAAU,0BACT;UA0Fc;;EAEf;;EAEA;;EAEA;;;;;;;;;;;;;;;iBAgBoB,cACpB,MAAM,cACN,yBAAyB,iBAAiB,iBAAiB,iBAC3D,UAAU,uBACT,QAAQ;;iBAkDK,qBAAqB,QAAQ;UAS5B;EACf,UAAU;;EAEV;;;;;;;;iBASc,gBACd,MAAM,cAAc,cAAc,gBAClC;EAAY;IACX;;;;KCxdS;cAGC,0BAA0B;;;;;;KAc3B;cAEC,sBAAsB;;UAOlB;;EAEf,MAAM;;EAEN,YAAY;;EAEZ;;EAEA;;;;;;;EAOA;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA,YAAY;;EAEZ,aAAa,eAAe;;;;;EAK5B;;;UAIe;;EAEf;;;;;;EAMA;;EAEA,OAAO,eAAe;;EAEtB,mBAAmB,eAAe;;;;;EAKlC;;;;;;EAMA,YAAY,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiEb,eAAe,UAAU,oBAAoB;;;;;;iBAwC7C,qBACd,UAAU,mBACV,kBACA,cACC;;iBAQa,2BACd,UAAU,mBACV"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { o as Stability, r as AttributeType, s as TelemetryContract } from "./contract-
|
|
2
|
-
|
|
1
|
+
import { o as Stability, r as AttributeType, s as TelemetryContract } from "./contract-Ymh_Q37N.js";
|
|
3
2
|
//#region src/attrs.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Wire constants for the schema contract — the keys autotel-schema reads from
|
|
@@ -13,7 +12,9 @@ import { o as Stability, r as AttributeType, s as TelemetryContract } from "./co
|
|
|
13
12
|
* between "confidently correct" and "confidently wrong" after a rename.
|
|
14
13
|
*/
|
|
15
14
|
declare const SCHEMA_ATTRS: {
|
|
16
|
-
/** The service this contract describes (mirrors `service.name`). */
|
|
15
|
+
/** The service this contract describes (mirrors `service.name`). */
|
|
16
|
+
readonly SERVICE: "telemetry.schema.service";
|
|
17
|
+
/** Semver of the telemetry contract that produced this span. */
|
|
17
18
|
readonly VERSION: "telemetry.schema.version";
|
|
18
19
|
};
|
|
19
20
|
type SchemaAttributeKey = (typeof SCHEMA_ATTRS)[keyof typeof SCHEMA_ATTRS];
|
|
@@ -86,4 +87,4 @@ declare function hasBreakingChanges(diff: SnapshotDiff): boolean;
|
|
|
86
87
|
declare function formatDiff(diff: SnapshotDiff): string;
|
|
87
88
|
//#endregion
|
|
88
89
|
export { diffSnapshots as a, ContractSnapshot as c, contractToSnapshot as d, parseSnapshot as f, SchemaAttributeKey as g, SNAPSHOT_SPEC as h, SnapshotDiff as i, SnapshotAttribute as l, SCHEMA_ATTRS as m, ChangeType as n, formatDiff as o, serializeSnapshot as p, SnapshotChange as r, hasBreakingChanges as s, ChangeKind as t, SnapshotSpan as u };
|
|
89
|
-
//# sourceMappingURL=diff-
|
|
90
|
+
//# sourceMappingURL=diff-CAIC04O4.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-CAIC04O4.d.ts","names":[],"sources":["../src/attrs.ts","../src/snapshot.ts","../src/diff.ts"],"mappings":";;;;;;;;;;;;;cAYa;;WAAA;;WAAA;;KAOD,6BACF,2BAA2B;;cAGxB;;;;UCPI;EACf,MAAM;EACN,WAAW;EACX;EACA;EACA;EACA;EACA;;UAGe;EACf,WAAW;EACX;EACA;EACA,YAAY,eAAe;;;UAIZ;EACf,aAAa;EACb;EACA;EACA,kBAAkB,eAAe;EACjC,OAAO,eAAe;;;;;;;iBA6BR,mBACd,UAAU,oBACT;;iBAgCa,kBAAkB,UAAU;;iBAK5B,cAAc,eAAe;;;KC/FjC;KAEA;UAeK;EACf,MAAM;EACN,MAAM;;EAEN;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,UAAU;EACV,UAAU;EACV,SAAS;;;;;;iBAuKK,cACd,UAAU,kBACV,MAAM,mBACL;;iBA6Ca,mBAAmB,MAAM;;iBAKzB,WAAW,MAAM"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { o as Stability, r as AttributeType, s as TelemetryContract } from "./contract-
|
|
2
|
-
|
|
1
|
+
import { o as Stability, r as AttributeType, s as TelemetryContract } from "./contract-Ymh_Q37N.cjs";
|
|
3
2
|
//#region src/attrs.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Wire constants for the schema contract — the keys autotel-schema reads from
|
|
@@ -13,7 +12,9 @@ import { o as Stability, r as AttributeType, s as TelemetryContract } from "./co
|
|
|
13
12
|
* between "confidently correct" and "confidently wrong" after a rename.
|
|
14
13
|
*/
|
|
15
14
|
declare const SCHEMA_ATTRS: {
|
|
16
|
-
/** The service this contract describes (mirrors `service.name`). */
|
|
15
|
+
/** The service this contract describes (mirrors `service.name`). */
|
|
16
|
+
readonly SERVICE: "telemetry.schema.service";
|
|
17
|
+
/** Semver of the telemetry contract that produced this span. */
|
|
17
18
|
readonly VERSION: "telemetry.schema.version";
|
|
18
19
|
};
|
|
19
20
|
type SchemaAttributeKey = (typeof SCHEMA_ATTRS)[keyof typeof SCHEMA_ATTRS];
|
|
@@ -86,4 +87,4 @@ declare function hasBreakingChanges(diff: SnapshotDiff): boolean;
|
|
|
86
87
|
declare function formatDiff(diff: SnapshotDiff): string;
|
|
87
88
|
//#endregion
|
|
88
89
|
export { diffSnapshots as a, ContractSnapshot as c, contractToSnapshot as d, parseSnapshot as f, SchemaAttributeKey as g, SNAPSHOT_SPEC as h, SnapshotDiff as i, SnapshotAttribute as l, SCHEMA_ATTRS as m, ChangeType as n, formatDiff as o, serializeSnapshot as p, SnapshotChange as r, hasBreakingChanges as s, ChangeKind as t, SnapshotSpan as u };
|
|
89
|
-
//# sourceMappingURL=diff-
|
|
90
|
+
//# sourceMappingURL=diff-CfvhW7ux.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-CfvhW7ux.d.cts","names":[],"sources":["../src/attrs.ts","../src/snapshot.ts","../src/diff.ts"],"mappings":";;;;;;;;;;;;;cAYa;;WAAA;;WAAA;;KAOD,6BACF,2BAA2B;;cAGxB;;;;UCPI;EACf,MAAM;EACN,WAAW;EACX;EACA;EACA;EACA;EACA;;UAGe;EACf,WAAW;EACX;EACA;EACA,YAAY,eAAe;;;UAIZ;EACf,aAAa;EACb;EACA;EACA,kBAAkB,eAAe;EACjC,OAAO,eAAe;;;;;;;iBA6BR,mBACd,UAAU,oBACT;;iBAgCa,kBAAkB,UAAU;;iBAK5B,cAAc,eAAe;;;KC/FjC;KAEA;UAeK;EACf,MAAM;EACN,MAAM;;EAEN;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,UAAU;EACV,UAAU;EACV,SAAS;;;;;;iBAuKK,cACd,UAAU,kBACV,MAAM,mBACL;;iBA6Ca,mBAAmB,MAAM;;iBAKzB,WAAW,MAAM"}
|
package/dist/diff.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.cjs","names":[],"sources":["../src/diff.ts"],"sourcesContent":["/**\n * Snapshot diffing — the CI gate that catches breaking changes to your trace\n * surface before they ship.\n *\n * \"If you wouldn't ship a rename to your public API without a changelog, don't\n * do it to your traces.\" This module is what makes that enforceable: classify\n * every change between two snapshots as breaking, additive, or neutral, and let\n * CI fail on the breaking ones.\n */\n\nimport type { ContractSnapshot, SnapshotAttribute } from './snapshot.js';\n\nexport type ChangeKind = 'breaking' | 'additive' | 'neutral';\n\nexport type ChangeType =\n | 'span_removed'\n | 'span_added'\n | 'attribute_removed'\n | 'attribute_added'\n | 'type_changed'\n | 'required_added'\n | 'required_removed'\n | 'enum_value_removed'\n | 'enum_value_added'\n | 'stability_downgraded'\n | 'stability_advanced'\n | 'deprecated'\n | 'replacement_documented';\n\nexport interface SnapshotChange {\n kind: ChangeKind;\n type: ChangeType;\n /** Span the change applies to (`*` = common attributes / contract-wide). */\n span: string;\n attribute?: string;\n message: string;\n}\n\nexport interface SnapshotDiff {\n service: string;\n previousVersion: string;\n nextVersion: string;\n breaking: SnapshotChange[];\n additive: SnapshotChange[];\n neutral: SnapshotChange[];\n}\n\n/**\n * How every cross-stability transition is classified. Keyed `prev->next` so all\n * six transitions are explicit and auditable — no silent fall-through. Same-\n * stability transitions are absent (no change to report).\n */\nconst STABILITY_TRANSITIONS: Record<\n string,\n { kind: ChangeKind; type: ChangeType }\n> = {\n 'stable->experimental': { kind: 'breaking', type: 'stability_downgraded' },\n 'stable->deprecated': { kind: 'additive', type: 'deprecated' },\n 'experimental->stable': { kind: 'neutral', type: 'stability_advanced' },\n 'experimental->deprecated': { kind: 'additive', type: 'deprecated' },\n 'deprecated->stable': { kind: 'neutral', type: 'stability_advanced' },\n 'deprecated->experimental': { kind: 'breaking', type: 'stability_downgraded' },\n};\n\nfunction stabilityMessage(\n type: ChangeType,\n attribute: string,\n prev: SnapshotAttribute,\n next: SnapshotAttribute,\n): string {\n if (type === 'deprecated') {\n return `attribute \"${attribute}\" was deprecated${next.replacedBy ? ` (use \"${next.replacedBy}\")` : ''}`;\n }\n if (type === 'stability_downgraded') {\n return `attribute \"${attribute}\" stability downgraded ${prev.stability} → ${next.stability}`;\n }\n return `attribute \"${attribute}\" promoted ${prev.stability} → ${next.stability}`;\n}\n\nfunction push(\n diff: SnapshotDiff,\n change: SnapshotChange,\n): void {\n if (change.kind === 'breaking') diff.breaking.push(change);\n else if (change.kind === 'additive') diff.additive.push(change);\n else diff.neutral.push(change);\n}\n\nfunction diffAttribute(\n diff: SnapshotDiff,\n span: string,\n attribute: string,\n prev: SnapshotAttribute,\n next: SnapshotAttribute,\n): void {\n if (prev.type !== next.type) {\n push(diff, {\n kind: 'breaking',\n type: 'type_changed',\n span,\n attribute,\n message: `attribute \"${attribute}\" changed type ${prev.type} → ${next.type}`,\n });\n }\n\n if (!prev.required && next.required) {\n push(diff, {\n kind: 'breaking',\n type: 'required_added',\n span,\n attribute,\n message: `attribute \"${attribute}\" became required`,\n });\n } else if (prev.required && !next.required) {\n push(diff, {\n kind: 'additive',\n type: 'required_removed',\n span,\n attribute,\n message: `attribute \"${attribute}\" is no longer required`,\n });\n }\n\n // Enum: removing a permitted value can break a producer that still emits it.\n if (prev.enum && next.enum) {\n const nextSet = new Set(next.enum);\n const removed = prev.enum.filter((v) => !nextSet.has(v));\n const prevSet = new Set(prev.enum);\n const added = next.enum.filter((v) => !prevSet.has(v));\n if (removed.length > 0) {\n push(diff, {\n kind: 'breaking',\n type: 'enum_value_removed',\n span,\n attribute,\n message: `attribute \"${attribute}\" dropped enum value(s) ${JSON.stringify(removed)}`,\n });\n }\n if (added.length > 0) {\n push(diff, {\n kind: 'additive',\n type: 'enum_value_added',\n span,\n attribute,\n message: `attribute \"${attribute}\" added enum value(s) ${JSON.stringify(added)}`,\n });\n }\n }\n\n if (prev.stability !== next.stability) {\n const transition =\n STABILITY_TRANSITIONS[`${prev.stability}->${next.stability}`];\n if (transition) {\n push(diff, {\n ...transition,\n span,\n attribute,\n message: stabilityMessage(transition.type, attribute, prev, next),\n });\n }\n }\n}\n\nfunction diffAttributeMaps(\n diff: SnapshotDiff,\n span: string,\n prev: Record<string, SnapshotAttribute>,\n next: Record<string, SnapshotAttribute>,\n): void {\n for (const [key, prevAttr] of Object.entries(prev)) {\n const nextAttr = next[key];\n if (!nextAttr) {\n // A removed attribute whose replacement is named is a documented\n // migration (still breaking — but reported as such with the pointer).\n push(diff, {\n kind: 'breaking',\n type: prevAttr.replacedBy ? 'replacement_documented' : 'attribute_removed',\n span,\n attribute: key,\n message: prevAttr.replacedBy\n ? `attribute \"${key}\" removed — replaced by \"${prevAttr.replacedBy}\"`\n : `attribute \"${key}\" was removed`,\n });\n continue;\n }\n diffAttribute(diff, span, key, prevAttr, nextAttr);\n }\n for (const key of Object.keys(next)) {\n if (!prev[key]) {\n const added = next[key];\n // Always `attribute_added` (the event is \"new attribute\"); severity rides\n // on `kind` — a new *required* attribute breaks existing producers.\n push(diff, {\n kind: added.required ? 'breaking' : 'additive',\n type: 'attribute_added',\n span,\n attribute: key,\n message: added.required\n ? `new required attribute \"${key}\" added`\n : `new attribute \"${key}\" added`,\n });\n }\n }\n}\n\n/**\n * Diff two snapshots, classifying every change. The `breaking` array is what a\n * CI gate keys off; `hasBreakingChanges()` is the convenience predicate.\n */\nexport function diffSnapshots(\n previous: ContractSnapshot,\n next: ContractSnapshot,\n): SnapshotDiff {\n const diff: SnapshotDiff = {\n service: next.service,\n previousVersion: previous.version,\n nextVersion: next.version,\n breaking: [],\n additive: [],\n neutral: [],\n };\n\n diffAttributeMaps(diff, '*', previous.commonAttributes, next.commonAttributes);\n\n for (const [name, prevSpan] of Object.entries(previous.spans)) {\n const nextSpan = next.spans[name];\n if (!nextSpan) {\n push(diff, {\n kind: 'breaking',\n type: 'span_removed',\n span: name,\n message: `span \"${name}\" was removed`,\n });\n continue;\n }\n diffAttributeMaps(diff, name, prevSpan.attributes, nextSpan.attributes);\n }\n for (const name of Object.keys(next.spans)) {\n if (!previous.spans[name]) {\n push(diff, {\n kind: 'additive',\n type: 'span_added',\n span: name,\n message: `new span \"${name}\" added`,\n });\n }\n }\n\n return diff;\n}\n\n/** `true` when the diff contains at least one breaking change. */\nexport function hasBreakingChanges(diff: SnapshotDiff): boolean {\n return diff.breaking.length > 0;\n}\n\n/** Markdown rendering of a diff — for CI logs and PR comments. */\nexport function formatDiff(diff: SnapshotDiff): string {\n const lines: string[] = [ \n `# Telemetry contract diff: ${diff.service} ${diff.previousVersion} → ${diff.nextVersion}`,\n ''];\n const section = (title: string, changes: SnapshotChange[]) => {\n if (changes.length === 0) return;\n lines.push(`## ${title} (${changes.length})`, '');\n for (const c of changes) {\n const where = c.attribute ? `\\`${c.span}.${c.attribute}\\`` : `\\`${c.span}\\``;\n lines.push(`- ${where}: ${c.message}`);\n }\n lines.push('');\n };\n section('💥 Breaking', diff.breaking);\n section('➕ Additive', diff.additive);\n section('• Neutral', diff.neutral);\n if (\n diff.breaking.length === 0 &&\n diff.additive.length === 0 &&\n diff.neutral.length === 0\n ) {\n lines.push('No changes to the telemetry contract.', '');\n }\n return lines.join('\\n');\n}\n"],"mappings":";;;;;;;;AAoDA,MAAM,wBAGF;CACF,wBAAwB;EAAE,MAAM;EAAY,MAAM;CAAuB;CACzE,sBAAsB;EAAE,MAAM;EAAY,MAAM;CAAa;CAC7D,wBAAwB;EAAE,MAAM;EAAW,MAAM;CAAqB;CACtE,4BAA4B;EAAE,MAAM;EAAY,MAAM;CAAa;CACnE,sBAAsB;EAAE,MAAM;EAAW,MAAM;CAAqB;CACpE,4BAA4B;EAAE,MAAM;EAAY,MAAM;CAAuB;AAC/E;AAEA,SAAS,iBACP,MACA,WACA,MACA,MACQ;CACR,IAAI,SAAS,cACX,OAAO,cAAc,UAAU,kBAAkB,KAAK,aAAa,UAAU,KAAK,WAAW,MAAM;CAErG,IAAI,SAAS,wBACX,OAAO,cAAc,UAAU,yBAAyB,KAAK,UAAU,KAAK,KAAK;CAEnF,OAAO,cAAc,UAAU,aAAa,KAAK,UAAU,KAAK,KAAK;AACvE;AAEA,SAAS,KACP,MACA,QACM;CACN,IAAI,OAAO,SAAS,YAAY,KAAK,SAAS,KAAK,MAAM;MACpD,IAAI,OAAO,SAAS,YAAY,KAAK,SAAS,KAAK,MAAM;MACzD,KAAK,QAAQ,KAAK,MAAM;AAC/B;AAEA,SAAS,cACP,MACA,MACA,WACA,MACA,MACM;CACN,IAAI,KAAK,SAAS,KAAK,MACrB,KAAK,MAAM;EACT,MAAM;EACN,MAAM;EACN;EACA;EACA,SAAS,cAAc,UAAU,iBAAiB,KAAK,KAAK,KAAK,KAAK;CACxE,CAAC;CAGH,IAAI,CAAC,KAAK,YAAY,KAAK,UACzB,KAAK,MAAM;EACT,MAAM;EACN,MAAM;EACN;EACA;EACA,SAAS,cAAc,UAAU;CACnC,CAAC;MACI,IAAI,KAAK,YAAY,CAAC,KAAK,UAChC,KAAK,MAAM;EACT,MAAM;EACN,MAAM;EACN;EACA;EACA,SAAS,cAAc,UAAU;C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GAAG,EAAE,UAAU,MAAM,KAAK,EAAE,KAAK;GACzE,MAAM,KAAK,KAAK,MAAM,IAAI,EAAE,SAAS;EACvC;EACA,MAAM,KAAK,EAAE;CACf;CACA,QAAQ,eAAe,KAAK,QAAQ;CACpC,QAAQ,cAAc,KAAK,QAAQ;CACnC,QAAQ,aAAa,KAAK,OAAO;CACjC,IACE,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,WAAW,KACzB,KAAK,QAAQ,WAAW,GAExB,MAAM,KAAK,yCAAyC,EAAE;CAExD,OAAO,MAAM,KAAK,IAAI;AACxB"}
|
|
1
|
+
{"version":3,"file":"diff.cjs","names":[],"sources":["../src/diff.ts"],"sourcesContent":["/**\n * Snapshot diffing — the CI gate that catches breaking changes to your trace\n * surface before they ship.\n *\n * \"If you wouldn't ship a rename to your public API without a changelog, don't\n * do it to your traces.\" This module is what makes that enforceable: classify\n * every change between two snapshots as breaking, additive, or neutral, and let\n * CI fail on the breaking ones.\n */\n\nimport type { ContractSnapshot, SnapshotAttribute } from './snapshot.js';\n\nexport type ChangeKind = 'breaking' | 'additive' | 'neutral';\n\nexport type ChangeType =\n | 'span_removed'\n | 'span_added'\n | 'attribute_removed'\n | 'attribute_added'\n | 'type_changed'\n | 'required_added'\n | 'required_removed'\n | 'enum_value_removed'\n | 'enum_value_added'\n | 'stability_downgraded'\n | 'stability_advanced'\n | 'deprecated'\n | 'replacement_documented';\n\nexport interface SnapshotChange {\n kind: ChangeKind;\n type: ChangeType;\n /** Span the change applies to (`*` = common attributes / contract-wide). */\n span: string;\n attribute?: string;\n message: string;\n}\n\nexport interface SnapshotDiff {\n service: string;\n previousVersion: string;\n nextVersion: string;\n breaking: SnapshotChange[];\n additive: SnapshotChange[];\n neutral: SnapshotChange[];\n}\n\n/**\n * How every cross-stability transition is classified. Keyed `prev->next` so all\n * six transitions are explicit and auditable — no silent fall-through. Same-\n * stability transitions are absent (no change to report).\n */\nconst STABILITY_TRANSITIONS: Record<\n string,\n { kind: ChangeKind; type: ChangeType }\n> = {\n 'stable->experimental': { kind: 'breaking', type: 'stability_downgraded' },\n 'stable->deprecated': { kind: 'additive', type: 'deprecated' },\n 'experimental->stable': { kind: 'neutral', type: 'stability_advanced' },\n 'experimental->deprecated': { kind: 'additive', type: 'deprecated' },\n 'deprecated->stable': { kind: 'neutral', type: 'stability_advanced' },\n 'deprecated->experimental': {\n kind: 'breaking',\n type: 'stability_downgraded',\n },\n};\n\nfunction stabilityMessage(\n type: ChangeType,\n attribute: string,\n prev: SnapshotAttribute,\n next: SnapshotAttribute,\n): string {\n if (type === 'deprecated') {\n return `attribute \"${attribute}\" was deprecated${next.replacedBy ? ` (use \"${next.replacedBy}\")` : ''}`;\n }\n if (type === 'stability_downgraded') {\n return `attribute \"${attribute}\" stability downgraded ${prev.stability} → ${next.stability}`;\n }\n return `attribute \"${attribute}\" promoted ${prev.stability} → ${next.stability}`;\n}\n\nfunction push(diff: SnapshotDiff, change: SnapshotChange): void {\n if (change.kind === 'breaking') diff.breaking.push(change);\n else if (change.kind === 'additive') diff.additive.push(change);\n else diff.neutral.push(change);\n}\n\nfunction diffAttribute(\n diff: SnapshotDiff,\n span: string,\n attribute: string,\n prev: SnapshotAttribute,\n next: SnapshotAttribute,\n): void {\n if (prev.type !== next.type) {\n push(diff, {\n kind: 'breaking',\n type: 'type_changed',\n span,\n attribute,\n message: `attribute \"${attribute}\" changed type ${prev.type} → ${next.type}`,\n });\n }\n\n if (!prev.required && next.required) {\n push(diff, {\n kind: 'breaking',\n type: 'required_added',\n span,\n attribute,\n message: `attribute \"${attribute}\" became required`,\n });\n } else if (prev.required && !next.required) {\n push(diff, {\n kind: 'additive',\n type: 'required_removed',\n span,\n attribute,\n message: `attribute \"${attribute}\" is no longer required`,\n });\n }\n\n // Enum: removing a permitted value can break a producer that still emits it.\n if (prev.enum && next.enum) {\n const nextSet = new Set(next.enum);\n const removed = prev.enum.filter((v) => !nextSet.has(v));\n const prevSet = new Set(prev.enum);\n const added = next.enum.filter((v) => !prevSet.has(v));\n if (removed.length > 0) {\n push(diff, {\n kind: 'breaking',\n type: 'enum_value_removed',\n span,\n attribute,\n message: `attribute \"${attribute}\" dropped enum value(s) ${JSON.stringify(removed)}`,\n });\n }\n if (added.length > 0) {\n push(diff, {\n kind: 'additive',\n type: 'enum_value_added',\n span,\n attribute,\n message: `attribute \"${attribute}\" added enum value(s) ${JSON.stringify(added)}`,\n });\n }\n }\n\n if (prev.stability !== next.stability) {\n const transition =\n STABILITY_TRANSITIONS[`${prev.stability}->${next.stability}`];\n if (transition) {\n push(diff, {\n ...transition,\n span,\n attribute,\n message: stabilityMessage(transition.type, attribute, prev, next),\n });\n }\n }\n}\n\nfunction diffAttributeMaps(\n diff: SnapshotDiff,\n span: string,\n prev: Record<string, SnapshotAttribute>,\n next: Record<string, SnapshotAttribute>,\n): void {\n for (const [key, prevAttr] of Object.entries(prev)) {\n const nextAttr = next[key];\n if (!nextAttr) {\n // A removed attribute whose replacement is named is a documented\n // migration (still breaking — but reported as such with the pointer).\n push(diff, {\n kind: 'breaking',\n type: prevAttr.replacedBy\n ? 'replacement_documented'\n : 'attribute_removed',\n span,\n attribute: key,\n message: prevAttr.replacedBy\n ? `attribute \"${key}\" removed — replaced by \"${prevAttr.replacedBy}\"`\n : `attribute \"${key}\" was removed`,\n });\n continue;\n }\n diffAttribute(diff, span, key, prevAttr, nextAttr);\n }\n for (const key of Object.keys(next)) {\n if (!prev[key]) {\n const added = next[key];\n // Always `attribute_added` (the event is \"new attribute\"); severity rides\n // on `kind` — a new *required* attribute breaks existing producers.\n push(diff, {\n kind: added.required ? 'breaking' : 'additive',\n type: 'attribute_added',\n span,\n attribute: key,\n message: added.required\n ? `new required attribute \"${key}\" added`\n : `new attribute \"${key}\" added`,\n });\n }\n }\n}\n\n/**\n * Diff two snapshots, classifying every change. The `breaking` array is what a\n * CI gate keys off; `hasBreakingChanges()` is the convenience predicate.\n */\nexport function diffSnapshots(\n previous: ContractSnapshot,\n next: ContractSnapshot,\n): SnapshotDiff {\n const diff: SnapshotDiff = {\n service: next.service,\n previousVersion: previous.version,\n nextVersion: next.version,\n breaking: [],\n additive: [],\n neutral: [],\n };\n\n diffAttributeMaps(\n diff,\n '*',\n previous.commonAttributes,\n next.commonAttributes,\n );\n\n for (const [name, prevSpan] of Object.entries(previous.spans)) {\n const nextSpan = next.spans[name];\n if (!nextSpan) {\n push(diff, {\n kind: 'breaking',\n type: 'span_removed',\n span: name,\n message: `span \"${name}\" was removed`,\n });\n continue;\n }\n diffAttributeMaps(diff, name, prevSpan.attributes, nextSpan.attributes);\n }\n for (const name of Object.keys(next.spans)) {\n if (!previous.spans[name]) {\n push(diff, {\n kind: 'additive',\n type: 'span_added',\n span: name,\n message: `new span \"${name}\" added`,\n });\n }\n }\n\n return diff;\n}\n\n/** `true` when the diff contains at least one breaking change. */\nexport function hasBreakingChanges(diff: SnapshotDiff): boolean {\n return diff.breaking.length > 0;\n}\n\n/** Markdown rendering of a diff — for CI logs and PR comments. */\nexport function formatDiff(diff: SnapshotDiff): string {\n const lines: string[] = [\n `# Telemetry contract diff: ${diff.service} ${diff.previousVersion} → ${diff.nextVersion}`,\n '',\n ];\n const section = (title: string, changes: SnapshotChange[]) => {\n if (changes.length === 0) return;\n lines.push(`## ${title} (${changes.length})`, '');\n for (const c of changes) {\n const where = c.attribute\n ? `\\`${c.span}.${c.attribute}\\``\n : `\\`${c.span}\\``;\n lines.push(`- ${where}: ${c.message}`);\n }\n lines.push('');\n };\n section('💥 Breaking', diff.breaking);\n section('➕ Additive', diff.additive);\n section('• Neutral', diff.neutral);\n if (\n diff.breaking.length === 0 &&\n diff.additive.length === 0 &&\n diff.neutral.length === 0\n ) {\n lines.push('No changes to the telemetry contract.', '');\n }\n return lines.join('\\n');\n}\n"],"mappings":";;;;;;;;AAoDA,MAAM,wBAGF;CACF,wBAAwB;EAAE,MAAM;EAAY,MAAM;CAAuB;CACzE,sBAAsB;EAAE,MAAM;EAAY,MAAM;CAAa;CAC7D,wBAAw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jC,IACE,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,WAAW,KACzB,KAAK,QAAQ,WAAW,GAExB,MAAM,KAAK,yCAAyC,EAAE;CAExD,OAAO,MAAM,KAAK,IAAI;AACxB"}
|
package/dist/diff.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as diffSnapshots, i as SnapshotDiff, n as ChangeType, o as formatDiff, r as SnapshotChange, s as hasBreakingChanges, t as ChangeKind } from "./diff-
|
|
1
|
+
import { a as diffSnapshots, i as SnapshotDiff, n as ChangeType, o as formatDiff, r as SnapshotChange, s as hasBreakingChanges, t as ChangeKind } from "./diff-CfvhW7ux.cjs";
|
|
2
2
|
export { ChangeKind, ChangeType, SnapshotChange, SnapshotDiff, diffSnapshots, formatDiff, hasBreakingChanges };
|
package/dist/diff.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as diffSnapshots, i as SnapshotDiff, n as ChangeType, o as formatDiff, r as SnapshotChange, s as hasBreakingChanges, t as ChangeKind } from "./diff-
|
|
1
|
+
import { a as diffSnapshots, i as SnapshotDiff, n as ChangeType, o as formatDiff, r as SnapshotChange, s as hasBreakingChanges, t as ChangeKind } from "./diff-CAIC04O4.js";
|
|
2
2
|
export { ChangeKind, ChangeType, SnapshotChange, SnapshotDiff, diffSnapshots, formatDiff, hasBreakingChanges };
|
package/dist/diff.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.js","names":[],"sources":["../src/diff.ts"],"sourcesContent":["/**\n * Snapshot diffing — the CI gate that catches breaking changes to your trace\n * surface before they ship.\n *\n * \"If you wouldn't ship a rename to your public API without a changelog, don't\n * do it to your traces.\" This module is what makes that enforceable: classify\n * every change between two snapshots as breaking, additive, or neutral, and let\n * CI fail on the breaking ones.\n */\n\nimport type { ContractSnapshot, SnapshotAttribute } from './snapshot.js';\n\nexport type ChangeKind = 'breaking' | 'additive' | 'neutral';\n\nexport type ChangeType =\n | 'span_removed'\n | 'span_added'\n | 'attribute_removed'\n | 'attribute_added'\n | 'type_changed'\n | 'required_added'\n | 'required_removed'\n | 'enum_value_removed'\n | 'enum_value_added'\n | 'stability_downgraded'\n | 'stability_advanced'\n | 'deprecated'\n | 'replacement_documented';\n\nexport interface SnapshotChange {\n kind: ChangeKind;\n type: ChangeType;\n /** Span the change applies to (`*` = common attributes / contract-wide). */\n span: string;\n attribute?: string;\n message: string;\n}\n\nexport interface SnapshotDiff {\n service: string;\n previousVersion: string;\n nextVersion: string;\n breaking: SnapshotChange[];\n additive: SnapshotChange[];\n neutral: SnapshotChange[];\n}\n\n/**\n * How every cross-stability transition is classified. Keyed `prev->next` so all\n * six transitions are explicit and auditable — no silent fall-through. Same-\n * stability transitions are absent (no change to report).\n */\nconst STABILITY_TRANSITIONS: Record<\n string,\n { kind: ChangeKind; type: ChangeType }\n> = {\n 'stable->experimental': { kind: 'breaking', type: 'stability_downgraded' },\n 'stable->deprecated': { kind: 'additive', type: 'deprecated' },\n 'experimental->stable': { kind: 'neutral', type: 'stability_advanced' },\n 'experimental->deprecated': { kind: 'additive', type: 'deprecated' },\n 'deprecated->stable': { kind: 'neutral', type: 'stability_advanced' },\n 'deprecated->experimental': { kind: 'breaking', type: 'stability_downgraded' },\n};\n\nfunction stabilityMessage(\n type: ChangeType,\n attribute: string,\n prev: SnapshotAttribute,\n next: SnapshotAttribute,\n): string {\n if (type === 'deprecated') {\n return `attribute \"${attribute}\" was deprecated${next.replacedBy ? ` (use \"${next.replacedBy}\")` : ''}`;\n }\n if (type === 'stability_downgraded') {\n return `attribute \"${attribute}\" stability downgraded ${prev.stability} → ${next.stability}`;\n }\n return `attribute \"${attribute}\" promoted ${prev.stability} → ${next.stability}`;\n}\n\nfunction push(\n diff: SnapshotDiff,\n change: SnapshotChange,\n): void {\n if (change.kind === 'breaking') diff.breaking.push(change);\n else if (change.kind === 'additive') diff.additive.push(change);\n else diff.neutral.push(change);\n}\n\nfunction diffAttribute(\n diff: SnapshotDiff,\n span: string,\n attribute: string,\n prev: SnapshotAttribute,\n next: SnapshotAttribute,\n): void {\n if (prev.type !== next.type) {\n push(diff, {\n kind: 'breaking',\n type: 'type_changed',\n span,\n attribute,\n message: `attribute \"${attribute}\" changed type ${prev.type} → ${next.type}`,\n });\n }\n\n if (!prev.required && next.required) {\n push(diff, {\n kind: 'breaking',\n type: 'required_added',\n span,\n attribute,\n message: `attribute \"${attribute}\" became required`,\n });\n } else if (prev.required && !next.required) {\n push(diff, {\n kind: 'additive',\n type: 'required_removed',\n span,\n attribute,\n message: `attribute \"${attribute}\" is no longer required`,\n });\n }\n\n // Enum: removing a permitted value can break a producer that still emits it.\n if (prev.enum && next.enum) {\n const nextSet = new Set(next.enum);\n const removed = prev.enum.filter((v) => !nextSet.has(v));\n const prevSet = new Set(prev.enum);\n const added = next.enum.filter((v) => !prevSet.has(v));\n if (removed.length > 0) {\n push(diff, {\n kind: 'breaking',\n type: 'enum_value_removed',\n span,\n attribute,\n message: `attribute \"${attribute}\" dropped enum value(s) ${JSON.stringify(removed)}`,\n });\n }\n if (added.length > 0) {\n push(diff, {\n kind: 'additive',\n type: 'enum_value_added',\n span,\n attribute,\n message: `attribute \"${attribute}\" added enum value(s) ${JSON.stringify(added)}`,\n });\n }\n }\n\n if (prev.stability !== next.stability) {\n const transition =\n STABILITY_TRANSITIONS[`${prev.stability}->${next.stability}`];\n if (transition) {\n push(diff, {\n ...transition,\n span,\n attribute,\n message: stabilityMessage(transition.type, attribute, prev, next),\n });\n }\n }\n}\n\nfunction diffAttributeMaps(\n diff: SnapshotDiff,\n span: string,\n prev: Record<string, SnapshotAttribute>,\n next: Record<string, SnapshotAttribute>,\n): void {\n for (const [key, prevAttr] of Object.entries(prev)) {\n const nextAttr = next[key];\n if (!nextAttr) {\n // A removed attribute whose replacement is named is a documented\n // migration (still breaking — but reported as such with the pointer).\n push(diff, {\n kind: 'breaking',\n type: prevAttr.replacedBy ? 'replacement_documented' : 'attribute_removed',\n span,\n attribute: key,\n message: prevAttr.replacedBy\n ? `attribute \"${key}\" removed — replaced by \"${prevAttr.replacedBy}\"`\n : `attribute \"${key}\" was removed`,\n });\n continue;\n }\n diffAttribute(diff, span, key, prevAttr, nextAttr);\n }\n for (const key of Object.keys(next)) {\n if (!prev[key]) {\n const added = next[key];\n // Always `attribute_added` (the event is \"new attribute\"); severity rides\n // on `kind` — a new *required* attribute breaks existing producers.\n push(diff, {\n kind: added.required ? 'breaking' : 'additive',\n type: 'attribute_added',\n span,\n attribute: key,\n message: added.required\n ? `new required attribute \"${key}\" added`\n : `new attribute \"${key}\" added`,\n });\n }\n }\n}\n\n/**\n * Diff two snapshots, classifying every change. The `breaking` array is what a\n * CI gate keys off; `hasBreakingChanges()` is the convenience predicate.\n */\nexport function diffSnapshots(\n previous: ContractSnapshot,\n next: ContractSnapshot,\n): SnapshotDiff {\n const diff: SnapshotDiff = {\n service: next.service,\n previousVersion: previous.version,\n nextVersion: next.version,\n breaking: [],\n additive: [],\n neutral: [],\n };\n\n diffAttributeMaps(diff, '*', previous.commonAttributes, next.commonAttributes);\n\n for (const [name, prevSpan] of Object.entries(previous.spans)) {\n const nextSpan = next.spans[name];\n if (!nextSpan) {\n push(diff, {\n kind: 'breaking',\n type: 'span_removed',\n span: name,\n message: `span \"${name}\" was removed`,\n });\n continue;\n }\n diffAttributeMaps(diff, name, prevSpan.attributes, nextSpan.attributes);\n }\n for (const name of Object.keys(next.spans)) {\n if (!previous.spans[name]) {\n push(diff, {\n kind: 'additive',\n type: 'span_added',\n span: name,\n message: `new span \"${name}\" added`,\n });\n }\n }\n\n return diff;\n}\n\n/** `true` when the diff contains at least one breaking change. */\nexport function hasBreakingChanges(diff: SnapshotDiff): boolean {\n return diff.breaking.length > 0;\n}\n\n/** Markdown rendering of a diff — for CI logs and PR comments. */\nexport function formatDiff(diff: SnapshotDiff): string {\n const lines: string[] = [ \n `# Telemetry contract diff: ${diff.service} ${diff.previousVersion} → ${diff.nextVersion}`,\n ''];\n const section = (title: string, changes: SnapshotChange[]) => {\n if (changes.length === 0) return;\n lines.push(`## ${title} (${changes.length})`, '');\n for (const c of changes) {\n const where = c.attribute ? `\\`${c.span}.${c.attribute}\\`` : `\\`${c.span}\\``;\n lines.push(`- ${where}: ${c.message}`);\n }\n lines.push('');\n };\n section('💥 Breaking', diff.breaking);\n section('➕ Additive', diff.additive);\n section('• Neutral', diff.neutral);\n if (\n diff.breaking.length === 0 &&\n diff.additive.length === 0 &&\n diff.neutral.length === 0\n ) {\n lines.push('No changes to the telemetry contract.', '');\n }\n return lines.join('\\n');\n}\n"],"mappings":";;;;;;AAoDA,MAAM,wBAGF;CACF,wBAAwB;EAAE,MAAM;EAAY,MAAM;CAAuB;CACzE,sBAAsB;EAAE,MAAM;EAAY,MAAM;CAAa;CAC7D,wBAAwB;EAAE,MAAM;EAAW,MAAM;CAAqB;CACtE,4BAA4B;EAAE,MAAM;EAAY,MAAM;CAAa;CACnE,sBAAsB;EAAE,MAAM;EAAW,MAAM;CAAqB;CACpE,4BAA4B;EAAE,MAAM;EAAY,MAAM;CAAuB;AAC/E;AAEA,SAAS,iBACP,MACA,WACA,MACA,MACQ;CACR,IAAI,SAAS,cACX,OAAO,cAAc,UAAU,kBAAkB,KAAK,aAAa,UAAU,KAAK,WAAW,MAAM;CAErG,IAAI,SAAS,wBACX,OAAO,cAAc,UAAU,yBAAyB,KAAK,UAAU,KAAK,KAAK;CAEnF,OAAO,cAAc,UAAU,aAAa,KAAK,UAAU,KAAK,KAAK;AACvE;AAEA,SAAS,KACP,MACA,QACM;CACN,IAAI,OAAO,SAAS,YAAY,KAAK,SAAS,KAAK,MAAM;MACpD,IAAI,OAAO,SAAS,YAAY,KAAK,SAAS,KAAK,MAAM;MACzD,KAAK,QAAQ,KAAK,MAAM;AAC/B;AAEA,SAAS,cACP,MACA,MACA,WACA,MACA,MACM;CACN,IAAI,KAAK,SAAS,KAAK,MACrB,KAAK,MAAM;EACT,MAAM;EACN,MAAM;EACN;EACA;EACA,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AAM,QAAkB,CACtB,8BAA8B,KAAK,QAAQ,GAAG,KAAK,gBAAgB,KAAK,KAAK,eAC7E,EAAE;CACJ,MAAM,WAAW,OAAe,YAA8B;EAC5D,IAAI,QAAQ,WAAW,GAAG;EAC1B,MAAM,KAAK,MAAM,MAAM,IAAI,QAAQ,OAAO,IAAI,EAAE;EAChD,KAAK,MAAM,KAAK,SAAS;GACvB,MAAM,QAAQ,EAAE,YAAY,KAAK,EAAE,KAAK,GAAG,EAAE,UAAU,MAAM,KAAK,EAAE,KAAK;GACzE,MAAM,KAAK,KAAK,MAAM,IAAI,EAAE,SAAS;EACvC;EACA,MAAM,KAAK,EAAE;CACf;CACA,QAAQ,eAAe,KAAK,QAAQ;CACpC,QAAQ,cAAc,KAAK,QAAQ;CACnC,QAAQ,aAAa,KAAK,OAAO;CACjC,IACE,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,WAAW,KACzB,KAAK,QAAQ,WAAW,GAExB,MAAM,KAAK,yCAAyC,EAAE;CAExD,OAAO,MAAM,KAAK,IAAI;AACxB"}
|
|
1
|
+
{"version":3,"file":"diff.js","names":[],"sources":["../src/diff.ts"],"sourcesContent":["/**\n * Snapshot diffing — the CI gate that catches breaking changes to your trace\n * surface before they ship.\n *\n * \"If you wouldn't ship a rename to your public API without a changelog, don't\n * do it to your traces.\" This module is what makes that enforceable: classify\n * every change between two snapshots as breaking, additive, or neutral, and let\n * CI fail on the breaking ones.\n */\n\nimport type { ContractSnapshot, SnapshotAttribute } from './snapshot.js';\n\nexport type ChangeKind = 'breaking' | 'additive' | 'neutral';\n\nexport type ChangeType =\n | 'span_removed'\n | 'span_added'\n | 'attribute_removed'\n | 'attribute_added'\n | 'type_changed'\n | 'required_added'\n | 'required_removed'\n | 'enum_value_removed'\n | 'enum_value_added'\n | 'stability_downgraded'\n | 'stability_advanced'\n | 'deprecated'\n | 'replacement_documented';\n\nexport interface SnapshotChange {\n kind: ChangeKind;\n type: ChangeType;\n /** Span the change applies to (`*` = common attributes / contract-wide). */\n span: string;\n attribute?: string;\n message: string;\n}\n\nexport interface SnapshotDiff {\n service: string;\n previousVersion: string;\n nextVersion: string;\n breaking: SnapshotChange[];\n additive: SnapshotChange[];\n neutral: SnapshotChange[];\n}\n\n/**\n * How every cross-stability transition is classified. Keyed `prev->next` so all\n * six transitions are explicit and auditable — no silent fall-through. Same-\n * stability transitions are absent (no change to report).\n */\nconst STABILITY_TRANSITIONS: Record<\n string,\n { kind: ChangeKind; type: ChangeType }\n> = {\n 'stable->experimental': { kind: 'breaking', type: 'stability_downgraded' },\n 'stable->deprecated': { kind: 'additive', type: 'deprecated' },\n 'experimental->stable': { kind: 'neutral', type: 'stability_advanced' },\n 'experimental->deprecated': { kind: 'additive', type: 'deprecated' },\n 'deprecated->stable': { kind: 'neutral', type: 'stability_advanced' },\n 'deprecated->experimental': {\n kind: 'breaking',\n type: 'stability_downgraded',\n },\n};\n\nfunction stabilityMessage(\n type: ChangeType,\n attribute: string,\n prev: SnapshotAttribute,\n next: SnapshotAttribute,\n): string {\n if (type === 'deprecated') {\n return `attribute \"${attribute}\" was deprecated${next.replacedBy ? ` (use \"${next.replacedBy}\")` : ''}`;\n }\n if (type === 'stability_downgraded') {\n return `attribute \"${attribute}\" stability downgraded ${prev.stability} → ${next.stability}`;\n }\n return `attribute \"${attribute}\" promoted ${prev.stability} → ${next.stability}`;\n}\n\nfunction push(diff: SnapshotDiff, change: SnapshotChange): void {\n if (change.kind === 'breaking') diff.breaking.push(change);\n else if (change.kind === 'additive') diff.additive.push(change);\n else diff.neutral.push(change);\n}\n\nfunction diffAttribute(\n diff: SnapshotDiff,\n span: string,\n attribute: string,\n prev: SnapshotAttribute,\n next: SnapshotAttribute,\n): void {\n if (prev.type !== next.type) {\n push(diff, {\n kind: 'breaking',\n type: 'type_changed',\n span,\n attribute,\n message: `attribute \"${attribute}\" changed type ${prev.type} → ${next.type}`,\n });\n }\n\n if (!prev.required && next.required) {\n push(diff, {\n kind: 'breaking',\n type: 'required_added',\n span,\n attribute,\n message: `attribute \"${attribute}\" became required`,\n });\n } else if (prev.required && !next.required) {\n push(diff, {\n kind: 'additive',\n type: 'required_removed',\n span,\n attribute,\n message: `attribute \"${attribute}\" is no longer required`,\n });\n }\n\n // Enum: removing a permitted value can break a producer that still emits it.\n if (prev.enum && next.enum) {\n const nextSet = new Set(next.enum);\n const removed = prev.enum.filter((v) => !nextSet.has(v));\n const prevSet = new Set(prev.enum);\n const added = next.enum.filter((v) => !prevSet.has(v));\n if (removed.length > 0) {\n push(diff, {\n kind: 'breaking',\n type: 'enum_value_removed',\n span,\n attribute,\n message: `attribute \"${attribute}\" dropped enum value(s) ${JSON.stringify(removed)}`,\n });\n }\n if (added.length > 0) {\n push(diff, {\n kind: 'additive',\n type: 'enum_value_added',\n span,\n attribute,\n message: `attribute \"${attribute}\" added enum value(s) ${JSON.stringify(added)}`,\n });\n }\n }\n\n if (prev.stability !== next.stability) {\n const transition =\n STABILITY_TRANSITIONS[`${prev.stability}->${next.stability}`];\n if (transition) {\n push(diff, {\n ...transition,\n span,\n attribute,\n message: stabilityMessage(transition.type, attribute, prev, next),\n });\n }\n }\n}\n\nfunction diffAttributeMaps(\n diff: SnapshotDiff,\n span: string,\n prev: Record<string, SnapshotAttribute>,\n next: Record<string, SnapshotAttribute>,\n): void {\n for (const [key, prevAttr] of Object.entries(prev)) {\n const nextAttr = next[key];\n if (!nextAttr) {\n // A removed attribute whose replacement is named is a documented\n // migration (still breaking — but reported as such with the pointer).\n push(diff, {\n kind: 'breaking',\n type: prevAttr.replacedBy\n ? 'replacement_documented'\n : 'attribute_removed',\n span,\n attribute: key,\n message: prevAttr.replacedBy\n ? `attribute \"${key}\" removed — replaced by \"${prevAttr.replacedBy}\"`\n : `attribute \"${key}\" was removed`,\n });\n continue;\n }\n diffAttribute(diff, span, key, prevAttr, nextAttr);\n }\n for (const key of Object.keys(next)) {\n if (!prev[key]) {\n const added = next[key];\n // Always `attribute_added` (the event is \"new attribute\"); severity rides\n // on `kind` — a new *required* attribute breaks existing producers.\n push(diff, {\n kind: added.required ? 'breaking' : 'additive',\n type: 'attribute_added',\n span,\n attribute: key,\n message: added.required\n ? `new required attribute \"${key}\" added`\n : `new attribute \"${key}\" added`,\n });\n }\n }\n}\n\n/**\n * Diff two snapshots, classifying every change. The `breaking` array is what a\n * CI gate keys off; `hasBreakingChanges()` is the convenience predicate.\n */\nexport function diffSnapshots(\n previous: ContractSnapshot,\n next: ContractSnapshot,\n): SnapshotDiff {\n const diff: SnapshotDiff = {\n service: next.service,\n previousVersion: previous.version,\n nextVersion: next.version,\n breaking: [],\n additive: [],\n neutral: [],\n };\n\n diffAttributeMaps(\n diff,\n '*',\n previous.commonAttributes,\n next.commonAttributes,\n );\n\n for (const [name, prevSpan] of Object.entries(previous.spans)) {\n const nextSpan = next.spans[name];\n if (!nextSpan) {\n push(diff, {\n kind: 'breaking',\n type: 'span_removed',\n span: name,\n message: `span \"${name}\" was removed`,\n });\n continue;\n }\n diffAttributeMaps(diff, name, prevSpan.attributes, nextSpan.attributes);\n }\n for (const name of Object.keys(next.spans)) {\n if (!previous.spans[name]) {\n push(diff, {\n kind: 'additive',\n type: 'span_added',\n span: name,\n message: `new span \"${name}\" added`,\n });\n }\n }\n\n return diff;\n}\n\n/** `true` when the diff contains at least one breaking change. */\nexport function hasBreakingChanges(diff: SnapshotDiff): boolean {\n return diff.breaking.length > 0;\n}\n\n/** Markdown rendering of a diff — for CI logs and PR comments. */\nexport function formatDiff(diff: SnapshotDiff): string {\n const lines: string[] = [\n `# Telemetry contract diff: ${diff.service} ${diff.previousVersion} → ${diff.nextVersion}`,\n '',\n ];\n const section = (title: string, changes: SnapshotChange[]) => {\n if (changes.length === 0) return;\n lines.push(`## ${title} (${changes.length})`, '');\n for (const c of changes) {\n const where = c.attribute\n ? `\\`${c.span}.${c.attribute}\\``\n : `\\`${c.span}\\``;\n lines.push(`- ${where}: ${c.message}`);\n }\n lines.push('');\n };\n section('💥 Breaking', diff.breaking);\n section('➕ Additive', diff.additive);\n section('• Neutral', diff.neutral);\n if (\n diff.breaking.length === 0 &&\n diff.additive.length === 0 &&\n diff.neutral.length === 0\n ) {\n lines.push('No changes to the telemetry contract.', '');\n }\n return lines.join('\\n');\n}\n"],"mappings":";;;;;;AAoDA,MAAM,wBAGF;CACF,wBAAwB;EAAE,MAAM;EAAY,MAAM;CAAuB;CACzE,sBAAsB;EAAE,MAAM;EAAY,MAAM;CAAa;CAC7D,wBAAwB;EAAE,MAAM;EAAW,MAAM;CAAqB;CACtE,4BAA4B;EAAE,MAAM;EAAY,MAAM;CAAa;CACnE,sBAAsB;EAAE,MAAM;EAAW,MAAM;CAAqB;CACpE,4BAA4B;EAC1B,MAAM;EACN,MAAM;CACR;AACF;AAEA,SAAS,iBACP,MACA,WACA,MACA,MACQ;CACR,IAAI,SAAS,cACX,OAAO,cAAc,UAAU,kBAAkB,KAAK,aAAa,UAAU,KAAK,WAAW,MAAM;CAErG,IAAI,SAAS,wBACX,OAAO,cAAc,UAAU,yBAAyB,KAAK,UAAU,KAAK,KAAK;CAEnF,OAAO,cAAc,UAAU,aAAa,KAAK,UAAU,KAAK,KAAK;AACvE;AAEA,SAAS,KAAK,MAAoB,QAA8B;CAC9D,IAAI,OAAO,SAAS,YAAY,KAAK,SAAS,KAAK,MAAM;MACpD,IAAI,OAAO,SAAS,YAAY,KAAK,SAAS,KAAK,MAAM;MACzD,KAAK,QAAQ,KAAK,MAAM;AAC/B;AAEA,SAAS,cACP,MACA,MACA,WACA,MACA,MACM;CACN,IAAI,KAAK,SAAS,KAAK,MACrB,KAAK,MAAM;EACT,MAAM;EACN,MAAM;EACN;EACA;EACA,SAAS,cAAc,UAAU,iBAAiB,KAAK,KAAK,KAAK,KAAK;CACxE,CAAC;CAGH,IAAI,CAAC,KAAK,YAAY,KAAK,UACzB,KAAK,MAAM;EACT,MAAM;EACN,MAAM;EACN;EACA;EACA,SAAS,cAAc,UAAU;CACnC,CAAC;MACI,IAAI,KAAK,YAAY,CAAC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M,KAAK,SAAS;GACvB,MAAM,QAAQ,EAAE,YACZ,KAAK,EAAE,KAAK,GAAG,EAAE,UAAU,MAC3B,KAAK,EAAE,KAAK;GAChB,MAAM,KAAK,KAAK,MAAM,IAAI,EAAE,SAAS;EACvC;EACA,MAAM,KAAK,EAAE;CACf;CACA,QAAQ,eAAe,KAAK,QAAQ;CACpC,QAAQ,cAAc,KAAK,QAAQ;CACnC,QAAQ,aAAa,KAAK,OAAO;CACjC,IACE,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,WAAW,KACzB,KAAK,QAAQ,WAAW,GAExB,MAAM,KAAK,yCAAyC,EAAE;CAExD,OAAO,MAAM,KAAK,IAAI;AACxB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_snapshot = require('./snapshot-CyWGJaJT.cjs');
|
|
3
|
-
const require_processor = require('./processor-
|
|
3
|
+
const require_processor = require('./processor-Gu8Yl_dS.cjs');
|
|
4
4
|
const require_diff = require('./diff.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/redaction.ts
|
|
@@ -185,18 +185,25 @@ exports.SNAPSHOT_SPEC = require_snapshot.SNAPSHOT_SPEC;
|
|
|
185
185
|
exports.STABILITIES = require_processor.STABILITIES;
|
|
186
186
|
exports.SchemaValidationSpanProcessor = require_processor.SchemaValidationSpanProcessor;
|
|
187
187
|
exports.allowsAdditionalAttributes = require_processor.allowsAdditionalAttributes;
|
|
188
|
+
exports.checkScenario = require_processor.checkScenario;
|
|
188
189
|
exports.contractToSnapshot = require_snapshot.contractToSnapshot;
|
|
189
190
|
exports.createSchemaValidationProcessor = require_processor.createSchemaValidationProcessor;
|
|
190
191
|
exports.defineContract = require_processor.defineContract;
|
|
191
192
|
exports.diffSnapshots = require_diff.diffSnapshots;
|
|
193
|
+
exports.evaluateScenario = require_processor.evaluateScenario;
|
|
192
194
|
exports.formatDiff = require_diff.formatDiff;
|
|
195
|
+
exports.formatScenarioResult = require_processor.formatScenarioResult;
|
|
193
196
|
exports.formatViolation = require_processor.formatViolation;
|
|
194
197
|
exports.hasBreakingChanges = require_diff.hasBreakingChanges;
|
|
195
198
|
exports.hasErrors = require_processor.hasErrors;
|
|
196
199
|
exports.highCardinalityKeys = highCardinalityKeys;
|
|
197
200
|
exports.isHighCardinalityKey = isHighCardinalityKey;
|
|
201
|
+
exports.isScenarioClosed = require_processor.isScenarioClosed;
|
|
202
|
+
exports.parseCardinality = require_processor.parseCardinality;
|
|
198
203
|
exports.parseSnapshot = require_snapshot.parseSnapshot;
|
|
204
|
+
exports.proposeScenario = require_processor.proposeScenario;
|
|
199
205
|
exports.resolveAttributeSpec = require_processor.resolveAttributeSpec;
|
|
200
206
|
exports.serializeSnapshot = require_snapshot.serializeSnapshot;
|
|
207
|
+
exports.validateScenarioSpec = require_processor.validateScenarioSpec;
|
|
201
208
|
exports.validateSpan = require_processor.validateSpan;
|
|
202
209
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["defineContract"],"sources":["../src/redaction.ts","../src/contracts/agent-security.ts"],"sourcesContent":["/**\n * Cardinality posture helpers.\n *\n * The old cardinality rule — \"keep unique-value counts down\" — was a constraint\n * invented because dashboards have pixels and a graph with 10k series is\n * unreadable to a human. An agent does not look at the graph; it reads the\n * spans. A high-cardinality field (the user id, the sender domain, the request\n * id) is then the single most useful attribute on a trace when the agent is\n * chasing one specific failure.\n *\n * So the contract lets you mark attributes `highCardinality: true` as a\n * deliberate signal, and this module turns that into a *protect list*: the keys\n * a redactor or span-name normalizer must NOT strip, even when an aggressive\n * default would otherwise drop them.\n */\n\nimport type { TelemetryContract } from './contract.js';\n\n/**\n * Every attribute key in the contract flagged `highCardinality: true`, across\n * both common and per-span attributes. Feed this into a redaction/normalization\n * allow-list so the fields most useful to an agent reader survive.\n *\n * @example\n * ```ts\n * import { init } from 'autotel';\n * import { highCardinalityKeys } from 'autotel-schema';\n * import { contract } from './telemetry.contract';\n *\n * init({\n * service: 'checkout',\n * // keep user.id / request.id intact even under the strict redactor\n * attributeRedactor: { allowKeys: highCardinalityKeys(contract), preset: 'strict' },\n * });\n * ```\n */\nexport function highCardinalityKeys(contract: TelemetryContract): string[] {\n const keys = new Set<string>();\n for (const [key, spec] of Object.entries(contract.commonAttributes ?? {})) {\n if (spec.highCardinality) keys.add(key);\n }\n for (const spanSpec of Object.values(contract.spans)) {\n for (const [key, spec] of Object.entries(spanSpec.attributes ?? {})) {\n if (spec.highCardinality) keys.add(key);\n }\n }\n return [...keys].toSorted();\n}\n\n/**\n * Predicate form of {@link highCardinalityKeys} — `true` when `key` is declared\n * high-cardinality anywhere in the contract. Useful inside a custom\n * `spanNameNormalizer` or redactor callback.\n */\nexport function isHighCardinalityKey(\n contract: TelemetryContract,\n key: string,\n): boolean {\n if (contract.commonAttributes?.[key]?.highCardinality) return true;\n for (const spanSpec of Object.values(contract.spans)) {\n if (spanSpec.attributes?.[key]?.highCardinality) return true;\n }\n return false;\n}\n","import { defineContract } from '../contract.js';\n\nconst stringAttr = { type: 'string' as const };\nconst boolAttr = { type: 'boolean' as const };\nconst numberAttr = { type: 'number' as const };\nconst stringArrayAttr = { type: 'string[]' as const };\n\n/**\n * Published telemetry contract for Google SAIF-aligned agent security observability.\n * Span names are illustrative — attributes are the stable surface under validation.\n */\nexport const AGENT_SECURITY_TELEMETRY_CONTRACT = defineContract({\n service: 'autotel-agent-security',\n version: '1.0.0',\n commonAttributes: {\n 'autotel.agent': {
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["defineContract"],"sources":["../src/redaction.ts","../src/contracts/agent-security.ts"],"sourcesContent":["/**\n * Cardinality posture helpers.\n *\n * The old cardinality rule — \"keep unique-value counts down\" — was a constraint\n * invented because dashboards have pixels and a graph with 10k series is\n * unreadable to a human. An agent does not look at the graph; it reads the\n * spans. A high-cardinality field (the user id, the sender domain, the request\n * id) is then the single most useful attribute on a trace when the agent is\n * chasing one specific failure.\n *\n * So the contract lets you mark attributes `highCardinality: true` as a\n * deliberate signal, and this module turns that into a *protect list*: the keys\n * a redactor or span-name normalizer must NOT strip, even when an aggressive\n * default would otherwise drop them.\n */\n\nimport type { TelemetryContract } from './contract.js';\n\n/**\n * Every attribute key in the contract flagged `highCardinality: true`, across\n * both common and per-span attributes. Feed this into a redaction/normalization\n * allow-list so the fields most useful to an agent reader survive.\n *\n * @example\n * ```ts\n * import { init } from 'autotel';\n * import { highCardinalityKeys } from 'autotel-schema';\n * import { contract } from './telemetry.contract';\n *\n * init({\n * service: 'checkout',\n * // keep user.id / request.id intact even under the strict redactor\n * attributeRedactor: { allowKeys: highCardinalityKeys(contract), preset: 'strict' },\n * });\n * ```\n */\nexport function highCardinalityKeys(contract: TelemetryContract): string[] {\n const keys = new Set<string>();\n for (const [key, spec] of Object.entries(contract.commonAttributes ?? {})) {\n if (spec.highCardinality) keys.add(key);\n }\n for (const spanSpec of Object.values(contract.spans)) {\n for (const [key, spec] of Object.entries(spanSpec.attributes ?? {})) {\n if (spec.highCardinality) keys.add(key);\n }\n }\n return [...keys].toSorted();\n}\n\n/**\n * Predicate form of {@link highCardinalityKeys} — `true` when `key` is declared\n * high-cardinality anywhere in the contract. Useful inside a custom\n * `spanNameNormalizer` or redactor callback.\n */\nexport function isHighCardinalityKey(\n contract: TelemetryContract,\n key: string,\n): boolean {\n if (contract.commonAttributes?.[key]?.highCardinality) return true;\n for (const spanSpec of Object.values(contract.spans)) {\n if (spanSpec.attributes?.[key]?.highCardinality) return true;\n }\n return false;\n}\n","import { defineContract } from '../contract.js';\n\nconst stringAttr = { type: 'string' as const };\nconst boolAttr = { type: 'boolean' as const };\nconst numberAttr = { type: 'number' as const };\nconst stringArrayAttr = { type: 'string[]' as const };\n\n/**\n * Published telemetry contract for Google SAIF-aligned agent security observability.\n * Span names are illustrative — attributes are the stable surface under validation.\n */\nexport const AGENT_SECURITY_TELEMETRY_CONTRACT = defineContract({\n service: 'autotel-agent-security',\n version: '1.0.0',\n commonAttributes: {\n 'autotel.agent': {\n ...boolAttr,\n required: false,\n description: 'Agent audit marker',\n },\n 'agent.controller.id': {\n ...stringAttr,\n highCardinality: true,\n description: 'Hashed controlling human user id',\n },\n 'agent.input.provenance': {\n ...stringAttr,\n enum: [\n 'user_direct',\n 'user_voice',\n 'rag',\n 'memory',\n 'tool_result',\n 'external_untrusted',\n ],\n },\n 'agent.action.risk_class': {\n ...stringAttr,\n enum: [\n 'read',\n 'write',\n 'destructive',\n 'financial',\n 'exfiltration_capable',\n ],\n },\n 'agent.consent.required': { ...boolAttr },\n 'agent.consent.outcome': {\n ...stringAttr,\n enum: ['approved', 'denied', 'timeout', 'revoked'],\n },\n 'agent.scope.active': { ...stringArrayAttr },\n 'agent.memory.operation': {\n ...stringAttr,\n enum: ['read', 'write', 'delete', 'search'],\n },\n 'agent.memory.isolation_key': { ...stringAttr, highCardinality: true },\n 'agent.plan.step_index': { ...numberAttr },\n 'agent.plan.tool_intents': { ...stringArrayAttr },\n 'agent.plan.risk.verdict': {\n ...stringAttr,\n enum: ['low', 'medium', 'high', 'critical'],\n },\n 'agent.plan.risk.score': { ...numberAttr },\n 'agent.plan.risk.categories': { ...stringArrayAttr },\n 'policy.decision': {\n ...stringAttr,\n enum: ['permit', 'deny', 'challenge', 'observe', 'error'],\n },\n 'tool.input_hash': { ...stringAttr },\n 'tool.output_hash': { ...stringAttr },\n 'mcp.tool.destructive': { ...boolAttr },\n 'mcp.tool.untrusted_content': { ...boolAttr },\n 'mcp.security.injection.verdict': {\n ...stringAttr,\n enum: ['clean', 'suspicious', 'malicious'],\n },\n 'security.event': { ...stringAttr },\n 'security.category': { ...stringAttr },\n 'security.outcome': { ...stringAttr },\n 'security.severity': {\n ...stringAttr,\n enum: ['info', 'warning', 'error', 'critical'],\n },\n },\n spans: {\n 'agent.action': {\n description: 'Scoped agent action or tool call with audit metadata',\n attributes: {\n 'agent.id': { ...stringAttr, required: true },\n 'tool.name': { ...stringAttr },\n },\n },\n 'tools/call': {\n description: 'MCP tool invocation with boundary security signals',\n attributes: {\n 'mcp.tool.name': { ...stringAttr, required: true },\n },\n },\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,oBAAoB,UAAuC;CACzE,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,SAAS,oBAAoB,CAAC,CAAC,GACtE,IAAI,KAAK,iBAAiB,KAAK,IAAI,GAAG;CAExC,KAAK,MAAM,YAAY,OAAO,OAAO,SAAS,KAAK,GACjD,KAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,SAAS,cAAc,CAAC,CAAC,GAChE,IAAI,KAAK,iBAAiB,KAAK,IAAI,GAAG;CAG1C,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,SAAS;AAC5B;;;;;;AAOA,SAAgB,qBACd,UACA,KACS;CACT,IAAI,SAAS,mBAAmB,IAAI,EAAE,iBAAiB,OAAO;CAC9D,KAAK,MAAM,YAAY,OAAO,OAAO,SAAS,KAAK,GACjD,IAAI,SAAS,aAAa,IAAI,EAAE,iBAAiB,OAAO;CAE1D,OAAO;AACT;;;;AC7DA,MAAM,aAAa,EAAE,MAAM,SAAkB;AAC7C,MAAM,WAAW,EAAE,MAAM,UAAmB;AAC5C,MAAM,aAAa,EAAE,MAAM,SAAkB;AAC7C,MAAM,kBAAkB,EAAE,MAAM,WAAoB;;;;;AAMpD,MAAa,oCAAoCA,iCAAe;CAC9D,SAAS;CACT,SAAS;CACT,kBAAkB;EAChB,iBAAiB;GACf,GAAG;GACH,UAAU;GACV,aAAa;EACf;EACA,uBAAuB;GACrB,GAAG;GACH,iBAAiB;GACjB,aAAa;EACf;EACA,0BAA0B;GACxB,GAAG;GACH,MAAM;IACJ;IACA;IACA;IACA;IACA;IACA;GACF;EACF;EACA,2BAA2B;GACz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cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as diffSnapshots, c as ContractSnapshot, d as contractToSnapshot, f as parseSnapshot, g as SchemaAttributeKey, h as SNAPSHOT_SPEC, i as SnapshotDiff, l as SnapshotAttribute, m as SCHEMA_ATTRS, n as ChangeType, o as formatDiff, p as serializeSnapshot, r as SnapshotChange, s as hasBreakingChanges, t as ChangeKind, u as SnapshotSpan } from "./diff-
|
|
2
|
-
import { a as SpanSpec, c as allowsAdditionalAttributes, i as STABILITIES, l as defineContract, n as AttributeSpec, o as Stability, r as AttributeType, s as TelemetryContract, t as ATTRIBUTE_TYPES, u as resolveAttributeSpec } from "./contract-
|
|
3
|
-
import { a as SchemaValidationSpanProcessor, c as createSchemaValidationProcessor, d as ValidateOptions, f as ViolationCode, g as validateSpan, h as hasErrors, i as SchemaValidationProcessorOptions, l as SchemaViolation, m as formatViolation, n as ReadableSpanLike, o as SpanLike, p as ViolationSeverity, r as SchemaProcessorMode, s as SpanProcessorLike, t as OtelContext, u as SpanShape } from "./processor-
|
|
4
|
-
|
|
1
|
+
import { a as diffSnapshots, c as ContractSnapshot, d as contractToSnapshot, f as parseSnapshot, g as SchemaAttributeKey, h as SNAPSHOT_SPEC, i as SnapshotDiff, l as SnapshotAttribute, m as SCHEMA_ATTRS, n as ChangeType, o as formatDiff, p as serializeSnapshot, r as SnapshotChange, s as hasBreakingChanges, t as ChangeKind, u as SnapshotSpan } from "./diff-CfvhW7ux.cjs";
|
|
2
|
+
import { A as validateScenarioSpec, C as ScenarioViolationCode, D as isScenarioClosed, E as formatScenarioResult, O as parseCardinality, S as ScenarioViolation, T as evaluateScenario, _ as ScenarioOutcome, a as SpanSpec, b as ScenarioSpan, c as allowsAdditionalAttributes, d as Cardinality, f as CheckScenarioOptions, g as ScenarioEventSpec, h as ScenarioAddition, i as STABILITIES, k as proposeScenario, l as defineContract, m as EvaluateScenarioOptions, n as AttributeSpec, o as Stability, p as CompletionBoundary, r as AttributeType, s as TelemetryContract, t as ATTRIBUTE_TYPES, u as resolveAttributeSpec, v as ScenarioProposal, w as checkScenario, x as ScenarioSpec, y as ScenarioResult } from "./contract-Ymh_Q37N.cjs";
|
|
3
|
+
import { a as SchemaValidationSpanProcessor, c as createSchemaValidationProcessor, d as ValidateOptions, f as ViolationCode, g as validateSpan, h as hasErrors, i as SchemaValidationProcessorOptions, l as SchemaViolation, m as formatViolation, n as ReadableSpanLike, o as SpanLike, p as ViolationSeverity, r as SchemaProcessorMode, s as SpanProcessorLike, t as OtelContext, u as SpanShape } from "./processor-DVcsS6Rz.cjs";
|
|
5
4
|
//#region src/redaction.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Every attribute key in the contract flagged `highCardinality: true`, across
|
|
@@ -36,5 +35,5 @@ declare function isHighCardinalityKey(contract: TelemetryContract, key: string):
|
|
|
36
35
|
*/
|
|
37
36
|
declare const AGENT_SECURITY_TELEMETRY_CONTRACT: TelemetryContract;
|
|
38
37
|
//#endregion
|
|
39
|
-
export { AGENT_SECURITY_TELEMETRY_CONTRACT, ATTRIBUTE_TYPES, type AttributeSpec, type AttributeType, type ChangeKind, type ChangeType, type ContractSnapshot, type OtelContext, type ReadableSpanLike, SCHEMA_ATTRS, SNAPSHOT_SPEC, STABILITIES, type SchemaAttributeKey, type SchemaProcessorMode, type SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, type SchemaViolation, type SnapshotAttribute, type SnapshotChange, type SnapshotDiff, type SnapshotSpan, type SpanLike, type SpanProcessorLike, type SpanShape, type SpanSpec, type Stability, type TelemetryContract, type ValidateOptions, type ViolationCode, type ViolationSeverity, allowsAdditionalAttributes, contractToSnapshot, createSchemaValidationProcessor, defineContract, diffSnapshots, formatDiff, formatViolation, hasBreakingChanges, hasErrors, highCardinalityKeys, isHighCardinalityKey, parseSnapshot, resolveAttributeSpec, serializeSnapshot, validateSpan };
|
|
38
|
+
export { AGENT_SECURITY_TELEMETRY_CONTRACT, ATTRIBUTE_TYPES, type AttributeSpec, type AttributeType, type Cardinality, type ChangeKind, type ChangeType, type CheckScenarioOptions, type CompletionBoundary, type ContractSnapshot, type EvaluateScenarioOptions, type OtelContext, type ReadableSpanLike, SCHEMA_ATTRS, SNAPSHOT_SPEC, STABILITIES, type ScenarioAddition, type ScenarioEventSpec, type ScenarioOutcome, type ScenarioProposal, type ScenarioResult, type ScenarioSpan, type ScenarioSpec, type ScenarioViolation, type ScenarioViolationCode, type SchemaAttributeKey, type SchemaProcessorMode, type SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, type SchemaViolation, type SnapshotAttribute, type SnapshotChange, type SnapshotDiff, type SnapshotSpan, type SpanLike, type SpanProcessorLike, type SpanShape, type SpanSpec, type Stability, type TelemetryContract, type ValidateOptions, type ViolationCode, type ViolationSeverity, allowsAdditionalAttributes, checkScenario, contractToSnapshot, createSchemaValidationProcessor, defineContract, diffSnapshots, evaluateScenario, formatDiff, formatScenarioResult, formatViolation, hasBreakingChanges, hasErrors, highCardinalityKeys, isHighCardinalityKey, isScenarioClosed, parseCardinality, parseSnapshot, proposeScenario, resolveAttributeSpec, serializeSnapshot, validateScenarioSpec, validateSpan };
|
|
40
39
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/redaction.ts","../src/contracts/agent-security.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/redaction.ts","../src/contracts/agent-security.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;iBAoCgB,oBAAoB,UAAU;;;;;;iBAkB9B,qBACd,UAAU,mBACV;;;;;;;cC7CW,mCAAA"}
|