@substrat-run/kernel 0.216.0 → 0.218.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.
Files changed (108) hide show
  1. package/dist/attachment-gate.d.ts +42 -0
  2. package/dist/attachment-gate.d.ts.map +1 -0
  3. package/dist/attachment-gate.js +36 -0
  4. package/dist/attachment-gate.js.map +1 -0
  5. package/dist/broker-counts.d.ts +108 -0
  6. package/dist/broker-counts.d.ts.map +1 -0
  7. package/dist/broker-counts.js +101 -0
  8. package/dist/broker-counts.js.map +1 -0
  9. package/dist/broker-erasure.d.ts +51 -0
  10. package/dist/broker-erasure.d.ts.map +1 -0
  11. package/dist/broker-erasure.js +161 -0
  12. package/dist/broker-erasure.js.map +1 -0
  13. package/dist/broker-relay-erasure.d.ts +27 -0
  14. package/dist/broker-relay-erasure.d.ts.map +1 -0
  15. package/dist/broker-relay-erasure.js +115 -0
  16. package/dist/broker-relay-erasure.js.map +1 -0
  17. package/dist/broker-relay.d.ts +292 -0
  18. package/dist/broker-relay.d.ts.map +1 -0
  19. package/dist/broker-relay.js +494 -0
  20. package/dist/broker-relay.js.map +1 -0
  21. package/dist/broker-schema.d.ts +25 -0
  22. package/dist/broker-schema.d.ts.map +1 -0
  23. package/dist/broker-schema.js +256 -0
  24. package/dist/broker-schema.js.map +1 -0
  25. package/dist/broker-shadow.d.ts +258 -0
  26. package/dist/broker-shadow.d.ts.map +1 -0
  27. package/dist/broker-shadow.js +295 -0
  28. package/dist/broker-shadow.js.map +1 -0
  29. package/dist/broker-telemetry.d.ts +289 -0
  30. package/dist/broker-telemetry.d.ts.map +1 -0
  31. package/dist/broker-telemetry.js +336 -0
  32. package/dist/broker-telemetry.js.map +1 -0
  33. package/dist/cost-rollup.d.ts +6 -0
  34. package/dist/cost-rollup.d.ts.map +1 -1
  35. package/dist/cost-rollup.js +22 -1
  36. package/dist/cost-rollup.js.map +1 -1
  37. package/dist/delivery-broker.d.ts +320 -0
  38. package/dist/delivery-broker.d.ts.map +1 -0
  39. package/dist/delivery-broker.js +571 -0
  40. package/dist/delivery-broker.js.map +1 -0
  41. package/dist/delivery-policy.d.ts +105 -0
  42. package/dist/delivery-policy.d.ts.map +1 -0
  43. package/dist/delivery-policy.js +105 -0
  44. package/dist/delivery-policy.js.map +1 -0
  45. package/dist/directory-lake-keep.d.ts +9 -0
  46. package/dist/directory-lake-keep.d.ts.map +1 -0
  47. package/dist/directory-lake-keep.js +331 -0
  48. package/dist/directory-lake-keep.js.map +1 -0
  49. package/dist/directory-lake-projection.d.ts +50 -0
  50. package/dist/directory-lake-projection.d.ts.map +1 -0
  51. package/dist/directory-lake-projection.js +143 -0
  52. package/dist/directory-lake-projection.js.map +1 -0
  53. package/dist/directory-lake.d.ts +11 -1
  54. package/dist/directory-lake.d.ts.map +1 -1
  55. package/dist/directory-lake.js +3 -1
  56. package/dist/directory-lake.js.map +1 -1
  57. package/dist/index.d.ts +19 -2
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +13 -0
  60. package/dist/index.js.map +1 -1
  61. package/dist/job-run.d.ts +21 -1
  62. package/dist/job-run.d.ts.map +1 -1
  63. package/dist/job-run.js +6 -0
  64. package/dist/job-run.js.map +1 -1
  65. package/dist/migration-digest.d.ts +2 -2
  66. package/dist/migration-digest.d.ts.map +1 -1
  67. package/dist/migration-digest.js +4 -2
  68. package/dist/migration-digest.js.map +1 -1
  69. package/dist/migration-fence.d.ts +1 -1
  70. package/dist/migration-fence.js +3 -3
  71. package/dist/migration-fence.js.map +1 -1
  72. package/dist/outbox-prune.d.ts +8 -1
  73. package/dist/outbox-prune.d.ts.map +1 -1
  74. package/dist/outbox-prune.js +6 -2
  75. package/dist/outbox-prune.js.map +1 -1
  76. package/dist/platform-sweep.d.ts +10 -1
  77. package/dist/platform-sweep.d.ts.map +1 -1
  78. package/dist/platform-sweep.js +37 -1
  79. package/dist/platform-sweep.js.map +1 -1
  80. package/dist/scope-host.d.ts +58 -8
  81. package/dist/scope-host.d.ts.map +1 -1
  82. package/dist/scope-host.js.map +1 -1
  83. package/dist/spine-guard.d.ts.map +1 -1
  84. package/dist/spine-guard.js +2 -0
  85. package/dist/spine-guard.js.map +1 -1
  86. package/dist/spine-restore.d.ts +14 -2
  87. package/dist/spine-restore.d.ts.map +1 -1
  88. package/dist/spine-restore.js.map +1 -1
  89. package/dist/store-driver-releases.d.ts +12 -3
  90. package/dist/store-driver-releases.d.ts.map +1 -1
  91. package/dist/store-driver-releases.js +12 -7
  92. package/dist/store-driver-releases.js.map +1 -1
  93. package/dist/subject-keys.d.ts +7 -0
  94. package/dist/subject-keys.d.ts.map +1 -1
  95. package/dist/subject-keys.js +29 -5
  96. package/dist/subject-keys.js.map +1 -1
  97. package/dist/subject-redaction.d.ts +7 -0
  98. package/dist/subject-redaction.d.ts.map +1 -1
  99. package/dist/subject-redaction.js +34 -27
  100. package/dist/subject-redaction.js.map +1 -1
  101. package/dist/table-ownership.d.ts +6 -0
  102. package/dist/table-ownership.d.ts.map +1 -1
  103. package/dist/table-ownership.js +17 -3
  104. package/dist/table-ownership.js.map +1 -1
  105. package/dist/vertical-owners.d.ts +1 -1
  106. package/dist/vertical-owners.d.ts.map +1 -1
  107. package/dist/vertical-owners.js.map +1 -1
  108. package/package.json +2 -2
@@ -0,0 +1,295 @@
1
+ import { DeliveryFailure } from './delivery-policy.js';
2
+ import { emittedHere } from './scope-copy.js';
3
+ export const DELIVERY_MODES = ['off', 'shadow', 'live'];
4
+ export const isDeliveryMode = (v) => typeof v === 'string' && DELIVERY_MODES.includes(v);
5
+ /** The recorder's subscription: every message handed off in shadow or live. */
6
+ export const SHADOW_RECEIVER = 'shadow';
7
+ /** The real receiver's subscription: intents handed off live. */
8
+ export const LIVE_RECEIVER = 'live';
9
+ /**
10
+ * The env var a script sets to hand off whatever the control plane says, owing every receiver as
11
+ * A1–A4 did: `always`. For a test worker or a self-hosted script with no control plane to ask. The
12
+ * uploader never sets it.
13
+ */
14
+ export const DELIVERY_HANDOFF_ENV = 'SUBSTRAT_DELIVERY_HANDOFF';
15
+ /**
16
+ * The receivers a message is owed, from the mode it was handed off under: `undefined` is every
17
+ * receiver the store has (no mode: A1–A4's behaviour). Only names the store knows are owed.
18
+ */
19
+ export function receiversFor(mode, kind) {
20
+ if (mode === 'shadow')
21
+ return [SHADOW_RECEIVER];
22
+ if (mode === 'live')
23
+ return kind === 'intent' ? [SHADOW_RECEIVER, LIVE_RECEIVER] : [SHADOW_RECEIVER];
24
+ return undefined;
25
+ }
26
+ /** How long a record is kept: the week the comparison is read over, and a day. */
27
+ export const SHADOW_RETENTION_MS = 8 * 24 * 60 * 60_000;
28
+ /** How young a message may be and still be in flight on either side: the drain's 15-minute pass, and the lake's 5. */
29
+ export const SHADOW_GRACE_MS = 20 * 60_000;
30
+ /** How many records one prune deletes; the rest go in the next. */
31
+ const SHADOW_PRUNE_BATCH = 500;
32
+ /**
33
+ * The recorder (the `SHADOW_RECEIVER` subscription) and the windows its comparison reads, over the
34
+ * broker's own database (`broker_shadow_records`, `broker_shadow_starts`; schema step 5).
35
+ */
36
+ export class ShadowRecorder {
37
+ sql;
38
+ retentionMs;
39
+ constructor(sql, opts = {}) {
40
+ this.sql = sql;
41
+ this.retentionMs = opts.retentionMs ?? SHADOW_RETENTION_MS;
42
+ }
43
+ /**
44
+ * The receiver: one row, copied from the broker's message row without its body. It writes nothing
45
+ * else anywhere and calls nothing: in shadow this is all a delivery does. Idempotent by id.
46
+ */
47
+ receiver(now) {
48
+ return {
49
+ deliver: async (m) => {
50
+ this.sql.run(`INSERT OR IGNORE INTO broker_shadow_records (message_id, kind, tenant_id, scope_id, type, committed_at, received_at, recorded_at)
51
+ SELECT id, kind, tenant_id, scope_id, type, committed_at, received_at, ? FROM broker_messages WHERE id = ?`, now(), m.id);
52
+ },
53
+ };
54
+ }
55
+ /** A scope's window starts after `marks`: a new start replaces the last, since the mode went on again. */
56
+ start(tenantId, scopeId, marks, now) {
57
+ this.sql.transaction(() => {
58
+ for (const kind of ['event', 'intent']) {
59
+ this.sql.run(`INSERT INTO broker_shadow_starts (tenant_id, scope_id, kind, start_after, started_at) VALUES (?, ?, ?, ?, ?)
60
+ ON CONFLICT (tenant_id, scope_id, kind) DO UPDATE SET start_after = excluded.start_after, started_at = excluded.started_at`, tenantId, scopeId, kind, marks[kind] ?? '', now);
61
+ }
62
+ });
63
+ }
64
+ /** The scopes with a window, in scope id order, after `cursor`. */
65
+ scopes(limit, cursor) {
66
+ const rows = this.sql.all(`SELECT tenant_id, scope_id, kind, start_after, started_at FROM broker_shadow_starts
67
+ WHERE scope_id IN (SELECT DISTINCT scope_id FROM broker_shadow_starts WHERE scope_id > ? ORDER BY scope_id LIMIT ?)
68
+ ORDER BY scope_id, kind`, cursor ?? '', limit);
69
+ const byScope = new Map();
70
+ for (const r of rows) {
71
+ const s = byScope.get(r.scope_id) ?? { tenantId: r.tenant_id, scopeId: r.scope_id, start: {}, startedAt: r.started_at };
72
+ if (r.start_after)
73
+ s.start[r.kind] = r.start_after;
74
+ s.startedAt = Math.max(s.startedAt, r.started_at);
75
+ byScope.set(r.scope_id, s);
76
+ }
77
+ return [...byScope.values()];
78
+ }
79
+ /** One scope's records inside its window: ids past its start, committed before `before`, at most `limit` per kind. */
80
+ records(scope, before, limit) {
81
+ return ['event', 'intent'].flatMap((kind) => this.sql
82
+ .all(`SELECT message_id, kind, tenant_id, scope_id, type, committed_at, received_at, recorded_at
83
+ FROM broker_shadow_records
84
+ WHERE tenant_id = ? AND scope_id = ? AND kind = ? AND message_id > ? AND committed_at < ?
85
+ ORDER BY message_id LIMIT ?`, scope.tenantId, scope.scopeId, kind, scope.start[kind] ?? '', before, limit)
86
+ .map((r) => ({
87
+ id: r.message_id,
88
+ kind: r.kind,
89
+ tenantId: r.tenant_id,
90
+ scopeId: r.scope_id,
91
+ type: r.type,
92
+ committedAt: r.committed_at,
93
+ receivedAt: r.received_at,
94
+ recordedAt: r.recorded_at,
95
+ })));
96
+ }
97
+ /** Drop records past their retention (K-70). Windows stay: one row per scope and kind. */
98
+ prune(now) {
99
+ this.sql.run(`DELETE FROM broker_shadow_records WHERE message_id IN (
100
+ SELECT message_id FROM broker_shadow_records WHERE recorded_at <= ? LIMIT ?)`, now - this.retentionMs, SHADOW_PRUNE_BATCH);
101
+ }
102
+ /** Epoch ms the oldest record's retention runs out, or null when it holds none. */
103
+ nextWakeAt() {
104
+ const row = this.sql.all('SELECT MIN(recorded_at) AS oldest FROM broker_shadow_records')[0];
105
+ return row?.oldest == null ? null : row.oldest + this.retentionMs;
106
+ }
107
+ }
108
+ /**
109
+ * The scope's half of the comparison: its own messages past `after`, committed before `before`,
110
+ * with what the drain did with each. Two reads by primary key range, both `emittedHere`, as the
111
+ * handoff's own reads are, so the two sides count the same rows.
112
+ */
113
+ export function witnessQueries(after, before, limit) {
114
+ return [
115
+ {
116
+ kind: 'event',
117
+ sql: `SELECT id, occurred_at AS committed_at, drained_at AS delivered_at FROM _substrat_outbox
118
+ WHERE id > ? AND occurred_at < ? AND ${emittedHere()} ORDER BY id LIMIT ?`,
119
+ params: [after.event ?? '', before, limit],
120
+ },
121
+ {
122
+ kind: 'intent',
123
+ sql: `SELECT id, requested_at AS committed_at, CASE WHEN status = 'pending' THEN NULL ELSE settled_at END AS delivered_at
124
+ FROM _substrat_platform_requests WHERE id > ? AND requested_at < ? AND ${emittedHere()} ORDER BY id LIMIT ?`,
125
+ params: [after.intent ?? '', before, limit],
126
+ },
127
+ ];
128
+ }
129
+ /** A witness read's rows, as witnesses. */
130
+ export function witnessesOf(kind, rows) {
131
+ return rows.map((r) => ({
132
+ id: String(r.id),
133
+ kind,
134
+ committedAt: String(r.committed_at),
135
+ deliveredAt: r.delivered_at == null ? null : String(r.delivered_at),
136
+ }));
137
+ }
138
+ /** How many ids of each difference a comparison names. */
139
+ export const COMPARISON_SAMPLE = 20;
140
+ const percentile = (sorted, p) => sorted[Math.min(sorted.length - 1, Math.max(0, Math.ceil((p / 100) * sorted.length) - 1))];
141
+ function stats(values) {
142
+ if (!values.length)
143
+ return null;
144
+ const sorted = [...values].sort((a, b) => a - b);
145
+ return { n: sorted.length, p50: percentile(sorted, 50), p95: percentile(sorted, 95), max: sorted[sorted.length - 1] };
146
+ }
147
+ /**
148
+ * Pair what the recorder got with what the drain did, for one kind. A record and a witness are the
149
+ * same message by id. Latency is from the message's commit: to the drain's delivery, and to the
150
+ * recorder's (which is the broker's whole path: handoff, store, pass).
151
+ */
152
+ export function compareKind(records, witnesses) {
153
+ const recorded = new Map(records.map((r) => [r.id, r]));
154
+ const witnessed = new Map(witnesses.map((w) => [w.id, w]));
155
+ const ids = [...new Set([...recorded.keys(), ...witnessed.keys()])].sort();
156
+ const out = {
157
+ compared: ids.length,
158
+ both: 0,
159
+ drainOnly: 0,
160
+ brokerOnly: 0,
161
+ neither: 0,
162
+ drainOnlyIds: [],
163
+ brokerOnlyIds: [],
164
+ latencyMs: { drain: null, broker: null },
165
+ };
166
+ const drain = [];
167
+ const broker = [];
168
+ for (const id of ids) {
169
+ const r = recorded.get(id);
170
+ const w = witnessed.get(id);
171
+ const drained = w?.deliveredAt != null;
172
+ const committedMs = Date.parse(r?.committedAt ?? w.committedAt);
173
+ if (drained)
174
+ drain.push(Math.max(0, Date.parse(w.deliveredAt) - committedMs));
175
+ if (r)
176
+ broker.push(Math.max(0, r.recordedAt - committedMs));
177
+ if (r && drained)
178
+ out.both++;
179
+ else if (drained) {
180
+ out.drainOnly++;
181
+ if (out.drainOnlyIds.length < COMPARISON_SAMPLE)
182
+ out.drainOnlyIds.push(id);
183
+ }
184
+ else if (r) {
185
+ out.brokerOnly++;
186
+ if (out.brokerOnlyIds.length < COMPARISON_SAMPLE)
187
+ out.brokerOnlyIds.push(id);
188
+ }
189
+ else
190
+ out.neither++;
191
+ }
192
+ out.latencyMs = { drain: stats(drain), broker: stats(broker) };
193
+ return out;
194
+ }
195
+ /** How many messages of each kind one scope contributes to one read. */
196
+ export const COMPARISON_PER_SCOPE = 1_000;
197
+ /** How many scopes one comparison read covers; `nextCursor` names the rest. */
198
+ export const COMPARISON_SCOPES = 50;
199
+ /**
200
+ * The comparison, both adapters' brokers: each scope with a window, its records against its
201
+ * witness. A scope whose witness throws is named in `unread`, never counted as all broker-only.
202
+ */
203
+ export async function compareDeliveries(recorder, witness, ids, opts) {
204
+ const before = new Date(opts.now - (opts.graceMs ?? SHADOW_GRACE_MS)).toISOString();
205
+ const limit = opts.perScope ?? COMPARISON_PER_SCOPE;
206
+ const pageSize = opts.scopes ?? COMPARISON_SCOPES;
207
+ const scopes = recorder.scopes(pageSize + 1, opts.cursor);
208
+ const page = scopes.slice(0, pageSize);
209
+ const records = [];
210
+ const witnesses = [];
211
+ const unread = [];
212
+ let truncated = false;
213
+ for (const scope of page) {
214
+ let seen;
215
+ try {
216
+ seen = await witness(scope, before, limit);
217
+ }
218
+ catch (err) {
219
+ unread.push({ scopeId: scope.scopeId, error: err instanceof Error ? err.message : String(err) });
220
+ continue;
221
+ }
222
+ const mine = recorder.records(scope, before, limit);
223
+ for (const kind of ['event', 'intent']) {
224
+ let w = seen.filter((x) => x.kind === kind);
225
+ let r = mine.filter((x) => x.kind === kind);
226
+ // A side that filled its read stops at its last id; past it, the other side's ids are unknown
227
+ // to it rather than missing. Compare only up to the lower of the two stops.
228
+ const through = [w.length >= limit ? w.at(-1).id : null, r.length >= limit ? r.at(-1).id : null]
229
+ .filter((x) => x !== null)
230
+ .sort()[0];
231
+ if (through !== undefined) {
232
+ truncated = true;
233
+ w = w.filter((x) => x.id <= through);
234
+ r = r.filter((x) => x.id <= through);
235
+ }
236
+ witnesses.push(...w);
237
+ records.push(...r);
238
+ }
239
+ }
240
+ return {
241
+ tenantId: ids.tenantId,
242
+ app: ids.app,
243
+ at: opts.now,
244
+ before,
245
+ scopes: page.length - unread.length,
246
+ unread,
247
+ truncated,
248
+ nextCursor: scopes.length > pageSize ? page.at(-1).scopeId : null,
249
+ event: compareKind(records.filter((r) => r.kind === 'event'), witnesses.filter((w) => w.kind === 'event')),
250
+ intent: compareKind(records.filter((r) => r.kind === 'intent'), witnesses.filter((w) => w.kind === 'intent')),
251
+ };
252
+ }
253
+ /** The reads `intentStateQuery` makes: one primary-key read. */
254
+ export const intentStateQuery = (id) => ({
255
+ sql: 'SELECT status FROM _substrat_platform_requests WHERE id = ?',
256
+ params: [id],
257
+ });
258
+ /** An intent's state from `intentStateQuery`'s rows. */
259
+ export const intentStateOf = (rows) => rows.length === 0 ? 'absent' : rows[0].status === 'pending' ? 'pending' : 'settled';
260
+ /** The live receiver's default looks after an ask: half a second, then one, two and four. */
261
+ export const LIVE_SETTLE_WAITS_MS = [500, 1_000, 2_000, 4_000];
262
+ /**
263
+ * The real receiver (`LIVE_RECEIVER`): an intent is delivered once it is no longer pending in its
264
+ * scope. The broker does not run the intent itself; the drain engine does, as it always has, so an
265
+ * intent is executed by one engine whichever path asked, and the ask is idempotent on the intent's
266
+ * own state. A settled or absent intent is delivered at once (another driver took it). A pending
267
+ * one is asked for and looked at again; still pending, the attempt fails and the broker retries it
268
+ * under its policy. An event is never owed here (`receiversFor`), and is delivered as a no-op if one
269
+ * ever is.
270
+ *
271
+ * `not-live`: the platform says this tenant is not live (a cut-back). The intent is the drain's
272
+ * again, and the delivery settles here, so the broker never asks twice for what it no longer owns.
273
+ */
274
+ export function liveIntentReceiver(deps) {
275
+ const waits = deps.settleWaitsMs ?? LIVE_SETTLE_WAITS_MS;
276
+ const timers = globalThis;
277
+ const sleep = deps.sleep ?? ((ms) => new Promise((r) => void timers.setTimeout(r, ms)));
278
+ return {
279
+ deliver: async (m) => {
280
+ if (m.kind !== 'intent')
281
+ return;
282
+ if ((await deps.state(m)) !== 'pending')
283
+ return;
284
+ if ((await deps.drive(m)) === 'not-live')
285
+ return;
286
+ for (const ms of waits) {
287
+ await sleep(ms);
288
+ if ((await deps.state(m)) !== 'pending')
289
+ return;
290
+ }
291
+ throw new DeliveryFailure(`intent ${m.id} is still pending after the drain was asked to run it`, { status: 503 });
292
+ },
293
+ };
294
+ }
295
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,CAAC;IACtG,OAAO;QACL,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;YACnB,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ;gBAAE,OAAO;YAChC,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS;gBAAE,OAAO;YAChD,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,UAAU;gBAAE,OAAO;YACjD,KAAK,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;gBACvB,MAAM,KAAK,CAAC,EAAE,CAAC,CAAC;gBAChB,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS;oBAAE,OAAO;YAClD,CAAC;YACD,MAAM,IAAI,eAAe,CAAC,UAAU,CAAC,CAAC,EAAE,uDAAuD,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACpH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,289 @@
1
+ /**
2
+ * #3474 (RFC broker-and-tenant-isolation §9.1): what a delivery broker tells the platform about the
3
+ * messages it owns, and the state it is in. Shared by both adapters, so the two cannot report
4
+ * differently.
5
+ *
6
+ * Two kinds of record, one sink:
7
+ *
8
+ * - **A data point per step** — the scope's handoff, the broker's receipt, each delivery attempt
9
+ * (delivered, or failed and retried), and, once #3470 decides them, dead letter and a receiver's
10
+ * pause starting and ending. Each names the tenant, the app, the scope, the receiver, the channel
11
+ * (the message's kind), the outcome, its timing and the trace id where one is known.
12
+ * - **The broker's state, when it changes** — queue depth, the oldest waiting message's age, paused
13
+ * receivers, dead-letter count. Reported by the broker as it moves, never polled, so an alarm such
14
+ * as "dead letter growing for app X" is a query over these points and needs no pass.
15
+ *
16
+ * **Never content.** No body, no event payload, no error text (a receiver's error may echo what it
17
+ * was given), no event type, no principal: only ids the platform mints (tenant, scope, message,
18
+ * trace), the app's slug, and enumerated steps and outcomes. Exact counts for billing are not these
19
+ * points' job: they come from the broker's own store, into the lake (K-70).
20
+ *
21
+ * **Cost.** A sink write is in-memory and never awaited. A handoff adds one primary-key read per 50
22
+ * ids it carries (`BrokerStore.held`), to tell a new message from a repeat, and keeps the state in
23
+ * memory from there; the one aggregate read (`BrokerStore.stats`) runs once per object wake and once
24
+ * after each delivery pass, beside the pass's own reads. A delivery pass writes one point per
25
+ * attempt (and one per pause change), bounded by `BROKER_DELIVERY_BATCH`, so an invocation stays far
26
+ * under Analytics Engine's per-invocation point limit. A sink that throws drops the point and never fails the broker.
27
+ *
28
+ * **Dead letter and pause** are read off what #3470's store decided: `BrokerStore.failed`'s outcome
29
+ * and the receiver's breaker (`BrokerStore.paused`), after each attempt. A dead letter resent or
30
+ * discarded moves the state, which the adapter settles after the call.
31
+ */
32
+ import type { BrokerMessage, BrokerMessageKind, BrokerStats, BrokerStore, DeliveryObserver, HandOffAnswer } from './delivery-broker.js';
33
+ /**
34
+ * The Analytics Engine dataset binding the broker and the scopes that hand off to it write through.
35
+ * No binding, no points: the broker runs unobserved, as it does with the switch off.
36
+ */
37
+ export declare const BROKER_TELEMETRY_BINDING = "SUBSTRAT_BROKER_TELEMETRY";
38
+ /** Where a message is in its life, as a point names it. `state` is the broker's state report. */
39
+ export type BrokerStep = 'handoff' | 'receipt' | 'delivery' | 'retry' | 'dead-letter' | 'pause-start' | 'pause-end' | 'state';
40
+ /** The outcomes each step may carry: enumerated, so no free text reaches a point. */
41
+ export type BrokerOutcome =
42
+ /** handoff: every message acknowledged. */
43
+ 'acked'
44
+ /** handoff: some acknowledged; the rest go again. */
45
+ | 'partial'
46
+ /** handoff: the broker refused or was unreachable; the scope alarm retries. */
47
+ | 'failed'
48
+ /** receipt: the broker now holds the batch (`duplicates` says how many it held already). */
49
+ | 'stored'
50
+ /** delivery: the receiver took it. */
51
+ | 'delivered'
52
+ /** retry: the attempt failed and the next is scheduled (`wait_ms`). */
53
+ | 'scheduled'
54
+ /** retry: the receiver asked to slow down; nothing spent, the next attempt waits (`wait_ms`). */
55
+ | 'slowed'
56
+ /** dead-letter: the message stops being retried (#3470). */
57
+ | 'dead'
58
+ /** pause-start / pause-end (#3470). */
59
+ | 'paused' | 'resumed'
60
+ /** state: the broker's state moved. */
61
+ | 'changed';
62
+ /** One step, as it leaves. Every count and time is a number; a field not known is null. */
63
+ export interface BrokerPoint {
64
+ step: BrokerStep;
65
+ outcome: BrokerOutcome;
66
+ tenantId: string;
67
+ app: string;
68
+ scopeId: string | null;
69
+ /** The receiver (the subscription's name) a delivery step is about, or a pause is of. */
70
+ receiver: string | null;
71
+ channel: BrokerMessageKind | null;
72
+ /** The W3C trace id (32 hex) of the request that committed, where the step runs inside it. */
73
+ traceId: string | null;
74
+ /** The message, for a step about one. */
75
+ messageId: string | null;
76
+ /** How many messages the point stands for. */
77
+ messages: number;
78
+ /** receipt: how many of them the broker already held. */
79
+ duplicates: number;
80
+ /** The step's own time: the handoff call, the delivery attempt, a pause's length. */
81
+ durationMs: number;
82
+ /** Since the message committed (the oldest of a batch). */
83
+ ageMs: number;
84
+ attempts: number;
85
+ /** retry: until the next attempt. */
86
+ waitMs: number;
87
+ }
88
+ /** The broker's state, as it leaves. */
89
+ export interface BrokerStateReport extends BrokerStats {
90
+ tenantId: string;
91
+ app: string;
92
+ /** Age of the oldest waiting message at the report, or 0 with none. */
93
+ oldestAgeMs: number;
94
+ }
95
+ /** Where points go: Analytics Engine on the Durable Object, a recorder in a test. */
96
+ export interface BrokerTelemetrySink {
97
+ point(point: BrokerPoint): void;
98
+ state(report: BrokerStateReport): void;
99
+ }
100
+ /**
101
+ * Where each field lands in an Analytics Engine data point. **A published shape**, as the scope-work
102
+ * and router layouts are: it only ever GROWS, a new field taking the next ordinal; no position is
103
+ * reordered, renamed or reused. Its own dataset. Every reader filters on `substrat.broker.step`,
104
+ * because state reports and step points share it; a state report's step fields hold their `absent`.
105
+ *
106
+ * "Dead letter growing for app X" reads, for instance:
107
+ * `SELECT index1 AS tenant, blob1 AS app, max(double10) FROM <dataset> WHERE blob2 = 'state'
108
+ * AND timestamp > NOW() - INTERVAL '1' HOUR GROUP BY tenant, app`.
109
+ */
110
+ export declare const BROKER_DATA_POINT_LAYOUT: {
111
+ readonly indexes: readonly [{
112
+ readonly ordinal: 'index1';
113
+ readonly name: 'substrat.tenant.id';
114
+ readonly unit: null;
115
+ readonly absent: '';
116
+ }];
117
+ readonly blobs: readonly [{
118
+ readonly ordinal: 'blob1';
119
+ readonly name: 'substrat.vertical';
120
+ readonly unit: null;
121
+ readonly absent: '';
122
+ }, {
123
+ readonly ordinal: 'blob2';
124
+ readonly name: 'substrat.broker.step';
125
+ readonly unit: null;
126
+ readonly absent: '';
127
+ }, {
128
+ readonly ordinal: 'blob3';
129
+ readonly name: 'substrat.broker.outcome';
130
+ readonly unit: null;
131
+ readonly absent: '';
132
+ }, {
133
+ readonly ordinal: 'blob4';
134
+ readonly name: 'substrat.scope.id';
135
+ readonly unit: null;
136
+ readonly absent: '';
137
+ }, {
138
+ readonly ordinal: 'blob5';
139
+ readonly name: 'substrat.broker.receiver';
140
+ readonly unit: null;
141
+ readonly absent: '';
142
+ }, {
143
+ readonly ordinal: 'blob6';
144
+ readonly name: 'substrat.broker.channel';
145
+ readonly unit: null;
146
+ readonly absent: '';
147
+ }, {
148
+ readonly ordinal: 'blob7';
149
+ readonly name: 'trace.id';
150
+ readonly unit: null;
151
+ readonly absent: '';
152
+ }, {
153
+ readonly ordinal: 'blob8';
154
+ readonly name: 'substrat.message.id';
155
+ readonly unit: null;
156
+ readonly absent: '';
157
+ }];
158
+ readonly doubles: readonly [{
159
+ readonly ordinal: 'double1';
160
+ readonly name: 'substrat.broker.messages';
161
+ readonly unit: '{message}';
162
+ readonly absent: 0;
163
+ }, {
164
+ readonly ordinal: 'double2';
165
+ readonly name: 'substrat.broker.duplicates';
166
+ readonly unit: '{message}';
167
+ readonly absent: 0;
168
+ }, {
169
+ readonly ordinal: 'double3';
170
+ readonly name: 'substrat.broker.duration';
171
+ readonly unit: 'ms';
172
+ readonly absent: 0;
173
+ }, {
174
+ readonly ordinal: 'double4';
175
+ readonly name: 'substrat.broker.age';
176
+ readonly unit: 'ms';
177
+ readonly absent: 0;
178
+ }, {
179
+ readonly ordinal: 'double5';
180
+ readonly name: 'substrat.broker.attempts';
181
+ readonly unit: '{attempt}';
182
+ readonly absent: 0;
183
+ }, {
184
+ readonly ordinal: 'double6';
185
+ readonly name: 'substrat.broker.wait';
186
+ readonly unit: 'ms';
187
+ readonly absent: 0;
188
+ }, {
189
+ readonly ordinal: 'double7';
190
+ readonly name: 'substrat.broker.queue.depth';
191
+ readonly unit: '{message}';
192
+ readonly absent: 0;
193
+ }, {
194
+ readonly ordinal: 'double8';
195
+ readonly name: 'substrat.broker.queue.oldest_age';
196
+ readonly unit: 'ms';
197
+ readonly absent: 0;
198
+ }, {
199
+ readonly ordinal: 'double9';
200
+ readonly name: 'substrat.broker.paused_receivers';
201
+ readonly unit: '{receiver}';
202
+ readonly absent: 0;
203
+ }, {
204
+ readonly ordinal: 'double10';
205
+ readonly name: 'substrat.broker.dead_letters';
206
+ readonly unit: '{message}';
207
+ readonly absent: 0;
208
+ }];
209
+ };
210
+ /** A step point or a state report as the data point it becomes, built from the layout. */
211
+ export declare function brokerDataPoint(record: BrokerPoint | BrokerStateReport): {
212
+ indexes: string[];
213
+ blobs: string[];
214
+ doubles: number[];
215
+ };
216
+ /** The trace id of a W3C `traceparent` (`00-<trace>-<span>-<flags>`), or null. */
217
+ export declare function traceIdOf(traceparent: string | undefined): string | null;
218
+ /**
219
+ * A handoff round's outcome, by how many of the sent messages the broker acknowledged: all, some (the
220
+ * rest go again), or none. Not by whether the marks moved: they stop at the first unacknowledged id,
221
+ * so an answer acknowledging only later ids moves no mark and is still `partial`.
222
+ */
223
+ export declare function handoffOutcome(sent: readonly BrokerMessage[], answer: HandOffAnswer): 'acked' | 'partial' | 'failed';
224
+ /**
225
+ * The scope's side: one point per handoff round, written where the scope calls its broker. A
226
+ * failed round carries what it tried to send. Never throws.
227
+ */
228
+ export declare function reportHandoff(sink: BrokerTelemetrySink, ids: {
229
+ tenantId: string;
230
+ app: string;
231
+ scopeId: string;
232
+ }, round: {
233
+ sent: readonly BrokerMessage[];
234
+ outcome: Extract<BrokerOutcome, 'acked' | 'partial' | 'failed'>;
235
+ startedAt: number;
236
+ at: number;
237
+ traceId: string | null;
238
+ }): void;
239
+ /**
240
+ * The broker's side, over its store: receipts, attempts, the #3470 seams, and the state report.
241
+ * One per broker object. Every method swallows a sink's throw (counted in `dropped`).
242
+ */
243
+ export declare class BrokerTelemetry {
244
+ private readonly store;
245
+ private readonly sink;
246
+ private readonly ids;
247
+ /** Points the sink refused. */
248
+ dropped: number;
249
+ /** The state as last read or moved; null until the first read after a wake. */
250
+ private known;
251
+ private lastReported;
252
+ constructor(store: BrokerStore, sink: BrokerTelemetrySink, ids: {
253
+ tenantId: string;
254
+ app: string;
255
+ });
256
+ /** Before `accept`: which of the messages the store holds already, or null when the read failed (unknown). */
257
+ heldBefore(messages: readonly BrokerMessage[]): Set<string> | null;
258
+ /**
259
+ * After `accept` committed: one receipt per (scope, channel, trace) in the batch (#3474: a message
260
+ * carries the trace it was committed under, so a batch spanning two commits writes two), and the state moved by
261
+ * the new messages in memory (read whole once, on the first receipt after a wake). With `heldBefore`
262
+ * unknown (its probe failed), the receipts count no duplicates and the state is read whole instead.
263
+ */
264
+ received(messages: readonly BrokerMessage[], heldBefore: ReadonlySet<string> | null, at: number): void;
265
+ /**
266
+ * What `runDeliveryPass` tells of each attempt, after the store recorded it: a delivery, a retry
267
+ * (with the wait the store scheduled), a slow-down, or a dead letter; and a receiver's pause starting
268
+ * or ending, read off its breaker (one primary-key read per attempt). The pauses already open when
269
+ * the object woke are read once, when its first pass starts, so one that ends after a wake reports its end
270
+ * (with no length: when it began is not kept) and none is reported starting twice.
271
+ */
272
+ passObserver(): DeliveryObserver;
273
+ /** A receiver's breaker, against what this object last saw: a pause starting or ending is a point. */
274
+ private notePause;
275
+ /** Open pauses, by receiver: when this object saw each start, or null for one open before it woke. */
276
+ private readonly openSince;
277
+ private openLoaded;
278
+ private read;
279
+ /** Read the state whole (`BrokerStore.stats`) and report it if it moved: after a pass, or on wake. */
280
+ settle(at: number): void;
281
+ /** The state as known now, for a staff read (`state()` on the broker); read whole if not yet known. */
282
+ current(at: number): BrokerStateReport;
283
+ private reportOf;
284
+ /** On change only: the same depth, oldest, pauses and dead letters write nothing. */
285
+ private report;
286
+ private about;
287
+ private write;
288
+ }
289
+ //# sourceMappingURL=broker-telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-telemetry.d.ts","sourceRoot":"","sources":["../src/broker-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAExI;;;GAGG;AACH,eAAO,MAAM,wBAAwB,8BAA8B,CAAC;AAEpE,iGAAiG;AACjG,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,SAAS,GACT,UAAU,GACV,OAAO,GACP,aAAa,GACb,aAAa,GACb,WAAW,GACX,OAAO,CAAC;AAEZ,qFAAqF;AACrF,MAAM,MAAM,aAAa;AACvB,2CAA2C;AACzC,OAAO;AACT,qDAAqD;GACnD,SAAS;AACX,+EAA+E;GAC7E,QAAQ;AACV,4FAA4F;GAC1F,QAAQ;AACV,sCAAsC;GACpC,WAAW;AACb,uEAAuE;GACrE,WAAW;AACb,iGAAiG;GAC/F,QAAQ;AACV,4DAA4D;GAC1D,MAAM;AACR,uCAAuC;GACrC,QAAQ,GACR,SAAS;AACX,uCAAuC;GACrC,SAAS,CAAC;AAEd,2FAA2F;AAC3F,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,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