@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,115 @@
1
+ /**
2
+ * Subject erasure in the broker relay's tables (#3484 for #3469, K-37, K-74): the relay's half of
3
+ * `eraseSubjectFromBroker`, which calls it, and of the screen a late arrival meets.
4
+ *
5
+ * What the relay keeps that can carry a subject is a request's or a reply's body, which the two apps'
6
+ * host code write and the platform does not classify, and the text of a failure about one. Neither is
7
+ * a spine row with a subject column, so a body is judged the way `broker-erasure.ts` judges a body it
8
+ * cannot read as a row: one that names the subject is replaced whole, failing closed. An event is not
9
+ * reached: a relayed event crosses only classified `none`, which the spine never redacts, and a copy
10
+ * judged more harshly than its original is an incoherent rule. Its row in `broker_messages` is
11
+ * `eraseSubjectFromBroker`'s.
12
+ *
13
+ * Each place is reached for the scope it belongs to: what a scope of this app sent (`outgoing`), what
14
+ * one of its scopes waits for (`waits`), and what another app relayed to one of its scopes (`inbox`,
15
+ * by the envelope's `target`). The tombstone `eraseSubjectFromBroker` leaves closes the race: what is
16
+ * stored after it, on the way out or on arrival, goes through `screenRelayBody` first.
17
+ */
18
+ import { REDACTED_FAILURE_NOTE, REDACTED_INTENT_MARKER, redactedIntentPayload } from './subject-redaction.js';
19
+ /** The relay's columns that can hold content or text about it, which `BROKER_CONTENT_COLUMNS` lists. */
20
+ export const RELAY_CONTENT_COLUMNS = [
21
+ { table: 'broker_relay_hops', column: 'last_error' },
22
+ { table: 'broker_relay_outgoing', column: 'body' },
23
+ { table: 'broker_relay_outgoing', column: 'last_error' },
24
+ { table: 'broker_relay_inbox', column: 'envelope_body' },
25
+ { table: 'broker_relay_inbox', column: 'last_error' },
26
+ { table: 'broker_waits', column: 'reply_body' },
27
+ { table: 'broker_waits', column: 'resume_error' },
28
+ ];
29
+ /**
30
+ * Is this value exactly the marker an erasure of this subject writes, and nothing else? The key alone
31
+ * is no proof: an app's body may carry it with content inside. Only the marker's own shape is, since
32
+ * a body that is exactly that shape holds nothing but the subject's id and an instant, which is all
33
+ * the marker itself holds.
34
+ */
35
+ function isMarkerFor(v, subjectId) {
36
+ if (typeof v !== 'object' || v === null || Array.isArray(v))
37
+ return false;
38
+ if (Object.keys(v).length !== 1 || !(REDACTED_INTENT_MARKER in v))
39
+ return false;
40
+ const m = v[REDACTED_INTENT_MARKER];
41
+ if (typeof m !== 'object' || m === null || Array.isArray(m))
42
+ return false;
43
+ const keys = Object.keys(m).sort();
44
+ const r = m;
45
+ return keys.join() === 'at,reason,subjectId' && r.reason === 'subject-erasure' && r.subjectId === subjectId && typeof r.at === 'string';
46
+ }
47
+ /** A request's or reply's body without the subject: the marker when it names them, else null. */
48
+ export function relayBodyWithoutSubject(body, subjectId, at) {
49
+ if (isMarkerFor(body, subjectId))
50
+ return null;
51
+ return JSON.stringify(body ?? null).includes(subjectId) ? JSON.parse(redactedIntentPayload(subjectId, at)) : null;
52
+ }
53
+ /** A body about to be stored for a scope, with every subject tombstoned there taken out of it. */
54
+ export function screenRelayBody(sql, tenantId, scopeId, body) {
55
+ const text = JSON.stringify(body ?? null);
56
+ for (const t of sql.all('SELECT subject_id, erased_at FROM broker_erased_subjects WHERE tenant_id = ? AND scope_id = ?', tenantId, scopeId)) {
57
+ if (!text.includes(t.subject_id))
58
+ continue;
59
+ const redacted = relayBodyWithoutSubject(body, t.subject_id, t.erased_at);
60
+ if (redacted !== null)
61
+ return redacted;
62
+ }
63
+ return body;
64
+ }
65
+ /**
66
+ * A failure's text about to be stored for a scope: the redacted note when it names a subject tombstoned
67
+ * there. A call that was out when the erasure ran may fail with the content in its message, and that
68
+ * text is written after the erasure's own rewrite.
69
+ */
70
+ export function screenRelayError(sql, tenantId, scopeId, text) {
71
+ for (const t of sql.all('SELECT subject_id FROM broker_erased_subjects WHERE tenant_id = ? AND scope_id = ?', tenantId, scopeId)) {
72
+ if (text.includes(t.subject_id))
73
+ return REDACTED_FAILURE_NOTE;
74
+ }
75
+ return text;
76
+ }
77
+ /**
78
+ * Erase one subject from the relay's tables, for one scope of this app. `rewritten` is the message
79
+ * ids `eraseSubjectFromBroker` redacted, whose hops' error texts go with them. Idempotent.
80
+ */
81
+ export function eraseSubjectFromRelay(sql, target, rewritten) {
82
+ const { tenantId, scopeId, subjectId, at } = target;
83
+ const note = (table, column, where, ...params) => sql.run(`UPDATE ${table} SET ${column} = ? WHERE ${column} IS NOT NULL AND ${column} != ? AND instr(${column}, ?) > 0 AND ${where}`, REDACTED_FAILURE_NOTE, REDACTED_FAILURE_NOTE, subjectId, ...params);
84
+ // What a scope of this app sent: a request or a reply, as its host code wrote it.
85
+ for (const r of sql.all('SELECT id, body FROM broker_relay_outgoing WHERE tenant_id = ? AND scope_id = ? AND instr(body, ?) > 0', tenantId, scopeId, subjectId)) {
86
+ const body = relayBodyWithoutSubject(JSON.parse(r.body), subjectId, at);
87
+ if (body !== null)
88
+ sql.run('UPDATE broker_relay_outgoing SET body = ? WHERE id = ?', JSON.stringify(body), r.id);
89
+ }
90
+ note('broker_relay_outgoing', 'last_error', 'tenant_id = ? AND scope_id = ?', tenantId, scopeId);
91
+ // The reply a scope of this app was answered with.
92
+ for (const w of sql.all('SELECT request_id, reply_body FROM broker_waits WHERE tenant_id = ? AND scope_id = ? AND instr(reply_body, ?) > 0', tenantId, scopeId, subjectId)) {
93
+ const reply = JSON.parse(w.reply_body);
94
+ const body = relayBodyWithoutSubject(reply.body, subjectId, at);
95
+ if (body !== null)
96
+ sql.run('UPDATE broker_waits SET reply_body = ? WHERE request_id = ?', JSON.stringify({ ...reply, body }), w.request_id);
97
+ }
98
+ note('broker_waits', 'resume_error', 'tenant_id = ? AND scope_id = ?', tenantId, scopeId);
99
+ // What another app relayed to a scope of this app. An event's body is left (see the header).
100
+ const inboxOf = `json_extract(envelope_body, '$.tenantId') = ? AND json_extract(envelope_body, '$.target.scopeId') = ?`;
101
+ for (const r of sql.all(`SELECT caller_app, id, envelope_body FROM broker_relay_inbox WHERE kind != 'event' AND ${inboxOf} AND instr(envelope_body, ?) > 0`, tenantId, scopeId, subjectId)) {
102
+ const envelope = JSON.parse(r.envelope_body);
103
+ const body = relayBodyWithoutSubject(envelope.message.body, subjectId, at);
104
+ if (body === null)
105
+ continue;
106
+ sql.run('UPDATE broker_relay_inbox SET envelope_body = ? WHERE caller_app = ? AND id = ?', JSON.stringify({ ...envelope, message: { ...envelope.message, body } }), r.caller_app, r.id);
107
+ }
108
+ note('broker_relay_inbox', 'last_error', inboxOf, tenantId, scopeId);
109
+ // An event's hops: their error text goes with a rewritten message, and wherever it names the subject.
110
+ sql.run(`UPDATE broker_relay_hops SET last_error = ?
111
+ WHERE last_error IS NOT NULL AND last_error != ?
112
+ AND message_id IN (SELECT id FROM broker_messages WHERE tenant_id = ? AND scope_id = ?)
113
+ AND (message_id IN (SELECT value FROM json_each(?)) OR instr(last_error, ?) > 0)`, REDACTED_FAILURE_NOTE, REDACTED_FAILURE_NOTE, tenantId, scopeId, JSON.stringify(rewritten), subjectId);
114
+ }
115
+ //# sourceMappingURL=broker-relay-erasure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-relay-erasure.js","sourceRoot":"","sources":["../src/broker-relay-erasure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAG9G,wGAAwG;AACxG,MAAM,CAAC,MAAM,qBAAqB,GAAiD;IACjF,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,YAAY,EAAE;IACpD,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,EAAE;IAClD,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,EAAE,YAAY,EAAE;IACxD,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,eAAe,EAAE;IACxD,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,YAAY,EAAE;IACrD,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE;IAC/C,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE;CAClD,CAAC;AAEF;;;;;GAKG;AACH,SAAS,WAAW,CAAC,CAAU,EAAE,SAAiB;IAChD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1E,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,sBAAsB,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAChF,MAAM,CAAC,GAAI,CAA6B,CAAC,sBAAsB,CAAC,CAAC;IACjE,IAAI,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AAQ,EAAE,OAAO,EAAE,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,EACvE,CAAC,CAAC,UAAU,EACZ,CAAC,CAAC,EAAE,CACL,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,oBAAoB,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAErE,sGAAsG;IACtG,GAAG,CAAC,GAAG,CACL;;;yFAGqF,EACrF,qBAAqB,EACrB,qBAAqB,EACrB,QAAQ,EACR,OAAO,EACP,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EACzB,SAAS,CACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,292 @@
1
+ /**
2
+ * Broker to broker, and request-reply (K-74, rfc/broker-and-tenant-isolation.md §4.3–§4.4, #3469).
3
+ *
4
+ * A delivery broker (`delivery-broker.ts`) owns what its app's scopes handed off. This is how it
5
+ * hands a message to ANOTHER app of the tenant: through the router, to the receiving app's broker,
6
+ * which delivers to its own scope. Every hop acknowledges and drops a duplicate by message id:
7
+ *
8
+ * scope → broker `BrokerStore.accept`, by id (A1)
9
+ * broker → router → broker the sender keeps one row per (message, receiving app), so a retried
10
+ * message goes again only where it was not accepted; the receiver keeps
11
+ * one row per (calling app, message), so a repeat is acknowledged and
12
+ * nothing is stored twice
13
+ * broker → scope the receiving broker keeps whether it delivered, and the scope's
14
+ * import door journals by event id besides (#1705)
15
+ *
16
+ * The router stores nothing. It names the caller from what it verified (K-66's three lines), and
17
+ * resolves the receiving instance by the peer call's rule.
18
+ *
19
+ * **What crosses is decided at each end by that end's own running code, as #1705 decides it.** An
20
+ * event leaves only through the producer scope's export read (`RelayExports.exportOne`), so the
21
+ * same `exports` declaration, `readPermission`, classification, version and cascade rules that
22
+ * decide a pulled batch decide a pushed message, and a withheld row is named without its payload.
23
+ * The receiving scope's import door then admits the producer as a peer, as it does today. The
24
+ * broker carries what those doors released and parses only the envelope.
25
+ *
26
+ * **Request-reply.** The sending broker records who waits (the scope, and a resume target) and a
27
+ * deadline. A reply is paired with its request on arrival, judged against the deadline by the
28
+ * clock at that moment, not by whether an expiry pass has run: a reply at or after the deadline is
29
+ * refused and logged, never applied (K-62). Expiry and pairing each move a wait out of `waiting`
30
+ * with one conditional write, so exactly one of them wins a race, and the resume target is handed
31
+ * one outcome, once. The resume target is generic: a K-62 attempt's record operation today, a
32
+ * kernel process (Track C) later.
33
+ *
34
+ * Everything here is synchronous over the broker's own SQLite (`BrokerSql`) except the four seams,
35
+ * which an adapter provides. Nothing runs unless an adapter is given a relay, which no deployment
36
+ * is yet: the broker's switch is the binding (#3483), and the relay is a further option on it.
37
+ */
38
+ import type { ExportedEvent, RelayAnswer, BrokerRelayCaller, RelayEnvelope, RelayHandoff, WithheldEvent } from '@substrat-run/contracts';
39
+ import { type BrokerMessage, type BrokerSql, type DeliveryReceiver } from './delivery-broker.js';
40
+ /**
41
+ * The router, as a sending broker reaches it. Who is calling is the transport's to name, from the
42
+ * dispatch it runs under, never an argument: neither method takes the calling app.
43
+ */
44
+ export interface RelayRouter {
45
+ /** The apps of the tenant that subscribe to `type` from the calling app, from the installation. */
46
+ subscribers(input: {
47
+ tenantId: string;
48
+ type: string;
49
+ }): Promise<readonly string[]>;
50
+ /** Carry one message to one app's broker. A throw is a failure, retried; an answer is final. */
51
+ forward(tenantId: string, handoff: RelayHandoff): Promise<RelayAnswer>;
52
+ }
53
+ /** The producer scope's own export read, for one event and one consumer (#1705's rules, unchanged). */
54
+ export type ExportOutcome = {
55
+ outcome: 'released';
56
+ event: ExportedEvent;
57
+ } | {
58
+ outcome: 'withheld';
59
+ withheld: WithheldEvent;
60
+ }
61
+ /** The producer does not export the type: it is never relayed, and this is final. */
62
+ | {
63
+ outcome: 'unexported';
64
+ }
65
+ /** The consumer lacks a key it needs here. Authority can change, so this is retried, never final. */
66
+ | {
67
+ outcome: 'paused';
68
+ missing: readonly string[];
69
+ };
70
+ export interface RelayExports {
71
+ exportOne(input: {
72
+ tenantId: string;
73
+ scopeId: string;
74
+ consumer: string;
75
+ message: BrokerMessage;
76
+ }): Promise<ExportOutcome>;
77
+ }
78
+ /** The receiving broker's delivery to its own scope. A throw is a failure, retried. */
79
+ export interface RelayLocal {
80
+ deliver(envelope: RelayEnvelope): Promise<void>;
81
+ }
82
+ /** Where a request's outcome is handed: a K-62 attempt's record operation, in the waiting scope. */
83
+ export interface ResumeTarget {
84
+ operation: string;
85
+ attemptId: string;
86
+ }
87
+ export type ResumeResult = {
88
+ outcome: 'answered';
89
+ reply: {
90
+ id: string;
91
+ type: string;
92
+ body: unknown;
93
+ from: BrokerRelayCaller;
94
+ };
95
+ }
96
+ /** The deadline passed, or the request could not be carried. The attempt is abandoned (K-62). */
97
+ | {
98
+ outcome: 'expired';
99
+ reason: 'deadline' | 'no-broker' | 'refused';
100
+ };
101
+ export interface RelayResume {
102
+ /** A throw is a failure, retried: the outcome is decided already and only its handing over repeats. */
103
+ resume(input: {
104
+ tenantId: string;
105
+ scopeId: string;
106
+ requestId: string;
107
+ target: ResumeTarget;
108
+ result: ResumeResult;
109
+ }): Promise<void>;
110
+ }
111
+ /**
112
+ * The subscription an adapter registers the relay under (`BrokerRelay.receiver`). Its deliveries
113
+ * have the store's retries, pause and dead letter (A4) like any receiver's.
114
+ */
115
+ export declare const RELAY_SUBSCRIPTION = "relay";
116
+ /** The waits after each failure of a relay row of its own: a request or reply sent, a delivery to the scope, a resume. */
117
+ export declare const RELAY_RETRY_MS: readonly number[];
118
+ /** The longest a request may wait. A deadline past it is refused at `request`. */
119
+ export declare const BROKER_WAIT_MAX_MS: number;
120
+ /** How many items of each kind one relay pass attempts before it yields. */
121
+ export declare const RELAY_PASS_BATCH = 50;
122
+ /**
123
+ * How long a settled relay row is kept: the window a repeated hop is recognised in. Past it a
124
+ * repeat is stored again, and the scope's door is what still drops it (#1705's journal).
125
+ */
126
+ export declare const RELAY_RETENTION_MS: number;
127
+ /**
128
+ * The relay's own tables are step 4 of `BROKER_SCHEMA` (broker-schema.ts), beside the store's and
129
+ * touching none of them. What each holds is written there.
130
+ */
131
+ export type HopState = 'owed' | 'accepted' | 'no-broker' | 'refused' | 'unexported';
132
+ export interface RelayHop {
133
+ app: string;
134
+ state: HopState;
135
+ attempts: number;
136
+ lastError: string | null;
137
+ }
138
+ export interface WaitRecord {
139
+ requestId: string;
140
+ tenantId: string;
141
+ scopeId: string;
142
+ toApp: string;
143
+ target: ResumeTarget;
144
+ deadline: number;
145
+ state: 'waiting' | 'answered' | 'expired';
146
+ reason: string | null;
147
+ replyId: string | null;
148
+ resumedAt: number | null;
149
+ }
150
+ /** What a scope's host code asks its broker to send and wait for. */
151
+ export interface RelayRequest {
152
+ id: string;
153
+ tenantId: string;
154
+ scopeId: string;
155
+ to: string;
156
+ type: string;
157
+ body: unknown;
158
+ /** Epoch ms the requester stops waiting. */
159
+ deadline: number;
160
+ resume: ResumeTarget;
161
+ }
162
+ /** What the receiving app's host code sends back. */
163
+ export interface RelayReply {
164
+ id: string;
165
+ tenantId: string;
166
+ scopeId: string;
167
+ /** The requesting app, as the request's envelope named it (`caller.app`). */
168
+ to: string;
169
+ requestId: string;
170
+ type: string;
171
+ body: unknown;
172
+ }
173
+ /** One relay pass's outcome. */
174
+ export interface RelayPass {
175
+ sent: number;
176
+ delivered: number;
177
+ expired: number;
178
+ resumed: number;
179
+ failed: number;
180
+ nextAt: number | null;
181
+ }
182
+ export interface BrokerRelayOptions {
183
+ router: RelayRouter;
184
+ exports: RelayExports;
185
+ local: RelayLocal;
186
+ resume: RelayResume;
187
+ now?: () => number;
188
+ /** The waits after each failure of the relay's own rows. Defaults to `RELAY_RETRY_MS`. */
189
+ retryMs?: readonly number[];
190
+ /** The longest a request may wait. Defaults to `BROKER_WAIT_MAX_MS`. */
191
+ maxWaitMs?: number;
192
+ /** How long a settled row is kept. Defaults to `RELAY_RETENTION_MS`. */
193
+ retentionMs?: number;
194
+ /** One structured line per refusal and expiry. Defaults to a JSON console line. */
195
+ log?: (line: Record<string, unknown>) => void;
196
+ }
197
+ /**
198
+ * One broker's relay: the sending half (`receiver`, `request`, `reply`), the receiving half
199
+ * (`accept`), and the pass that drives both (`pass`). An adapter keeps one per broker.
200
+ */
201
+ export declare class BrokerRelay {
202
+ private readonly sql;
203
+ private readonly opts;
204
+ private readonly now;
205
+ private readonly retryMs;
206
+ private readonly log;
207
+ constructor(sql: BrokerSql, opts: BrokerRelayOptions);
208
+ /**
209
+ * The receiver an adapter registers as `RELAY_SUBSCRIPTION`: an event goes to every subscribing
210
+ * app, and an intent is nothing to relay. A throw is the store's to retry (A4's policy), and the
211
+ * retry carries the event again only to an app that did not accept it.
212
+ */
213
+ receiver(): DeliveryReceiver;
214
+ private relayEvent;
215
+ private resolved;
216
+ private settleHop;
217
+ /** The per-app state of one relayed event. */
218
+ hops(messageId: string): RelayHop[];
219
+ /**
220
+ * Record a wait and the request that answers it, to be sent on the next pass. Idempotent by id: a
221
+ * repeat returns the wait as it stands and stores nothing.
222
+ */
223
+ request(req: RelayRequest): WaitRecord;
224
+ /** Send a reply to a request this app received. Idempotent by id. */
225
+ reply(rep: RelayReply): void;
226
+ private insertOutgoing;
227
+ /** A request's wait, or null. */
228
+ waitOf(requestId: string): WaitRecord | null;
229
+ private waitRow;
230
+ /** The state of a request or reply this broker originated. */
231
+ outgoingState(id: string): string | null;
232
+ /**
233
+ * Take a message another app's broker relayed here: once per (calling app, id), and every repeat
234
+ * answered as the first was. A reply is paired here, against the clock now; an event or request
235
+ * is delivered to the scope by the next pass. Synchronous, in one storage transaction.
236
+ */
237
+ accept(envelope: RelayEnvelope): RelayAnswer;
238
+ /** Pair a reply with its wait: the reason it is refused, or null when it answered the wait. */
239
+ private pair;
240
+ /** Move a wait from `waiting` to `expired`. One conditional write, so it never overtakes a reply. */
241
+ private expire;
242
+ /**
243
+ * One pass: expire what is past its deadline, send what is due, deliver what arrived to the scope,
244
+ * and hand each settled wait to its resume target. Every item is leased before its await (its next
245
+ * attempt moved out by the first retry step), so a pass that overlaps another does not repeat it.
246
+ */
247
+ pass(limit?: number): Promise<RelayPass>;
248
+ private lease;
249
+ private sendDue;
250
+ private settleOutgoing;
251
+ private retryLater;
252
+ private deliverInbound;
253
+ private resumeSettled;
254
+ /**
255
+ * Epoch ms the relay next has work: a send, a delivery or a resume due, a deadline, or a settled
256
+ * row whose retention runs out. Null when it holds nothing.
257
+ */
258
+ nextWakeAt(): number | null;
259
+ /**
260
+ * Drop what is settled and older than the retention: the window a repeat is recognised in. An
261
+ * event's hops go once every hop is settled. A wait goes once its outcome was handed over.
262
+ */
263
+ prune(now: number): void;
264
+ }
265
+ /**
266
+ * The greatest id below `id` in ULID order, or null when there is none. An exclusive `after` read
267
+ * from it starts at `id` itself, which is how a single event is read through #1705's export read.
268
+ */
269
+ export declare function idJustBefore(id: string): string | null;
270
+ /**
271
+ * `RelayExports.exportOne` over a host's export read (`readExportedEvents`, #1705): the same read,
272
+ * for one row and one consumer, at the row's own version (the consumer's door judges the version
273
+ * it takes). A read that answers some other row is refused rather than relayed.
274
+ */
275
+ export declare function exportOneVia(read: (input: {
276
+ tenantId: string;
277
+ scopeId: string;
278
+ consumer: string;
279
+ after: string | null;
280
+ wants: {
281
+ type: string;
282
+ schemaVersion: number;
283
+ }[];
284
+ }) => Promise<{
285
+ events: readonly ExportedEvent[];
286
+ withheld: readonly WithheldEvent[];
287
+ unexported: readonly unknown[];
288
+ paused: {
289
+ missing: readonly string[];
290
+ } | null;
291
+ }>): RelayExports['exportOne'];
292
+ //# sourceMappingURL=broker-relay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-relay.d.ts","sourceRoot":"","sources":["../src/broker-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,YAAY,EAGZ,aAAa,EACd,MAAM,yBAAyB,CAAC;AAGjC,OAAO,E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