@substrat-run/contracts 0.98.1 → 0.100.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.
@@ -0,0 +1,91 @@
1
+ import { z } from 'zod';
2
+ import { connectionId } from './connections.js';
3
+ import { scopeId, tenantId } from './ids.js';
4
+ /**
5
+ * The signals dimension vocabulary (#1231) — the one set of names every
6
+ * observability-facing fact is stamped with, defined once so that every chart,
7
+ * list, graph node and failure record means the same thing by `version`, and an
8
+ * aggregate anywhere can click through to its exemplars with filters intact.
9
+ *
10
+ * What each dimension names, precisely:
11
+ *
12
+ * - `tenant` / `scope` — the branded directory ids, exactly as the spine stamps
13
+ * them on every event.
14
+ * - `vertical` — the vertical's package name (`@substrat-run/demo-ticket0`),
15
+ * the registry's identity for it.
16
+ * - `version` — the version REGISTRY id (ULID) of the vertical version the fact
17
+ * was recorded under. The id, not the human version label: the label is one
18
+ * `getVersion` away, while the id survives channels, previews and re-releases
19
+ * of the same label. For a record written outside any deploy the stamp is the
20
+ * version bound to the scope at write time — stated here because it is an
21
+ * approximation everywhere the writer is not the deploy itself.
22
+ * - `operation` — the operation on whose behalf the work ran: a vertical's
23
+ * operation name (`ticket0/answer`) for scope-side facts, the platform
24
+ * operation string (`preview.create`, `intent.connector:scrive`) for
25
+ * control-plane facts.
26
+ * - `eventType` — a DOMAIN event type (`receipt.landed`), never the Workers
27
+ * invocation shape (fetch/rpc/scheduled/alarm); the observability seam names
28
+ * that `invocation` so the two can never be confused in a filter.
29
+ * - `connection` — the connection id (ULID), not the provider slug: a tenant can
30
+ * hold two connections to one provider, and the slug cannot tell them apart.
31
+ *
32
+ * `modelAttribution` (model-usage.ts) predates this vocabulary and stays its own
33
+ * frozen five-key shape — the smallest per-request metadata limit among model
34
+ * providers fixes it at five, so it is deliberately NOT widened to this schema;
35
+ * a signals reader reconciles it at read time.
36
+ */
37
+ export const SIGNAL_DIMENSIONS = [
38
+ 'tenant',
39
+ 'scope',
40
+ 'vertical',
41
+ 'version',
42
+ 'operation',
43
+ 'eventType',
44
+ 'connection',
45
+ ];
46
+ /**
47
+ * A partial stamp: the dimensions one durable record carries. Every key is
48
+ * optional — a record states what it knows and nothing else — but `.strict()`,
49
+ * so an eighth dimension cannot drift in through a stamp; widening the
50
+ * vocabulary is an edit HERE, read in a PR diff, or nowhere.
51
+ */
52
+ export const signalStamp = z
53
+ .object({
54
+ tenant: tenantId,
55
+ scope: scopeId,
56
+ vertical: z.string().min(1),
57
+ // Deliberately as loose as the registry's own `versionId` (`z.string().min(1)`,
58
+ // registry.ts): the registry owns that id's shape, and a stamp stricter than its
59
+ // owner could refuse an id the registry itself handed out. If the registry ever
60
+ // brands it, this field adopts the brand from there.
61
+ version: z.string().min(1),
62
+ operation: z.string().min(1),
63
+ eventType: z.string().min(1),
64
+ connection: connectionId,
65
+ })
66
+ .partial()
67
+ .strict();
68
+ /**
69
+ * What one deployed SERVICE (a Cloudflare script ref) means in signal dimensions —
70
+ * the service→(vertical, version) join, answered by the control plane's
71
+ * `GET /service-refs` so every consumer (dashboard, console, CLI, the signals
72
+ * views) gets the same answer instead of each re-deriving it (#1231's last item).
73
+ *
74
+ * `stamp.version` is the registry ULID, per this file's rule; the HUMAN label
75
+ * rides beside the stamp rather than inside it — `signalStamp` is `.strict()`
76
+ * precisely so a display concern cannot drift into the dimension vocabulary.
77
+ * `versionLabel` is null where the directory cannot name one (a serving ref
78
+ * bound to a scope whose version the registry no longer lists).
79
+ *
80
+ * `role` names which ref scheme this service is — the per-version archive
81
+ * script or the stable serving script — because conflating the two is the
82
+ * mistake that made the dashboard's per-version view read empty once already.
83
+ */
84
+ export const serviceDimensions = z.object({
85
+ /** The deployed unit: a `deploymentRef` (archive) or a `servingRef` (serving). */
86
+ service: z.string().min(1),
87
+ role: z.enum(['archive', 'serving']),
88
+ stamp: signalStamp,
89
+ versionLabel: z.string().min(1).nullable(),
90
+ });
91
+ //# sourceMappingURL=signals.js.map
@@ -0,0 +1 @@
1
+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IAClB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@substrat-run/contracts",
3
- "version": "0.98.1",
3
+ "version": "0.100.0",
4
4
  "description": "Substrat kernel contract schemas — Zod is the source of truth (master plan D-22); OAS/JSON Schema are emitted artifacts",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {