@serve.zone/interfaces 32.97.0 → 32.99.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.
@@ -7,6 +7,9 @@
7
7
  * binding authority.
8
8
  */
9
9
 
10
+ import type { TControllerPeerSetRefusal } from './controller.js';
11
+ import type { TServiceMailSubmissionTlsMode } from './mail.js';
12
+ import type { ISystemSecretOwner, TSecretManagementScope } from './secret.js';
10
13
  import type { IWorkloadReplicaIdentity } from './workloadreplicaidentity.js';
11
14
  import type { TCorestoreDatabaseCredentialKey, TCorestoreObjectStorageCredentialSecretKey } from '../runtime.corestore.js';
12
15
  import type { TObjectStorageEndpointEnvironmentKey } from '../platform/objectstorage.js';
@@ -76,7 +79,16 @@ export type TCoreMailErrorCode =
76
79
  | 'DELIVERY_FAILED'
77
80
  | 'DELIVERY_DEAD_LETTERED'
78
81
  | 'GATEWAY_UNAVAILABLE'
79
- | 'RECONCILIATION_FENCE_MISMATCH';
82
+ | 'RECONCILIATION_FENCE_MISMATCH'
83
+ /**
84
+ * The controller refusals of `judgeControllerPeerSet`, under their own names
85
+ * (`controllerPeerSetRefusals`): `controller-mismatch` for a control authentication whose peer
86
+ * set names another controller than the one CoreMail stored, `controller-epoch-older` for an
87
+ * older epoch, or for no peer set once CoreMail stored one. Answered only to
88
+ * `coreMailAuthenticateControl`, always `retryable: false`, and never written into a
89
+ * reconciliation status (`ICoreMailReconciliationStatus.errorCode`), whose reader refuses them.
90
+ */
91
+ | TControllerPeerSetRefusal;
80
92
 
81
93
  export interface ICoreMailErrorData {
82
94
  code: TCoreMailErrorCode;
@@ -254,6 +266,99 @@ export interface ICoreMailGatewayPeerDesiredState {
254
266
  credentials: ICoreMailBindingCredentialVerifier[];
255
267
  }
256
268
 
269
+ /**
270
+ * One credential a CoreMail instance record names, by identity only. Its plaintext is a system
271
+ * secret of the instance (`createCoreMailInstanceSecretOwnership`, `coreMailInstanceSecretKeys`)
272
+ * and its verifier is the controller's own stored record; neither is ever a member of this record.
273
+ */
274
+ export interface ICoreMailInstanceCredential {
275
+ credentialId: string;
276
+ /** A positive safe integer; a changed version rotates the credential. */
277
+ credentialVersion: number;
278
+ }
279
+
280
+ /** The SMTP submission listener of one CoreMail instance, as its workloads submit to it. */
281
+ export interface ICoreMailInstanceSmtp {
282
+ /** The listener's advertised EHLO hostname and the host workloads submit to (`SMTP_HOST`). */
283
+ host: string;
284
+ /** The listener port inside the CoreMail workload and the port workloads submit to (`SMTP_PORT`). */
285
+ port: number;
286
+ /** What workloads are told to speak to the listener (`SMTP_TLS_MODE`). */
287
+ tlsMode: TServiceMailSubmissionTlsMode;
288
+ }
289
+
290
+ /**
291
+ * One cluster's CoreMail as its controller records it (Linus rulings 249 and 250): the record that
292
+ * replaces the single set of `coreMail*` settings, one per cluster, read exactly by
293
+ * `normalizeCoreMailInstance`.
294
+ *
295
+ * - Identity: `clusterId`. A cluster has at most one record, and a CoreMail serves one cluster, so
296
+ * `coreMailServiceId` is unique across records too. A Service's binding names the instance it
297
+ * was minted on by that service id (`ICoreMailServiceBinding.coreMailServiceId`), which is also
298
+ * the gateway peer key, the control bootstrap's id and every inbound target's id.
299
+ * - Secrets: by reference only. No member carries a secret or a verifier. The four secrets of an
300
+ * instance live under the system owner `createCoreMailInstanceSecretOwnership(clusterId)`
301
+ * answers, keyed by `coreMailInstanceSecretKeys`.
302
+ * - Epochs: `reservedConfigEpoch` is the controller's own counter. The applied epoch is CoreMail's
303
+ * and is not a member: CoreMail answers it at session open (`IReq_CoreMailAuthenticateControl`
304
+ * `appliedConfigEpoch`), and the controller keeps no copy of it (ruling 250 W2).
305
+ * - Not a member: the gateway endpoint CoreMail dials. It is the gateway's, the same for every
306
+ * instance, and stays `ICloudlySettings.coreMailGatewayEndpointUrl` (ruling 250 part 1).
307
+ */
308
+ export interface ICoreMailInstance {
309
+ /** The cluster this CoreMail serves and the record's identity. */
310
+ clusterId: string;
311
+ /** The Service that runs this CoreMail, on a node of `clusterId`. */
312
+ coreMailServiceId: string;
313
+ /**
314
+ * Whether the controller reconciles this CoreMail and binds the cluster's mail-eligible Services
315
+ * to it. `false` keeps the record (credentials, epoch) and leaves the cluster's Services on the
316
+ * dcrouter-direct path, as `coreMailEnabled: false` does today.
317
+ */
318
+ enabled: boolean;
319
+ /** The canonical control socket URL, `https://<host>/socket`, and the workloads' `MAIL_COREMAIL_URL`. */
320
+ controlEndpointUrl: string;
321
+ /** The canonical HTTPS transfer origin, an origin without a path. */
322
+ transferOrigin: string;
323
+ /** The credential the controller authenticates its control session with. */
324
+ controlCredential: ICoreMailInstanceCredential;
325
+ /** The credential this CoreMail authenticates to the gateway with; its own, never shared. */
326
+ gatewayCredential: ICoreMailInstanceCredential;
327
+ /** The SMTP submission listener; `null` keeps the API-only surface. */
328
+ smtp: ICoreMailInstanceSmtp | null;
329
+ /** The limits every binding of this instance carries (`ICoreMailBindingDesiredState.limits`). */
330
+ bindingLimits: ICoreMailBindingDesiredState['limits'];
331
+ /**
332
+ * The last `configEpoch` the controller reserved for this CoreMail, `0` before the first: a
333
+ * non-negative safe integer that never falls. The controller's epoch reservation is its only
334
+ * writer; an administrator's write never states it, and a copied record keeps it, never reset.
335
+ */
336
+ reservedConfigEpoch: number;
337
+ }
338
+
339
+ /**
340
+ * The keys of one CoreMail instance's system secrets, under the owner
341
+ * `createCoreMailInstanceSecretOwnership` answers for its cluster. They are the names the single
342
+ * settings set used (`cloudlySystemSecretKeys.coreMail*`), so each value moves under its instance
343
+ * without a rename, and the SMTP TLS names a desired state carries
344
+ * (`ICoreMailSmtpTlsDesiredState`) stay byte-identical.
345
+ */
346
+ export const coreMailInstanceSecretKeys = Object.freeze({
347
+ controlCredentialSecret: 'COREMAIL_CONTROL_CREDENTIAL_SECRET',
348
+ gatewayCredentialSecret: 'COREMAIL_GATEWAY_CREDENTIAL_SECRET',
349
+ smtpTlsCertificatePem: 'COREMAIL_SMTP_TLS_CERTIFICATE_PEM',
350
+ smtpTlsPrivateKeyPem: 'COREMAIL_SMTP_TLS_PRIVATE_KEY_PEM',
351
+ } as const);
352
+
353
+ /**
354
+ * Where one CoreMail instance's system secrets are kept: the system owner of its cluster and the
355
+ * management scope its secrets carry (`createCoreMailInstanceSecretOwnership`).
356
+ */
357
+ export interface ICoreMailInstanceSecretOwnership {
358
+ owner: ISystemSecretOwner;
359
+ managementScope: TSecretManagementScope;
360
+ }
361
+
257
362
  export interface ICoreMailRuntimeKeyReference {
258
363
  keyId: string;
259
364
  version: number;
@@ -337,6 +442,11 @@ export interface ICoreMailReconciliationStatus {
337
442
  appliedDesiredStateDigest: TCoreMailSha256;
338
443
  bindings: ICoreMailBindingReconciliationStatus[];
339
444
  updatedAt: number;
445
+ /**
446
+ * Present exactly for a `failed` state. Never a controller refusal (`controller-mismatch`,
447
+ * `controller-epoch-older`): CoreMail never writes one into a status, and
448
+ * `normalizeCoreMailReconciliationStatus` refuses a status that carries one.
449
+ */
340
450
  errorCode?: TCoreMailErrorCode;
341
451
  }
342
452
 
@@ -8,12 +8,14 @@ import { readDataProperties } from '../private/dataproperties.js';
8
8
  * record's id from it and answers a create it already stored with that record, so a re-sent create
9
9
  * never makes a second one. First-party callers send one key per user action, never one per
10
10
  * attempt, and never a key derived from the request's content, which would merge two legitimate
11
- * identical creates.
11
+ * identical creates. A create answered from a stored record applies nothing of the re-sent
12
+ * request: the same key with different content is answered with the record as it was stored.
12
13
  *
13
- * The member is optional on `createService`, `createCluster`, `createServiceBackup` and
14
- * `createImage` so callers built before it keep working, and becomes required at the next major of
15
- * this package. A controller built before the member ignores it (those requests have no exact-key
16
- * reader), so a caller that relies on it names the minimum controller that honours it.
14
+ * The member is optional on `createService`, `createCluster`, `createServiceBackup`, `createImage`,
15
+ * `createDnsEntry`, `createExternalRegistry` and `createDomain` so callers built before it keep
16
+ * working, and becomes required at the next major of this package. A controller built before the
17
+ * member ignores it (those requests have no exact-key reader), so a caller that relies on it names
18
+ * the minimum controller that honours it.
17
19
  */
18
20
 
19
21
  /** Bounds of an idempotency key. */
@@ -37,7 +39,8 @@ export const isIdempotencyKey = (valueArg: unknown): valueArg is string => (
37
39
 
38
40
  /**
39
41
  * Every error of the optional `idempotencyKey` of a create request (`createService`,
40
- * `createCluster`, `createServiceBackup`, `createImage`); empty when the request omits the member
42
+ * `createCluster`, `createServiceBackup`, `createImage`, `createDnsEntry`,
43
+ * `createExternalRegistry`, `createDomain`); empty when the request omits the member
41
44
  * (absent or `undefined`, which the wire never carries) or states a valid key. It judges that
42
45
  * member only, never the request's other members.
43
46
  */
package/ts/data/mail.ts CHANGED
@@ -310,6 +310,20 @@ export interface IServiceMailAddressConfig {
310
310
  */
311
311
  export interface ICoreMailServiceBinding {
312
312
  bindingId: string;
313
+ /**
314
+ * The CoreMail this binding was minted on (`ICoreMailInstance.coreMailServiceId`), and so the
315
+ * one that holds its state: its published verifier, pending inbound deliveries, submissions and
316
+ * quota counters. It is a fact about where the binding lives, never re-derived from the
317
+ * Service's placement (Linus ruling 253 point 4). From the controller release that writes it,
318
+ * the controller derives the CoreMail once, at mint, as the CoreMail of the Service's cluster,
319
+ * and then publishes, routes inbound mail to and points `MAIL_COREMAIL_URL` at this CoreMail
320
+ * alone; a Service whose cluster no longer matches is reported and stays served by this CoreMail.
321
+ *
322
+ * Absent on a binding minted before per-cluster CoreMail. The controller's per-cluster data step
323
+ * writes it on every stored binding, and from that step on the controller refuses a binding
324
+ * without it by name and never derives it. It becomes required in the next major.
325
+ */
326
+ coreMailServiceId?: string;
313
327
  credentialId: string;
314
328
  credentialVersion: number;
315
329
  verificationHash: string;
@@ -1,4 +1,5 @@
1
1
  import type { IIdentityCredential } from './user.js';
2
+ import { validateControllerPeerSet, type IControllerPeerSet } from './controller.js';
2
3
  import { isSha256Digest } from './immutableimage.js';
3
4
  import type {
4
5
  IRuntimeAssignmentObservation, IRuntimeAssignmentReference, IRuntimeAssignment,
@@ -75,6 +76,24 @@ export interface IRegisterPalletRuntimeSessionRequest {
75
76
  export interface IRegisterPalletRuntimeSessionResponse {
76
77
  session: IRuntimeSessionBinding;
77
78
  protocol: IProtocolOffer;
79
+ /**
80
+ * The controller's current peer set (`validateControllerPeerSet`, Linus rulings 252 point 9 and
81
+ * 253 point 5), as the relay registration and Spark heartbeat answers carry it. From the Pallet
82
+ * release that admits it, Pallet judges it by `judgeControllerPeerSet` against the peer set it
83
+ * stores on disk. It travels beside the binding, never in it: the binding is compared whole, so
84
+ * a peer set in it would change every session. A local controller states none.
85
+ *
86
+ * This answer is read exactly (`snapshotRegisterPalletRuntimeSessionResponse`) at two hops: by
87
+ * the relay that carries it and again by the node. Pallet 37.0.1 and coreflow 33.5.1 refuse an
88
+ * answer carrying the member, and the failure ends the node's session. So from the Cloudly
89
+ * release that sends it, Cloudly's sender gates it per session, in code, on the existing
90
+ * `IProtocolOffer.interfacesVersion` of the node (its `registerPalletRuntimeSession` request)
91
+ * and of the carrying relay (its `registerClusterRelay` request), stating the member only when
92
+ * both name 32.98.0 or later. No other member states support. The relay registration answer's
93
+ * own `controller` needs no gate: coreflow reads that answer field by field and ignores the
94
+ * member.
95
+ */
96
+ controller?: IControllerPeerSet;
78
97
  }
79
98
 
80
99
  export interface IApplyRuntimeAssignmentRequest {
@@ -305,8 +324,16 @@ export const snapshotRegisterPalletRuntimeSessionRequest = (
305
324
  export const snapshotRegisterPalletRuntimeSessionResponse = (
306
325
  valueArg: unknown,
307
326
  ): IRegisterPalletRuntimeSessionResponse => safe(() => {
308
- const value = record(capture(valueArg), ['session', 'protocol']);
309
- return { session: session(value.session), protocol: readProtocolOffer(value) };
327
+ const value = record(capture(valueArg), ['session', 'protocol'], ['controller']);
328
+ const response: IRegisterPalletRuntimeSessionResponse = {
329
+ session: session(value.session), protocol: readProtocolOffer(value),
330
+ };
331
+ if (Object.hasOwn(value, 'controller')) {
332
+ requireValue(validateControllerPeerSet(value.controller).length === 0);
333
+ // `capture` already made an inert copy; the peer set's own validator judged it exactly.
334
+ response.controller = value.controller as IControllerPeerSet;
335
+ }
336
+ return response;
310
337
  });
311
338
 
312
339
  export const snapshotApplyRuntimeAssignmentRequest = (
@@ -17,6 +17,7 @@ import type {
17
17
  TCoreMailSha256,
18
18
  TCoreMailWorkloadOperation,
19
19
  } from '../data/coremail.js';
20
+ import type { IControllerPeerSet } from '../data/controller.js';
20
21
  import type { IMailConnectionInfo } from '../data/mail.js';
21
22
  import type { IWorkloadReplicaIdentity } from '../data/workloadreplicaidentity.js';
22
23
 
@@ -182,6 +183,26 @@ export interface IReq_CoreMailAuthenticateControl extends plugins.typedrequestIn
182
183
  credentialId: string;
183
184
  credentialVersion: number;
184
185
  credentialSecret: string;
186
+ /**
187
+ * The controller's current peer set (Linus rulings 250 W1, 252 point 9 and 253): the one
188
+ * controller contract, read by `data.validateControllerPeerSet` and admitted by
189
+ * `data.judgeControllerPeerSet` against the peer set CoreMail stored, exactly as a gateway, a
190
+ * relay and a node admit it. CoreMail stores the peer set and never dials an origin in it.
191
+ *
192
+ * CoreMail judges it only after the credential verified. A credential failure still closes the
193
+ * socket with 4401 unanswered. The two controller refusals, `controller-mismatch` and
194
+ * `controller-epoch-older`, are answered as `ICoreMailErrorData` codes (`retryable: false`),
195
+ * and then the session is closed. A peer set at a higher epoch is stored durably beside
196
+ * CoreMail's applied state before anything is admitted at that epoch, and CoreMail closes its
197
+ * control sessions of a lower epoch.
198
+ *
199
+ * Optional on the wire until the next major, where it becomes required. A CoreMail without the
200
+ * check ignores it. A CoreMail with the check stores the first peer set stated after the
201
+ * credential verified, and accepts a session without one only while it has stored none, so the
202
+ * check stays inert until the controller states itself; from then on a session without it is
203
+ * refused `controller-epoch-older`.
204
+ */
205
+ controller?: IControllerPeerSet;
185
206
  };
186
207
  response: {
187
208
  authenticated: true;
@@ -192,6 +213,16 @@ export interface IReq_CoreMailAuthenticateControl extends plugins.typedrequestIn
192
213
  * `ICoreMailReplicaIdentity` from an earlier CoreMail (`normalizeCoreMailReplicaIdentity`).
193
214
  */
194
215
  replica: IWorkloadReplicaIdentity | ICoreMailReplicaIdentity;
216
+ /**
217
+ * The `configEpoch` of the desired state CoreMail has applied when the session opens, `0` when
218
+ * it has applied none (`data.normalizeCoreMailControlAppliedConfigEpoch`): never an error. It is
219
+ * the `expectedAppliedConfigEpoch` the controller's next preparation states, and the controller
220
+ * reserves above the greater of it and its own reserved epoch (Linus ruling 250 W2).
221
+ *
222
+ * Absent from a CoreMail built before this member. A reader that needs it reads its absence as
223
+ * "not stated" and never as `0`: assuming `0` is the restart lock-out ruling 250 W2 removes.
224
+ */
225
+ appliedConfigEpoch?: number;
195
226
  };
196
227
  }
197
228
 
@@ -41,6 +41,15 @@ extends plugins.typedrequestInterfaces.implementsTR<
41
41
  request: {
42
42
  identity: IIdentity;
43
43
  dnsEntryData: IDnsEntry['data'];
44
+ /**
45
+ * Names the user action this create belongs to (`data.isIdempotencyKey`,
46
+ * `data.validateCreateIdempotencyKey`): a create sent again with the same key, after an answer
47
+ * that never arrived or one named `outcome-unknown`, is answered with the DNS entry the first one
48
+ * stored instead of creating a second. One key per user action, never per attempt. Optional in
49
+ * this major so callers built before it keep working; required at the next major. A controller
50
+ * built before the member ignores it.
51
+ */
52
+ idempotencyKey?: string;
44
53
  };
45
54
  response: {
46
55
  dnsEntry: IDnsEntry;
@@ -40,6 +40,15 @@ extends plugins.typedrequestInterfaces.implementsTR<
40
40
  request: {
41
41
  identity: IIdentity;
42
42
  domainData: IDomain['data'];
43
+ /**
44
+ * Names the user action this create belongs to (`data.isIdempotencyKey`,
45
+ * `data.validateCreateIdempotencyKey`): a create sent again with the same key, after an answer
46
+ * that never arrived or one named `outcome-unknown`, is answered with the domain the first one
47
+ * stored instead of creating a second. One key per user action, never per attempt. Optional in
48
+ * this major so callers built before it keep working; required at the next major. A controller
49
+ * built before the member ignores it.
50
+ */
51
+ idempotencyKey?: string;
43
52
  };
44
53
  response: {
45
54
  domain: IDomain;
@@ -37,6 +37,15 @@ export interface IReq_CreateRegistry extends plugins.typedrequestInterfaces.impl
37
37
  request: {
38
38
  identity: userInterfaces.IIdentity;
39
39
  registryData: data.IExternalRegistry['data'];
40
+ /**
41
+ * Names the user action this create belongs to (`data.isIdempotencyKey`,
42
+ * `data.validateCreateIdempotencyKey`): a create sent again with the same key, after an answer
43
+ * that never arrived or one named `outcome-unknown`, is answered with the registry the first one
44
+ * stored instead of creating a second. One key per user action, never per attempt. Optional in
45
+ * this major so callers built before it keep working; required at the next major. A controller
46
+ * built before the member ignores it.
47
+ */
48
+ idempotencyKey?: string;
40
49
  };
41
50
  response: {
42
51
  registry: data.IExternalRegistryPublic;