@serve.zone/interfaces 31.9.0 → 32.0.1
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/changelog.md +476 -0
- package/dist_ts/00_commitinfo_data.js +3 -3
- package/dist_ts/appstore/types.d.ts +4 -6
- package/dist_ts/appstore/types.js +5 -5
- package/dist_ts/data/backup.d.ts +3 -26
- package/dist_ts/data/cluster.d.ts +36 -11
- package/dist_ts/data/cluster.js +33 -22
- package/dist_ts/data/clusteringress.d.ts +8 -0
- package/dist_ts/data/clusteringress.js +13 -8
- package/dist_ts/data/clusternode.d.ts +121 -74
- package/dist_ts/data/clusternode.js +109 -132
- package/dist_ts/data/coremail.d.ts +3 -7
- package/dist_ts/data/coremail.js +2 -2
- package/dist_ts/data/coremail.runtime.d.ts +0 -1
- package/dist_ts/data/coremail.runtime.js +5 -22
- package/dist_ts/data/deploymentadoption.d.ts +0 -2
- package/dist_ts/data/deploymentadoption.js +40 -6
- package/dist_ts/data/deploymentoperation.js +16 -3
- package/dist_ts/data/deploymentpreflight.d.ts +0 -2
- package/dist_ts/data/deploymentpreflight.js +1 -1
- package/dist_ts/data/immutableimage.d.ts +38 -21
- package/dist_ts/data/immutableimage.js +45 -5
- package/dist_ts/data/index.d.ts +1 -1
- package/dist_ts/data/isolatedrestore.d.ts +139 -21
- package/dist_ts/data/isolatedrestore.golden.d.ts +0 -1
- package/dist_ts/data/isolatedrestore.golden.js +6 -9
- package/dist_ts/data/isolatedrestore.js +176 -40
- package/dist_ts/data/mail.d.ts +1 -1
- package/dist_ts/data/networkaddressplan.d.ts +8 -8
- package/dist_ts/data/networkaddressplan.js +4 -4
- package/dist_ts/data/networkauthority.d.ts +20 -22
- package/dist_ts/data/networkauthority.js +26 -28
- package/dist_ts/data/networkcredential.d.ts +10 -10
- package/dist_ts/data/networkcredential.js +16 -16
- package/dist_ts/data/networkdelivery.d.ts +18 -18
- package/dist_ts/data/networkdelivery.js +16 -16
- package/dist_ts/data/networklease.d.ts +18 -7
- package/dist_ts/data/networklease.js +29 -7
- package/dist_ts/data/networknode.d.ts +2 -2
- package/dist_ts/data/networkprojection.d.ts +59 -60
- package/dist_ts/data/networkprojection.js +53 -57
- package/dist_ts/data/networkprotection.d.ts +27 -28
- package/dist_ts/data/networkprotection.js +36 -36
- package/dist_ts/data/networkrouter.d.ts +11 -11
- package/dist_ts/data/networkrouter.js +1 -1
- package/dist_ts/data/networksigning.d.ts +16 -18
- package/dist_ts/data/networksigning.js +20 -21
- package/dist_ts/data/nodecredential.d.ts +4 -6
- package/dist_ts/data/nodeenrollment.d.ts +35 -40
- package/dist_ts/data/nodeenrollment.js +57 -72
- package/dist_ts/data/privatenetwork.d.ts +21 -24
- package/dist_ts/data/privatenetwork.js +39 -54
- package/dist_ts/data/runtimeassignment.d.ts +50 -34
- package/dist_ts/data/runtimeassignment.js +79 -45
- package/dist_ts/data/runtimeconfig.d.ts +21 -22
- package/dist_ts/data/runtimeconfig.js +24 -24
- package/dist_ts/data/runtimesession.d.ts +100 -62
- package/dist_ts/data/runtimesession.js +98 -79
- package/dist_ts/data/runtimeterminalreceipt.d.ts +28 -29
- package/dist_ts/data/runtimeterminalreceipt.js +42 -42
- package/dist_ts/data/secret.d.ts +18 -25
- package/dist_ts/data/secret.js +12 -52
- package/dist_ts/data/servicecredential.d.ts +14 -16
- package/dist_ts/data/servicecredential.js +17 -28
- package/dist_ts/data/serviceruntime.d.ts +7 -7
- package/dist_ts/data/serviceruntime.js +4 -4
- package/dist_ts/data/sparknodereport.d.ts +27 -14
- package/dist_ts/data/sparknodereport.js +35 -28
- package/dist_ts/data/webpush.d.ts +0 -1
- package/dist_ts/index.d.ts +2 -1
- package/dist_ts/index.js +3 -2
- package/dist_ts/platform/objectstorageretention.d.ts +21 -24
- package/dist_ts/platform/objectstorageretention.js +10 -17
- package/dist_ts/platform/storage.d.ts +1 -3
- package/dist_ts/platform/storagemigration.d.ts +0 -7
- package/dist_ts/platform/storagemigration.golden.d.ts +0 -1
- package/dist_ts/platform/storagemigration.golden.js +8 -12
- package/dist_ts/platform/storagemigration.js +6 -51
- package/dist_ts/platform/types.d.ts +2 -2
- package/dist_ts/private/canonicaljson.d.ts +9 -1
- package/dist_ts/private/canonicaljson.js +14 -2
- package/dist_ts/private/dataproperties.d.ts +62 -0
- package/dist_ts/private/dataproperties.js +117 -0
- package/dist_ts/private/networkcontract.d.ts +10 -10
- package/dist_ts/private/networkcontract.js +1 -1
- package/dist_ts/private/releaseversion.d.ts +37 -0
- package/dist_ts/private/releaseversion.js +48 -0
- package/dist_ts/private/runtimepolicy.d.ts +2 -2
- package/dist_ts/private/runtimepolicy.js +1 -1
- package/dist_ts/private/tokenlist.d.ts +9 -0
- package/dist_ts/private/tokenlist.js +23 -0
- package/dist_ts/protocol.d.ts +137 -0
- package/dist_ts/protocol.js +255 -0
- package/dist_ts/requests/admin.d.ts +8 -8
- package/dist_ts/requests/backup.d.ts +102 -112
- package/dist_ts/requests/cluster.d.ts +10 -10
- package/dist_ts/requests/clusteringress.d.ts +9 -0
- package/dist_ts/requests/clusteringress.js +1 -1
- package/dist_ts/requests/config.d.ts +3 -3
- package/dist_ts/requests/corestore.d.ts +0 -3
- package/dist_ts/requests/corestore.js +5 -9
- package/dist_ts/requests/network.d.ts +30 -30
- package/dist_ts/requests/node.d.ts +15 -28
- package/dist_ts/requests/pallet.d.ts +13 -13
- package/dist_ts/requests/runtimesession.d.ts +53 -41
- package/dist_ts/requests/secret.d.ts +4 -5
- package/dist_ts/requests/secret.js +1 -5
- package/dist_ts/runtime.corestore.d.ts +56 -74
- package/dist_ts/runtime.corestore.databaseexportpackage.d.ts +30 -36
- package/dist_ts/runtime.corestore.databaseexportpackage.golden.d.ts +11 -12
- package/dist_ts/runtime.corestore.databaseexportpackage.golden.js +54 -71
- package/dist_ts/runtime.corestore.databaseexportpackage.js +9 -25
- package/dist_ts/runtime.corestore.js +35 -135
- package/dist_ts/runtime.corestore.relay.js +2 -7
- package/dist_ts/runtime.d.ts +38 -48
- package/dist_ts/runtime.js +20 -77
- package/dist_ts/runtime.networkprojection.d.ts +4 -4
- package/dist_ts/runtime.networkprojection.js +18 -18
- package/dist_ts/runtime.workloadinit.d.ts +23 -24
- package/dist_ts/runtime.workloadinit.js +6 -13
- package/package.json +2 -2
- package/readme.md +421 -270
- package/ts/00_commitinfo_data.ts +3 -3
- package/ts/appstore/types.ts +4 -6
- package/ts/data/backup.ts +3 -38
- package/ts/data/cluster.ts +51 -34
- package/ts/data/clusteringress.ts +12 -12
- package/ts/data/clusternode.ts +204 -232
- package/ts/data/coremail.runtime.ts +4 -21
- package/ts/data/coremail.ts +3 -7
- package/ts/data/deploymentadoption.ts +46 -4
- package/ts/data/deploymentoperation.ts +16 -1
- package/ts/data/deploymentpreflight.ts +0 -2
- package/ts/data/immutableimage.ts +71 -24
- package/ts/data/index.ts +1 -1
- package/ts/data/isolatedrestore.golden.ts +5 -9
- package/ts/data/isolatedrestore.ts +339 -54
- package/ts/data/mail.ts +1 -1
- package/ts/data/networkaddressplan.ts +13 -13
- package/ts/data/networkauthority.ts +42 -46
- package/ts/data/networkcredential.ts +24 -24
- package/ts/data/networkdelivery.ts +27 -27
- package/ts/data/networklease.ts +40 -13
- package/ts/data/networknode.ts +2 -2
- package/ts/data/networkprojection.ts +119 -124
- package/ts/data/networkprotection.ts +54 -55
- package/ts/data/networkrouter.ts +14 -14
- package/ts/data/networksigning.ts +29 -32
- package/ts/data/nodecredential.ts +4 -6
- package/ts/data/nodeenrollment.ts +96 -114
- package/ts/data/privatenetwork.ts +58 -74
- package/ts/data/runtimeassignment.ts +143 -94
- package/ts/data/runtimeconfig.ts +45 -46
- package/ts/data/runtimesession.ts +185 -138
- package/ts/data/runtimeterminalreceipt.ts +72 -73
- package/ts/data/secret.ts +28 -76
- package/ts/data/servicecredential.ts +33 -43
- package/ts/data/serviceruntime.ts +11 -11
- package/ts/data/sparknodereport.ts +48 -36
- package/ts/data/webpush.ts +0 -1
- package/ts/index.ts +2 -0
- package/ts/platform/objectstorageretention.ts +40 -54
- package/ts/platform/storage.ts +1 -3
- package/ts/platform/storagemigration.golden.ts +7 -11
- package/ts/platform/storagemigration.ts +5 -55
- package/ts/platform/types.ts +2 -2
- package/ts/private/canonicaljson.ts +13 -1
- package/ts/private/dataproperties.ts +139 -0
- package/ts/private/networkcontract.ts +9 -9
- package/ts/private/releaseversion.ts +70 -0
- package/ts/private/runtimepolicy.ts +2 -2
- package/ts/private/tokenlist.ts +30 -0
- package/ts/protocol.ts +364 -0
- package/ts/requests/admin.ts +11 -11
- package/ts/requests/backup.ts +112 -117
- package/ts/requests/cluster.ts +13 -13
- package/ts/requests/clusteringress.ts +9 -0
- package/ts/requests/config.ts +3 -3
- package/ts/requests/corestore.ts +4 -16
- package/ts/requests/network.ts +40 -40
- package/ts/requests/node.ts +21 -38
- package/ts/requests/pallet.ts +17 -17
- package/ts/requests/runtimesession.ts +63 -51
- package/ts/requests/secret.ts +5 -10
- package/ts/runtime.corestore.databaseexportpackage.golden.ts +77 -95
- package/ts/runtime.corestore.databaseexportpackage.ts +51 -73
- package/ts/runtime.corestore.relay.ts +1 -10
- package/ts/runtime.corestore.ts +118 -268
- package/ts/runtime.networkprojection.ts +30 -30
- package/ts/runtime.ts +83 -158
- package/ts/runtime.workloadinit.ts +36 -48
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.d.ts +0 -902
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.golden.d.ts +0 -35
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.golden.js +0 -315
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.js +0 -3315
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.offlineexport.d.ts +0 -291
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.offlineexport.golden.d.ts +0 -30
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.offlineexport.golden.js +0 -408
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.offlineexport.js +0 -1126
- package/ts/runtime.cloudlylegacydeploymentsettlement.golden.ts +0 -421
- package/ts/runtime.cloudlylegacydeploymentsettlement.offlineexport.golden.ts +0 -510
- package/ts/runtime.cloudlylegacydeploymentsettlement.offlineexport.ts +0 -2470
- package/ts/runtime.cloudlylegacydeploymentsettlement.ts +0 -6630
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { TSha256Digest } from './immutableimage.js';
|
|
2
2
|
import { isSha256Digest } from './immutableimage.js';
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
3
|
+
import type { IRuntimeAssignmentReference, IRuntimeAssignment } from './runtimeassignment.js';
|
|
4
|
+
import { evaluateRuntimeAssignment, getRuntimeAssignmentReference,
|
|
5
|
+
snapshotRuntimeAssignment } from './runtimeassignment.js';
|
|
6
|
+
import type { IRuntimeSessionBinding, TRuntimeObservationAuthorityUse } from './runtimesession.js';
|
|
7
|
+
import { bindRuntimeReporterSession, snapshotRuntimeSessionBinding } from './runtimesession.js';
|
|
8
8
|
import { canonicalizeStrictJson, createCanonicalJsonSha256Hex } from '../private/canonicaljson.js';
|
|
9
9
|
|
|
10
10
|
/** Exact value-free native terminal evidence; terminal inspection does not collect addresses. */
|
|
11
|
-
export interface
|
|
11
|
+
export interface IRuntimeAssignmentTerminalEvidence {
|
|
12
12
|
phase: 'stopped' | 'absent';
|
|
13
13
|
sandboxId: string | null;
|
|
14
14
|
containerId: string | null;
|
|
@@ -28,12 +28,11 @@ export interface IRuntimeAssignmentTerminalEvidenceV1 {
|
|
|
28
28
|
* liveness, storage relocation, whole-host, Docker/Coreflow absence, other
|
|
29
29
|
* controller or cross-organization authority. It has no authoritative wall clock.
|
|
30
30
|
*/
|
|
31
|
-
export interface
|
|
32
|
-
schemaVersion: 1;
|
|
31
|
+
export interface IRuntimeAssignmentTerminalReceipt {
|
|
33
32
|
/** Exact generation 2 stop or generation 3 remove revision. */
|
|
34
|
-
assignment:
|
|
33
|
+
assignment: IRuntimeAssignmentReference;
|
|
35
34
|
/** Exact immutable generation 1 run revision. */
|
|
36
|
-
runAssignment:
|
|
35
|
+
runAssignment: IRuntimeAssignmentReference;
|
|
37
36
|
reporterSessionId: string;
|
|
38
37
|
sequence: 1 | 2;
|
|
39
38
|
operation: {
|
|
@@ -41,32 +40,32 @@ export interface IRuntimeAssignmentTerminalReceiptV1 {
|
|
|
41
40
|
action: 'stop' | 'remove';
|
|
42
41
|
bootId: string;
|
|
43
42
|
status: 'completed';
|
|
44
|
-
evidence:
|
|
43
|
+
evidence: IRuntimeAssignmentTerminalEvidence;
|
|
45
44
|
};
|
|
46
45
|
/** Null for stop; the exact accepted stop receipt digest for remove. */
|
|
47
46
|
previousReceiptDigest: TSha256Digest | null;
|
|
48
47
|
digest: TSha256Digest;
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
export interface
|
|
50
|
+
export interface IReportRuntimeAssignmentTerminalReceiptRequest {
|
|
52
51
|
/** Current physical peer binding, even when the immutable receipt is historical. */
|
|
53
|
-
session:
|
|
54
|
-
receipt:
|
|
52
|
+
session: IRuntimeSessionBinding;
|
|
53
|
+
receipt: IRuntimeAssignmentTerminalReceipt;
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
export interface
|
|
56
|
+
export interface IReportRuntimeAssignmentTerminalReceiptResponse {
|
|
58
57
|
/** Exact immutable body after the owning durable receipt transaction. */
|
|
59
|
-
receipt:
|
|
58
|
+
receipt: IRuntimeAssignmentTerminalReceipt;
|
|
60
59
|
/** Historical recovery never restores active readiness, routes or liveness. */
|
|
61
|
-
authorityUse:
|
|
60
|
+
authorityUse: TRuntimeObservationAuthorityUse;
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
export type
|
|
65
|
-
| { status: 'accept' | 'replay'; receipt:
|
|
63
|
+
export type TRuntimeAssignmentTerminalReceiptDecision =
|
|
64
|
+
| { status: 'accept' | 'replay'; receipt: IRuntimeAssignmentTerminalReceipt }
|
|
66
65
|
| { status: 'reject'; reason: 'invalid' | 'conflict' | 'sequence-gap' | 'predecessor-mismatch' };
|
|
67
66
|
|
|
68
|
-
export const
|
|
69
|
-
digestDomain: 'serve.zone/runtime-assignment-terminal-receipt
|
|
67
|
+
export const runtimeAssignmentTerminalReceiptContract = Object.freeze({
|
|
68
|
+
digestDomain: 'serve.zone/runtime-assignment-terminal-receipt',
|
|
70
69
|
maximumReceiptCanonicalBytes: 16_384,
|
|
71
70
|
maximumHistoryCanonicalBytes: 98_304,
|
|
72
71
|
maximumReceipts: 2,
|
|
@@ -74,7 +73,7 @@ export const runtimeAssignmentTerminalReceiptV1Contract = Object.freeze({
|
|
|
74
73
|
error: 'Runtime terminal receipt contract rejected.',
|
|
75
74
|
} as const);
|
|
76
75
|
|
|
77
|
-
const fail = (): never => { throw new Error(
|
|
76
|
+
const fail = (): never => { throw new Error(runtimeAssignmentTerminalReceiptContract.error); };
|
|
78
77
|
function requireValue(conditionArg: unknown): asserts conditionArg { if (!conditionArg) fail(); }
|
|
79
78
|
const safe = <T>(operationArg: () => T): T => { try { return operationArg(); } catch { return fail(); } };
|
|
80
79
|
const canonical = (valueArg: unknown): string => canonicalizeStrictJson(valueArg, fail);
|
|
@@ -89,7 +88,7 @@ const digest = (valueArg: unknown): TSha256Digest => {
|
|
|
89
88
|
};
|
|
90
89
|
|
|
91
90
|
/** Bounded inert copy before hashing or calling any nested validator. */
|
|
92
|
-
const capture = (valueArg: unknown, maximumBytesArg: number =
|
|
91
|
+
const capture = (valueArg: unknown, maximumBytesArg: number = runtimeAssignmentTerminalReceiptContract.maximumHistoryCanonicalBytes): unknown => safe(() => {
|
|
93
92
|
let nodes = 0;
|
|
94
93
|
let bytes = 0;
|
|
95
94
|
const ancestors = new Set<object>();
|
|
@@ -141,13 +140,13 @@ const record = (valueArg: unknown, keysArg: string[]): Record<string, unknown> =
|
|
|
141
140
|
requireValue(keys.length === keysArg.length && keys.every((key) => keysArg.includes(key)));
|
|
142
141
|
return valueArg as Record<string, unknown>;
|
|
143
142
|
};
|
|
144
|
-
const reference = (valueArg: unknown):
|
|
143
|
+
const reference = (valueArg: unknown): IRuntimeAssignmentReference => {
|
|
145
144
|
const value = record(valueArg, ['assignmentId', 'generation', 'digest']);
|
|
146
145
|
requireValue(typeof value.generation === 'number' && Number.isSafeInteger(value.generation)
|
|
147
146
|
&& value.generation >= 1 && value.generation <= 3);
|
|
148
147
|
return { assignmentId: identifier(value.assignmentId), generation: value.generation, digest: digest(value.digest) };
|
|
149
148
|
};
|
|
150
|
-
const evidence = (valueArg: unknown):
|
|
149
|
+
const evidence = (valueArg: unknown): IRuntimeAssignmentTerminalEvidence => {
|
|
151
150
|
const value = record(valueArg, ['phase', 'sandboxId', 'containerId', 'imageConfigDigest', 'ipAddresses', 'exitCode']);
|
|
152
151
|
requireValue(value.phase === 'absent' || value.phase === 'stopped');
|
|
153
152
|
for (const field of ['sandboxId', 'containerId']) requireValue(value[field] === null
|
|
@@ -161,35 +160,35 @@ const evidence = (valueArg: unknown): IRuntimeAssignmentTerminalEvidenceV1 => {
|
|
|
161
160
|
? value.sandboxId === null && value.containerId === null && value.imageConfigDigest === null && value.exitCode === null
|
|
162
161
|
: value.sandboxId !== null);
|
|
163
162
|
requireValue(value.containerId !== null || (value.imageConfigDigest === null && value.exitCode === null));
|
|
164
|
-
return value as unknown as
|
|
163
|
+
return value as unknown as IRuntimeAssignmentTerminalEvidence;
|
|
165
164
|
};
|
|
166
165
|
|
|
167
166
|
/** Detached exact-schema assertion only; digest, journal provenance and authority remain unverified. */
|
|
168
|
-
export const
|
|
169
|
-
const value = record(capture(valueArg,
|
|
170
|
-
['
|
|
167
|
+
export const snapshotRuntimeAssignmentTerminalReceipt = (valueArg: unknown): IRuntimeAssignmentTerminalReceipt => safe(() => {
|
|
168
|
+
const value = record(capture(valueArg, runtimeAssignmentTerminalReceiptContract.maximumReceiptCanonicalBytes),
|
|
169
|
+
['assignment', 'runAssignment', 'reporterSessionId', 'sequence', 'operation', 'previousReceiptDigest', 'digest']);
|
|
171
170
|
const assignment = reference(value.assignment);
|
|
172
171
|
const runAssignment = reference(value.runAssignment);
|
|
173
172
|
const operation = record(value.operation, ['id', 'action', 'bootId', 'status', 'evidence']);
|
|
174
173
|
const terminalEvidence = evidence(operation.evidence);
|
|
175
|
-
requireValue(
|
|
174
|
+
requireValue((value.sequence === 1 || value.sequence === 2)
|
|
176
175
|
&& operation.status === 'completed' && assignment.generation === value.sequence + 1
|
|
177
176
|
&& runAssignment.generation === 1 && runAssignment.assignmentId === assignment.assignmentId);
|
|
178
177
|
requireValue(typeof operation.bootId === 'string'
|
|
179
178
|
&& /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(operation.bootId));
|
|
180
179
|
requireValue(value.sequence === 1 ? operation.action === 'stop' && value.previousReceiptDigest === null
|
|
181
180
|
: operation.action === 'remove' && terminalEvidence.phase === 'absent' && value.previousReceiptDigest !== null);
|
|
182
|
-
return {
|
|
181
|
+
return { assignment, runAssignment, reporterSessionId: identifier(value.reporterSessionId),
|
|
183
182
|
sequence: value.sequence, operation: { id: identifier(operation.id), action: operation.action as 'stop' | 'remove',
|
|
184
183
|
bootId: operation.bootId, status: 'completed', evidence: terminalEvidence },
|
|
185
184
|
previousReceiptDigest: value.previousReceiptDigest === null ? null : digest(value.previousReceiptDigest), digest: digest(value.digest) };
|
|
186
185
|
});
|
|
187
186
|
|
|
188
187
|
/** Bounded exact receipt history for synchronous persistence assertions; hashes remain unchecked. */
|
|
189
|
-
export const
|
|
188
|
+
export const snapshotRuntimeAssignmentTerminalReceiptHistory = (valueArg: unknown): IRuntimeAssignmentTerminalReceipt[] => safe(() => {
|
|
190
189
|
const values = capture(valueArg);
|
|
191
|
-
requireValue(Array.isArray(values) && values.length <=
|
|
192
|
-
const receipts = values.map(
|
|
190
|
+
requireValue(Array.isArray(values) && values.length <= runtimeAssignmentTerminalReceiptContract.maximumReceipts);
|
|
191
|
+
const receipts = values.map(snapshotRuntimeAssignmentTerminalReceipt);
|
|
193
192
|
for (const [index, receipt] of receipts.entries()) {
|
|
194
193
|
requireValue(receipt.sequence === index + 1);
|
|
195
194
|
if (index > 0) requireValue(receipt.previousReceiptDigest === receipts[0].digest
|
|
@@ -199,41 +198,41 @@ export const snapshotRuntimeAssignmentTerminalReceiptHistoryV1 = (valueArg: unkn
|
|
|
199
198
|
return receipts;
|
|
200
199
|
});
|
|
201
200
|
|
|
202
|
-
const assignments = (valueArg: unknown):
|
|
201
|
+
const assignments = (valueArg: unknown): IRuntimeAssignment[] => {
|
|
203
202
|
const values = capture(valueArg);
|
|
204
203
|
requireValue(Array.isArray(values) && values.length >= 2
|
|
205
|
-
&& values.length <=
|
|
206
|
-
return values.map(
|
|
204
|
+
&& values.length <= runtimeAssignmentTerminalReceiptContract.maximumAssignmentRevisions);
|
|
205
|
+
return values.map(snapshotRuntimeAssignment);
|
|
207
206
|
};
|
|
208
|
-
const checkAssignmentHistory = async (historyArg:
|
|
207
|
+
const checkAssignmentHistory = async (historyArg: IRuntimeAssignment[]): Promise<void> => {
|
|
209
208
|
const run = historyArg[0];
|
|
210
209
|
const scope = { controller: run.controller, organizationId: run.organizationId,
|
|
211
210
|
nodeId: run.nodeId, runtimeNamespace: run.runtimeNamespace };
|
|
212
211
|
for (const [index, assignment] of historyArg.entries()) {
|
|
213
212
|
requireValue(assignment.generation === index + 1
|
|
214
213
|
&& assignment.disposition === ['run', 'stop-preserve', 'remove-runtime-preserve-storage'][index]);
|
|
215
|
-
requireValue((await
|
|
214
|
+
requireValue((await evaluateRuntimeAssignment(assignment, index === 0 ? null : historyArg[index - 1], scope)).status === 'accept');
|
|
216
215
|
}
|
|
217
216
|
};
|
|
218
|
-
const computeSnapshotDigest = async (receiptArg:
|
|
217
|
+
const computeSnapshotDigest = async (receiptArg: IRuntimeAssignmentTerminalReceipt): Promise<TSha256Digest> => {
|
|
219
218
|
const { digest: _digest, ...payload } = receiptArg;
|
|
220
219
|
return `sha256:${await createCanonicalJsonSha256Hex(canonical({
|
|
221
|
-
domain:
|
|
220
|
+
domain: runtimeAssignmentTerminalReceiptContract.digestDomain, payload,
|
|
222
221
|
}), fail)}`;
|
|
223
222
|
};
|
|
224
223
|
/** Domain-separated exact body digest; captures before asynchronous hashing. */
|
|
225
|
-
export const
|
|
226
|
-
valueArg:
|
|
224
|
+
export const computeRuntimeAssignmentTerminalReceiptDigest = async (
|
|
225
|
+
valueArg: IRuntimeAssignmentTerminalReceipt,
|
|
227
226
|
): Promise<TSha256Digest> => {
|
|
228
|
-
try { return await computeSnapshotDigest(
|
|
227
|
+
try { return await computeSnapshotDigest(snapshotRuntimeAssignmentTerminalReceipt(valueArg)); } catch { return fail(); }
|
|
229
228
|
};
|
|
230
229
|
const checkReceipt = async (
|
|
231
|
-
receiptArg:
|
|
232
|
-
previousArg:
|
|
230
|
+
receiptArg: IRuntimeAssignmentTerminalReceipt, historyArg: IRuntimeAssignment[],
|
|
231
|
+
previousArg: IRuntimeAssignmentTerminalReceipt | null,
|
|
233
232
|
): Promise<void> => {
|
|
234
233
|
requireValue(historyArg.length > receiptArg.sequence
|
|
235
|
-
&& canonical(receiptArg.runAssignment) === canonical(
|
|
236
|
-
&& canonical(receiptArg.assignment) === canonical(
|
|
234
|
+
&& canonical(receiptArg.runAssignment) === canonical(getRuntimeAssignmentReference(historyArg[0]))
|
|
235
|
+
&& canonical(receiptArg.assignment) === canonical(getRuntimeAssignmentReference(historyArg[receiptArg.sequence]))
|
|
237
236
|
&& receiptArg.digest === await computeSnapshotDigest(receiptArg));
|
|
238
237
|
if (receiptArg.sequence === 1) requireValue(previousArg === null);
|
|
239
238
|
else {
|
|
@@ -244,17 +243,17 @@ const checkReceipt = async (
|
|
|
244
243
|
};
|
|
245
244
|
|
|
246
245
|
/** Full immutable run/stop/remove chain and exact prior stop receipt are mandatory for removal. */
|
|
247
|
-
export const
|
|
246
|
+
export const validateRuntimeAssignmentTerminalReceipt = async (
|
|
248
247
|
valueArg: unknown, assignmentHistoryArg: unknown, previousReceiptArg: unknown,
|
|
249
248
|
): Promise<string[]> => {
|
|
250
249
|
try {
|
|
251
|
-
const receipt =
|
|
250
|
+
const receipt = snapshotRuntimeAssignmentTerminalReceipt(valueArg);
|
|
252
251
|
const history = assignments(assignmentHistoryArg);
|
|
253
|
-
const previous = previousReceiptArg === null ? null :
|
|
252
|
+
const previous = previousReceiptArg === null ? null : snapshotRuntimeAssignmentTerminalReceipt(previousReceiptArg);
|
|
254
253
|
await checkAssignmentHistory(history);
|
|
255
254
|
await checkReceipt(receipt, history, previous);
|
|
256
255
|
return [];
|
|
257
|
-
} catch { return [
|
|
256
|
+
} catch { return [runtimeAssignmentTerminalReceiptContract.error]; }
|
|
258
257
|
};
|
|
259
258
|
|
|
260
259
|
/**
|
|
@@ -263,19 +262,19 @@ export const validateRuntimeAssignmentTerminalReceiptV1 = async (
|
|
|
263
262
|
* only a previously persisted exact body can replay after the incumbent changes.
|
|
264
263
|
* The helper cannot prove either condition. Retain both bodies after removal.
|
|
265
264
|
*/
|
|
266
|
-
export const
|
|
265
|
+
export const evaluateRuntimeAssignmentTerminalReceipt = async (
|
|
267
266
|
valueArg: unknown, acceptedHistoryArg: unknown, assignmentHistoryArg: unknown,
|
|
268
|
-
): Promise<
|
|
267
|
+
): Promise<TRuntimeAssignmentTerminalReceiptDecision> => {
|
|
269
268
|
try {
|
|
270
|
-
const receipt =
|
|
271
|
-
const accepted =
|
|
269
|
+
const receipt = snapshotRuntimeAssignmentTerminalReceipt(valueArg);
|
|
270
|
+
const accepted = snapshotRuntimeAssignmentTerminalReceiptHistory(acceptedHistoryArg);
|
|
272
271
|
const history = assignments(assignmentHistoryArg);
|
|
273
272
|
await checkAssignmentHistory(history);
|
|
274
273
|
for (const existing of accepted) await checkReceipt(existing, history, existing.sequence === 1 ? null : accepted[0]);
|
|
275
274
|
if (receipt.digest !== await computeSnapshotDigest(receipt)
|
|
276
275
|
|| history.length <= receipt.sequence
|
|
277
|
-
|| canonical(receipt.runAssignment) !== canonical(
|
|
278
|
-
|| canonical(receipt.assignment) !== canonical(
|
|
276
|
+
|| canonical(receipt.runAssignment) !== canonical(getRuntimeAssignmentReference(history[0]))
|
|
277
|
+
|| canonical(receipt.assignment) !== canonical(getRuntimeAssignmentReference(history[receipt.sequence]))) {
|
|
279
278
|
return { status: 'reject', reason: 'invalid' };
|
|
280
279
|
}
|
|
281
280
|
const existing = accepted[receipt.sequence - 1];
|
|
@@ -288,18 +287,18 @@ export const evaluateRuntimeAssignmentTerminalReceiptV1 = async (
|
|
|
288
287
|
} catch { return { status: 'reject', reason: 'invalid' }; }
|
|
289
288
|
};
|
|
290
289
|
|
|
291
|
-
export const
|
|
290
|
+
export const snapshotReportRuntimeAssignmentTerminalReceiptRequest = (
|
|
292
291
|
valueArg: unknown,
|
|
293
|
-
):
|
|
292
|
+
): IReportRuntimeAssignmentTerminalReceiptRequest => safe(() => {
|
|
294
293
|
const value = record(capture(valueArg), ['session', 'receipt']);
|
|
295
|
-
return { session:
|
|
294
|
+
return { session: snapshotRuntimeSessionBinding(value.session), receipt: snapshotRuntimeAssignmentTerminalReceipt(value.receipt) };
|
|
296
295
|
});
|
|
297
|
-
export const
|
|
296
|
+
export const snapshotReportRuntimeAssignmentTerminalReceiptResponse = (
|
|
298
297
|
valueArg: unknown,
|
|
299
|
-
):
|
|
298
|
+
): IReportRuntimeAssignmentTerminalReceiptResponse => safe(() => {
|
|
300
299
|
const value = record(capture(valueArg), ['receipt', 'authorityUse']);
|
|
301
300
|
requireValue(value.authorityUse === 'current-session' || value.authorityUse === 'historical-recovery');
|
|
302
|
-
return { receipt:
|
|
301
|
+
return { receipt: snapshotRuntimeAssignmentTerminalReceipt(value.receipt), authorityUse: value.authorityUse };
|
|
303
302
|
});
|
|
304
303
|
|
|
305
304
|
/**
|
|
@@ -308,16 +307,16 @@ export const snapshotReportRuntimeAssignmentTerminalReceiptResponseV1 = (
|
|
|
308
307
|
* come from the durable owner. This binds content; it does not authenticate,
|
|
309
308
|
* prove the local operation join, advance CAS, or admit a replacement.
|
|
310
309
|
*/
|
|
311
|
-
export const
|
|
310
|
+
export const bindReportRuntimeAssignmentTerminalReceiptRequest = async (
|
|
312
311
|
valueArg: unknown, assignmentHistoryArg: unknown, previousReceiptArg: unknown,
|
|
313
312
|
trustedSessionArg: unknown, reporterHistoryArg: unknown,
|
|
314
|
-
): Promise<{ request:
|
|
313
|
+
): Promise<{ request: IReportRuntimeAssignmentTerminalReceiptRequest; authorityUse: TRuntimeObservationAuthorityUse }> => {
|
|
315
314
|
try {
|
|
316
|
-
const request =
|
|
315
|
+
const request = snapshotReportRuntimeAssignmentTerminalReceiptRequest(valueArg);
|
|
317
316
|
const history = assignments(assignmentHistoryArg);
|
|
318
|
-
const previous = previousReceiptArg === null ? null :
|
|
317
|
+
const previous = previousReceiptArg === null ? null : snapshotRuntimeAssignmentTerminalReceipt(previousReceiptArg);
|
|
319
318
|
requireValue(history.length > request.receipt.sequence);
|
|
320
|
-
const binding =
|
|
319
|
+
const binding = bindRuntimeReporterSession(request.session, request.receipt.reporterSessionId,
|
|
321
320
|
history[request.receipt.sequence], trustedSessionArg, reporterHistoryArg);
|
|
322
321
|
await checkAssignmentHistory(history);
|
|
323
322
|
await checkReceipt(request.receipt, history, previous);
|
|
@@ -326,11 +325,11 @@ export const bindReportRuntimeAssignmentTerminalReceiptRequestV1 = async (
|
|
|
326
325
|
};
|
|
327
326
|
|
|
328
327
|
/** Exact ACK of the immutable outbox body; no rewritten session, operation or chain. */
|
|
329
|
-
export const
|
|
328
|
+
export const bindReportRuntimeAssignmentTerminalReceiptResponse = (
|
|
330
329
|
valueArg: unknown, requestArg: unknown,
|
|
331
|
-
):
|
|
332
|
-
const response =
|
|
333
|
-
const request =
|
|
330
|
+
): IReportRuntimeAssignmentTerminalReceiptResponse => safe(() => {
|
|
331
|
+
const response = snapshotReportRuntimeAssignmentTerminalReceiptResponse(valueArg);
|
|
332
|
+
const request = snapshotReportRuntimeAssignmentTerminalReceiptRequest(requestArg);
|
|
334
333
|
requireValue(canonical(response.receipt) === canonical(request.receipt)
|
|
335
334
|
&& response.authorityUse === (request.receipt.reporterSessionId === request.session.reporterSessionId
|
|
336
335
|
? 'current-session' : 'historical-recovery'));
|