@serve.zone/interfaces 32.96.0 → 32.98.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 (38) hide show
  1. package/changelog.md +19 -0
  2. package/dist_ts/00_commitinfo_data.js +1 -1
  3. package/dist_ts/data/coremail.d.ts +106 -1
  4. package/dist_ts/data/coremail.js +14 -1
  5. package/dist_ts/data/coremail.runtime.d.ts +25 -1
  6. package/dist_ts/data/coremail.runtime.js +106 -2
  7. package/dist_ts/data/idempotencykey.d.ts +20 -0
  8. package/dist_ts/data/idempotencykey.js +47 -0
  9. package/dist_ts/data/index.d.ts +2 -0
  10. package/dist_ts/data/index.js +3 -1
  11. package/dist_ts/data/mail.d.ts +14 -0
  12. package/dist_ts/data/mail.js +1 -1
  13. package/dist_ts/data/outcomeunknown.d.ts +31 -0
  14. package/dist_ts/data/outcomeunknown.js +43 -0
  15. package/dist_ts/data/runtimesession.d.ts +19 -0
  16. package/dist_ts/data/runtimesession.js +12 -3
  17. package/dist_ts/data/witness.js +6 -4
  18. package/dist_ts/requests/backup.d.ts +9 -0
  19. package/dist_ts/requests/cluster.d.ts +9 -0
  20. package/dist_ts/requests/coremail.d.ts +31 -0
  21. package/dist_ts/requests/image.d.ts +9 -0
  22. package/dist_ts/requests/service.d.ts +9 -0
  23. package/package.json +1 -1
  24. package/readme.md +95 -4
  25. package/ts/00_commitinfo_data.ts +1 -1
  26. package/ts/data/coremail.runtime.ts +152 -2
  27. package/ts/data/coremail.ts +111 -1
  28. package/ts/data/idempotencykey.ts +51 -0
  29. package/ts/data/index.ts +2 -0
  30. package/ts/data/mail.ts +14 -0
  31. package/ts/data/outcomeunknown.ts +71 -0
  32. package/ts/data/runtimesession.ts +29 -2
  33. package/ts/data/witness.ts +5 -3
  34. package/ts/requests/backup.ts +9 -0
  35. package/ts/requests/cluster.ts +9 -0
  36. package/ts/requests/coremail.ts +31 -0
  37. package/ts/requests/image.ts +9 -0
  38. package/ts/requests/service.ts +9 -0
@@ -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 = (
@@ -8,6 +8,7 @@ import { readDataElements, readExactDataRecord } from '../private/dataproperties
8
8
  import { isCanonicalBase64url32, isSha256Hex } from '../private/bearerencoding.js';
9
9
  import type { TCompleteKeyList } from '../private/keylist.js';
10
10
  import { controllerPeerSetContract } from './controller.js';
11
+ import { outcomeUnknownCode } from './outcomeunknown.js';
11
12
  import { isReleaseVersion } from './releaseversion.js';
12
13
 
13
14
  /**
@@ -240,9 +241,10 @@ export const witnessRefusals = Object.freeze([
240
241
  'witness-unavailable',
241
242
  /**
242
243
  * Momentary: the witness sent the change to its storage and does not know whether it was stored.
243
- * Read the record before acting on the change or sending another.
244
+ * Read the record before acting on the change or sending another. The general operator-facing
245
+ * name of an unknown write outcome (`outcomeUnknownCode`), so the two cannot drift apart.
244
246
  */
245
- 'outcome-unknown',
247
+ outcomeUnknownCode,
246
248
  ] as const);
247
249
 
248
250
  /** One of the reasons the witness answers instead of a request. */
@@ -251,7 +253,7 @@ export type TWitnessRefusal = typeof witnessRefusals[number];
251
253
  /** The refusals that describe the witness's own state rather than a judgement of the request. */
252
254
  export const witnessMomentaryRefusals = Object.freeze([
253
255
  'witness-unavailable',
254
- 'outcome-unknown',
256
+ outcomeUnknownCode,
255
257
  ] as const satisfies readonly TWitnessRefusal[]);
256
258
 
257
259
  /** One of the momentary witness refusals. */
@@ -33,6 +33,15 @@ extends plugins.typedrequestInterfaces.implementsTR<
33
33
  clusterId?: string;
34
34
  tags?: Record<string, string>;
35
35
  replicate?: boolean;
36
+ /**
37
+ * Names the user action this create belongs to (`data.isIdempotencyKey`,
38
+ * `data.validateCreateIdempotencyKey`): a create sent again with the same key, after an answer
39
+ * that never arrived or one named `outcome-unknown`, is answered with the record the first one
40
+ * stored instead of creating a second. One key per user action, never per attempt. Optional in
41
+ * this major so callers built before it keep working; required at the next major. A controller
42
+ * built before the member ignores it.
43
+ */
44
+ idempotencyKey?: string;
36
45
  };
37
46
  response: {
38
47
  backup: IBackupRecord;
@@ -69,6 +69,15 @@ export interface IRequest_CreateCluster extends plugins.typedrequestInterfaces.i
69
69
  * makes no node leaves the cluster empty, standing nowhere.
70
70
  */
71
71
  locationId?: string;
72
+ /**
73
+ * Names the user action this create belongs to (`data.isIdempotencyKey`,
74
+ * `data.validateCreateIdempotencyKey`): a create sent again with the same key, after an answer
75
+ * that never arrived or one named `outcome-unknown`, is answered with the record the first one
76
+ * stored instead of creating a second. One key per user action, never per attempt. Optional in
77
+ * this major so callers built before it keep working; required at the next major. A controller
78
+ * built before the member ignores it.
79
+ */
80
+ idempotencyKey?: string;
72
81
  };
73
82
  response: {
74
83
  cluster: clusterInterfaces.ICluster;
@@ -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
 
@@ -43,6 +43,15 @@ export interface IRequest_CreateImage extends plugins.typedrequestInterfaces.imp
43
43
  identity: userInterfaces.IIdentity;
44
44
  name: string;
45
45
  description: string;
46
+ /**
47
+ * Names the user action this create belongs to (`data.isIdempotencyKey`,
48
+ * `data.validateCreateIdempotencyKey`): a create sent again with the same key, after an answer
49
+ * that never arrived or one named `outcome-unknown`, is answered with the record the first one
50
+ * stored instead of creating a second. One key per user action, never per attempt. Optional in
51
+ * this major so callers built before it keep working; required at the next major. A controller
52
+ * built before the member ignores it.
53
+ */
54
+ idempotencyKey?: string;
46
55
  };
47
56
  response: {
48
57
  image: IImage;
@@ -495,6 +495,15 @@ extends plugins.typedrequestInterfaces.implementsTR<
495
495
  /** Canonical organization authority assigned by Cloudly to the new service. */
496
496
  organizationId: string;
497
497
  serviceData: TServiceWritableData;
498
+ /**
499
+ * Names the user action this create belongs to (`data.isIdempotencyKey`,
500
+ * `data.validateCreateIdempotencyKey`): a create sent again with the same key, after an answer
501
+ * that never arrived or one named `outcome-unknown`, is answered with the record the first one
502
+ * stored instead of creating a second. One key per user action, never per attempt. Optional in
503
+ * this major so callers built before it keep working; required at the next major. A controller
504
+ * built before the member ignores it.
505
+ */
506
+ idempotencyKey?: string;
498
507
  };
499
508
  response: {
500
509
  service: IService;