@serve.zone/interfaces 32.79.0 → 32.81.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.
package/readme.md CHANGED
@@ -4122,6 +4122,8 @@ A legacy `deployOnPush` service without deployable source moves to a greenfield
4122
4122
  - Instead of the registry push, the deployer calls `importServiceDeploymentLegacyImage`: Cloudly imports the attested image from its own registry into the reserved tag — an index root as it is, a single platform manifest under a one-descriptor index of the manifest's own family — and records release evidence of source `cloudly-legacy-import` naming the legacy source. Steps 3 to 5 follow unchanged; `selectTrustedImageReleaseEvidence` accepts that evidence only with `evidenceSource: 'cloudly-legacy-import'`.
4123
4123
  - The reservation and the import need the capability `deployment:import-legacy`, which only an organization-service-slot grant can carry.
4124
4124
 
4125
+ An existing service can deploy an image that is already published instead of building one: its reservation states `publishedImageDigest`, the exact canonical OCI index digest, and step 2 announces that manifest to the reserved tag. The operation records no other digest, and a release tag that already holds that digest from an earlier operation of the same service does not occupy the tag for it. Only an existing-service reservation of a source revision states it (`data.validateDeploymentReservationInput`); the operation keeps it as `data.IServiceDeploymentOperationData.publishedImageDigest`. A Cloudly built before this contract accepts the field and ignores it, so the deployer names the minimum Cloudly that honours it.
4126
+
4125
4127
  An existing service deploys one of its own releases again with a release redeploy, which needs no build, push or reservation:
4126
4128
 
4127
4129
  - `startServiceReleaseDeployment` (`requests.service.IRequest_Any_Cloudly_StartServiceReleaseDeployment`) names the service, the release, an idempotency key and the service's current rollout fence (`expectedRolloutGeneration` at least 1 and `expectedCurrentRolloutId`, both required: a redeploy needs a current plan). `data.validateServiceReleaseDeploymentStartInput` states its shape.
@@ -4477,6 +4479,86 @@ const desired: requests.gatewayconnector.IReq_Cloudly_Gateway_ApplyDesiredState[
4477
4479
  data.validateGatewayDesiredState(desired.desired); // []
4478
4480
  ```
4479
4481
 
4482
+ ### Witness
4483
+
4484
+ The witness (AGL-1195) is a small service of its own at a third site that keeps one compare-and-set
4485
+ record per controller, `data.IWitnessRecord`: `controllerId`, `epoch`, `activeOrigin`,
4486
+ `inSyncStandbyOrigin` (or `null`), `revision` and `memberOrigins`. A site is named by its site
4487
+ origin, the canonical `https` origin of one controller site (the value `data.IControllerPeerSet`
4488
+ carries as `activeOrigin` while that site is active), never the public origin browsers use. Cloudly
4489
+ is the only caller and sends `requests.witness` with TypedRequest over HTTPS to
4490
+ `data.witnessContract.typedRequestPath` (`/typedrequest`) below the witness's origin. The witness
4491
+ holds no controller data and no controller credential.
4492
+
4493
+ - Bearers: a member's bearer is a fact about one site. The site creates it, the unpadded base64url
4494
+ of `data.witnessContract.bearerRandomBytes` (32) random bytes, 43 characters checked by an exact
4495
+ pattern, and keeps it in that site's own config or secret store, never in the replicated
4496
+ controller database. The witness learns only `bearerSha256`, the SHA-256 of the bearer's UTF-8 as
4497
+ 64 lowercase hex characters, and no answer carries a bearer.
4498
+ - Pairing: the witness's operator makes a one-time code for a controller id on the witness host;
4499
+ the controller redeems it with `pairWitnessController` (its `epoch`, its own origin and its
4500
+ `bearerSha256`), and the witness creates the record (revision 1, the caller active and only
4501
+ member, no standby) and answers `{ record }`. A controller whose answer was lost reads the record
4502
+ with its own bearer (`getWitnessRecord`). The active enrolls every other member with
4503
+ `enrollWitnessMember`, by the `bearerSha256` that site handed it, a compare-and-set on
4504
+ `expectedRevision` that raises the revision and replaces an existing member's hash; it answers
4505
+ `{ record }`. It never enrolls the recorded in-sync standby (`transition-invalid`): the active
4506
+ drops that standby first. At most `data.witnessContract.maximumMemberOrigins` (17) members.
4507
+ - Changes: `compareAndSetWitnessRecord` stores `next` (`data.IWitnessState`) only while the stored
4508
+ revision is `expectedRevision`, and raises it by one, so of two changes naming one revision at most
4509
+ one is stored. `data.judgeWitnessChange` is the rule both sides apply: within an epoch only the
4510
+ active changes the record, and only its in-sync standby (dropping it before it continues without
4511
+ one, or recording it again once it caught up); an epoch rises by exactly one and every epoch raise
4512
+ records no standby; a promotion names the recorded in-sync standby as active and is stated by that
4513
+ site, so a stale standby is never promoted; the active raises its own epoch after a restore.
4514
+ `data.judgeWitnessMemberEnrollment` is the rule for enrollment. `getWitnessRecord` reads the
4515
+ record for any member.
4516
+ - Refusals: one of `data.witnessRefusals`, as a `TypedResponseError` whose `errorData` is
4517
+ `data.IWitnessRefusalErrorData` (`{ code, retryable }`, `data.createWitnessRefusalErrorData`). The
4518
+ list is a vocabulary, not a check order. The witness answers the first refusal of its gates, in
4519
+ this order: `request-invalid`; then the pairing code (`pairing-code-unknown`,
4520
+ `pairing-code-expired`, `pairing-code-used`, then `controller-mismatch` and `controller-paired`
4521
+ with the code unconsumed) or the authentication (`credential-invalid`, one code for an unknown
4522
+ controller, a non-member site and a bad bearer); then `revision-stale` (the text names the stored
4523
+ revision); then the judge's first refusal, in the order each judge's doc states. Only
4524
+ `witness-unavailable` and `outcome-unknown` (`data.witnessMomentaryRefusals`) are momentary. A
4525
+ change refused `outcome-unknown`, or whose answer never arrived, may have been stored: read the
4526
+ record before acting on it. `data.readWitnessRefusalErrorData` reads anything but exactly one
4527
+ refusal as no answer.
4528
+ - Health: the unauthenticated `getWitnessHealth` answers `{ ready, witnessVersion, interfacesVersion }`
4529
+ and names no controller.
4530
+ - Validators are exact and never carry a bearer or a pairing code in a refusal:
4531
+ `data.validateWitnessRecord`, `data.validateWitnessState`, `data.validateWitnessMemberCredential`,
4532
+ `data.validatePairWitnessControllerRequest`, `data.validateEnrollWitnessMemberRequest`,
4533
+ `data.validateGetWitnessRecordRequest`, `data.validateCompareAndSetWitnessRecordRequest` and
4534
+ `data.validateWitnessHealth`.
4535
+
4536
+ ```typescript
4537
+ import { data, requests } from '@serve.zone/interfaces';
4538
+
4539
+ declare const activeBearer: string; // the active's own witness bearer, from its site's secret store
4540
+ // The record as getWitnessRecord answered it.
4541
+ const record: data.IWitnessRecord = {
4542
+ controllerId: 'controller-0123456789abcdef0123456789abcdef',
4543
+ epoch: 1,
4544
+ activeOrigin: 'https://fra.cloudly.example.com',
4545
+ inSyncStandbyOrigin: 'https://nbg.cloudly.example.com',
4546
+ revision: 4,
4547
+ memberOrigins: ['https://fra.cloudly.example.com', 'https://nbg.cloudly.example.com'],
4548
+ };
4549
+ // The active stops waiting for a standby that stopped answering: first the witness records none.
4550
+ const dropStandby: requests.witness.IReq_Cloudly_Witness_CompareAndSetWitnessRecord['request'] = {
4551
+ controllerId: record.controllerId,
4552
+ member: { origin: record.activeOrigin, bearer: activeBearer },
4553
+ expectedRevision: record.revision,
4554
+ next: { epoch: record.epoch, activeOrigin: record.activeOrigin, inSyncStandbyOrigin: null },
4555
+ };
4556
+ data.judgeWitnessChange(record, dropStandby.member.origin, dropStandby.next); // null: admissible
4557
+ // A promotion of the standby once the record no longer names it in sync:
4558
+ data.judgeWitnessChange({ ...record, inSyncStandbyOrigin: null, revision: 5 }, 'https://nbg.cloudly.example.com',
4559
+ { epoch: 2, activeOrigin: 'https://nbg.cloudly.example.com', inSyncStandbyOrigin: null }); // 'standby-not-in-sync'
4560
+ ```
4561
+
4480
4562
  ### CoreMail contracts
4481
4563
 
4482
4564
  `requests.coremail` is the shared contract boundary for authenticated workload
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@serve.zone/interfaces',
6
- version: '32.79.0',
6
+ version: '32.81.0',
7
7
  description: 'Shared TypeScript interfaces and TypedRequest contracts for the serve.zone ecosystem.'
8
8
  }
@@ -57,6 +57,15 @@ extends IDeploymentReservationInputBase, ISourceDeploymentOrigin {
57
57
  mode: 'existing-service';
58
58
  expectedRolloutGeneration: number;
59
59
  expectedCurrentRolloutId?: string;
60
+ /**
61
+ * The canonical OCI index digest of an already-published image this deployment deploys instead
62
+ * of building one. The operation is bound to exactly this digest: its push records no other, and
63
+ * a release tag that already holds it from an earlier operation of the same service does not
64
+ * occupy the tag for this one. Exact canonical form only (`normalizeSha256Digest` of the value
65
+ * is the value). `validateDeploymentReservationInput` is not exact-key, so a reader before
66
+ * 32.80.0 accepts the member and ignores it.
67
+ */
68
+ publishedImageDigest?: TSha256Digest;
60
69
  }
61
70
 
62
71
  export interface IGreenfieldServiceDeploymentReservationInput
@@ -64,6 +73,7 @@ extends IDeploymentReservationInputBase, ISourceDeploymentOrigin {
64
73
  mode: 'greenfield';
65
74
  expectedRolloutGeneration?: never;
66
75
  expectedCurrentRolloutId?: never;
76
+ publishedImageDigest?: never;
67
77
  }
68
78
 
69
79
  /** A greenfield successor slot whose image is a legacy service's attested image. */
@@ -72,6 +82,7 @@ extends IDeploymentReservationInputBase, ILegacyImportDeploymentOrigin {
72
82
  mode: 'greenfield';
73
83
  expectedRolloutGeneration?: never;
74
84
  expectedCurrentRolloutId?: never;
85
+ publishedImageDigest?: never;
75
86
  }
76
87
 
77
88
  export type IDeploymentReservationInput =
@@ -282,6 +293,17 @@ export const validateDeploymentReservationInput = (inputArg: unknown): string[]
282
293
  if (inputArg.releaseRedeploy !== undefined) {
283
294
  errors.push('a release redeploy is started by startServiceReleaseDeployment, never reserved');
284
295
  }
296
+ if (inputArg.publishedImageDigest !== undefined) {
297
+ if (inputArg.mode !== 'existing-service'
298
+ || inputArg.legacyImport !== undefined
299
+ || inputArg.releaseRedeploy !== undefined) {
300
+ errors.push('publishedImageDigest is stated only by an existing-service deployment of a source revision');
301
+ }
302
+ if (typeof inputArg.publishedImageDigest !== 'string'
303
+ || normalizeSha256Digest(inputArg.publishedImageDigest) !== inputArg.publishedImageDigest) {
304
+ errors.push('publishedImageDigest must be a canonical sha256 digest');
305
+ }
306
+ }
285
307
  if (inputArg.legacyImport !== undefined) {
286
308
  errors.push(...validateLegacyImageImportReference(inputArg.legacyImport));
287
309
  if (inputArg.mode !== 'greenfield') {
@@ -478,6 +500,12 @@ interface IServiceDeploymentOperationStateData {
478
500
  state: TDeploymentOperationState;
479
501
  releaseId?: string;
480
502
  registryRootDigest?: TSha256Digest;
503
+ /**
504
+ * The published image digest the reservation stated
505
+ * (`IExistingServiceDeploymentReservationInput.publishedImageDigest`); the operation records no
506
+ * other image.
507
+ */
508
+ publishedImageDigest?: TSha256Digest;
481
509
  rolloutId?: string;
482
510
  rolloutGeneration?: number;
483
511
  routeGeneration?: number;
package/ts/data/index.ts CHANGED
@@ -100,4 +100,5 @@ export * from './traffic.js';
100
100
  export * from './user.js';
101
101
  export * from './version.js';
102
102
  export * from './webpush.js';
103
+ export * from './witness.js';
103
104
  export * from './workloadreplicaidentity.js';