@xemahq/agent-session-runtime 0.9.1 → 0.10.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/dist/lib/agent-workspace-manifest.js +13 -1
- package/dist/lib/agent-workspace-manifest.js.map +1 -1
- package/dist/lib/composer.d.ts.map +1 -1
- package/dist/lib/composer.js +6 -8
- package/dist/lib/composer.js.map +1 -1
- package/dist/lib/launch-identity/index.d.ts +0 -4
- package/dist/lib/launch-identity/index.d.ts.map +1 -1
- package/dist/lib/launch-identity/index.js +0 -4
- package/dist/lib/launch-identity/index.js.map +1 -1
- package/package.json +3 -3
- package/src/lib/agent-workspace-manifest.ts +41 -1
- package/src/lib/composer.ts +13 -14
- package/src/lib/launch-identity/index.ts +0 -4
- package/dist/lib/launch-identity/compiled-session-launch-plan-store.d.ts +0 -44
- package/dist/lib/launch-identity/compiled-session-launch-plan-store.d.ts.map +0 -1
- package/dist/lib/launch-identity/compiled-session-launch-plan-store.js +0 -116
- package/dist/lib/launch-identity/compiled-session-launch-plan-store.js.map +0 -1
- package/dist/lib/launch-identity/compiled-session-launch-plan.d.ts +0 -84
- package/dist/lib/launch-identity/compiled-session-launch-plan.d.ts.map +0 -1
- package/dist/lib/launch-identity/compiled-session-launch-plan.js +0 -382
- package/dist/lib/launch-identity/compiled-session-launch-plan.js.map +0 -1
- package/dist/lib/launch-identity/preparation-generation.d.ts +0 -26
- package/dist/lib/launch-identity/preparation-generation.d.ts.map +0 -1
- package/dist/lib/launch-identity/preparation-generation.js +0 -88
- package/dist/lib/launch-identity/preparation-generation.js.map +0 -1
- package/dist/lib/launch-identity/prepared-launch-variant.d.ts +0 -46
- package/dist/lib/launch-identity/prepared-launch-variant.d.ts.map +0 -1
- package/dist/lib/launch-identity/prepared-launch-variant.js +0 -118
- package/dist/lib/launch-identity/prepared-launch-variant.js.map +0 -1
- package/src/lib/launch-identity/compiled-session-launch-plan-store.ts +0 -178
- package/src/lib/launch-identity/compiled-session-launch-plan.ts +0 -681
- package/src/lib/launch-identity/preparation-generation.ts +0 -171
- package/src/lib/launch-identity/prepared-launch-variant.ts +0 -263
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { WorkerRuntimeKind } from '@xemahq/kernel-contracts/worker-runtime';
|
|
2
|
-
import { type PreparationFailure } from './preparation-generation';
|
|
3
|
-
import { RuntimeTemplateTenantDependency, RuntimeTemplateTrustPolicy } from './runtime-template-key';
|
|
4
|
-
export declare enum PreparedLaunchVariantStatus {
|
|
5
|
-
Materializing = "materializing",
|
|
6
|
-
Ready = "ready",
|
|
7
|
-
Failed = "failed",
|
|
8
|
-
Retired = "retired"
|
|
9
|
-
}
|
|
10
|
-
export type PreparedLaunchTenantDependency = {
|
|
11
|
-
readonly kind: RuntimeTemplateTenantDependency.OrganizationNeutral;
|
|
12
|
-
} | {
|
|
13
|
-
readonly kind: RuntimeTemplateTenantDependency.OrganizationBound;
|
|
14
|
-
readonly organizationScopeHash: string;
|
|
15
|
-
};
|
|
16
|
-
export interface PreparedLaunchVariantKey {
|
|
17
|
-
readonly schemaVersion: 1;
|
|
18
|
-
readonly runtimeKind: WorkerRuntimeKind;
|
|
19
|
-
readonly runtimeRevision: string;
|
|
20
|
-
readonly imageDigest: `sha256:${string}`;
|
|
21
|
-
readonly layoutProfileRef: string;
|
|
22
|
-
readonly staticDependencyClosureHash: string;
|
|
23
|
-
readonly tenantDependency: PreparedLaunchTenantDependency;
|
|
24
|
-
readonly trustPolicy: RuntimeTemplateTrustPolicy;
|
|
25
|
-
readonly policyGenerationHash: string;
|
|
26
|
-
readonly region: string;
|
|
27
|
-
}
|
|
28
|
-
export interface PreparedLaunchVariant {
|
|
29
|
-
readonly id: string;
|
|
30
|
-
readonly preparationGenerationId: string;
|
|
31
|
-
readonly key: PreparedLaunchVariantKey;
|
|
32
|
-
readonly keyHash: string;
|
|
33
|
-
readonly compiledLaunchPlanHash: string;
|
|
34
|
-
readonly preparedRuntimeTemplateHash: string;
|
|
35
|
-
readonly preparedRuntimeTemplateRef: string;
|
|
36
|
-
readonly status: PreparedLaunchVariantStatus;
|
|
37
|
-
readonly failure?: PreparationFailure;
|
|
38
|
-
readonly rowVersion: number;
|
|
39
|
-
}
|
|
40
|
-
export declare function createPreparedLaunchVariantKey(input: unknown): PreparedLaunchVariantKey;
|
|
41
|
-
export declare function serializePreparedLaunchVariantKey(input: PreparedLaunchVariantKey): string;
|
|
42
|
-
export declare function hashPreparedLaunchVariantKey(input: PreparedLaunchVariantKey): string;
|
|
43
|
-
export declare function createPreparedLaunchVariant(input: unknown): PreparedLaunchVariant;
|
|
44
|
-
export declare function serializePreparedLaunchVariant(input: PreparedLaunchVariant): string;
|
|
45
|
-
export declare function hashPreparedLaunchVariant(input: PreparedLaunchVariant): string;
|
|
46
|
-
//# sourceMappingURL=prepared-launch-variant.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prepared-launch-variant.d.ts","sourceRoot":"","sources":["../../../src/lib/launch-identity/prepared-launch-variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAY5E,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,EAC3B,MAAM,wBAAwB,CAAC;AAEhC,oBAAY,2BAA2B;IACrC,aAAa,kBAAkB;IAC/B,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,8BAA8B,GACtC;IACE,QAAQ,CAAC,IAAI,EAAE,+BAA+B,CAAC,mBAAmB,CAAC;CACpE,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,+BAA+B,CAAC,iBAAiB,CAAC;IACjE,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;CACxC,CAAC;AAEN,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAC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BAAqB,GAC3B,MAAM,CAER;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,qBAAqB,GAC3B,MAAM,CAER"}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PreparedLaunchVariantStatus = void 0;
|
|
4
|
-
exports.createPreparedLaunchVariantKey = createPreparedLaunchVariantKey;
|
|
5
|
-
exports.serializePreparedLaunchVariantKey = serializePreparedLaunchVariantKey;
|
|
6
|
-
exports.hashPreparedLaunchVariantKey = hashPreparedLaunchVariantKey;
|
|
7
|
-
exports.createPreparedLaunchVariant = createPreparedLaunchVariant;
|
|
8
|
-
exports.serializePreparedLaunchVariant = serializePreparedLaunchVariant;
|
|
9
|
-
exports.hashPreparedLaunchVariant = hashPreparedLaunchVariant;
|
|
10
|
-
const worker_runtime_1 = require("@xemahq/kernel-contracts/worker-runtime");
|
|
11
|
-
const canonical_contract_1 = require("./canonical-contract");
|
|
12
|
-
const preparation_generation_1 = require("./preparation-generation");
|
|
13
|
-
const runtime_template_key_1 = require("./runtime-template-key");
|
|
14
|
-
var PreparedLaunchVariantStatus;
|
|
15
|
-
(function (PreparedLaunchVariantStatus) {
|
|
16
|
-
PreparedLaunchVariantStatus["Materializing"] = "materializing";
|
|
17
|
-
PreparedLaunchVariantStatus["Ready"] = "ready";
|
|
18
|
-
PreparedLaunchVariantStatus["Failed"] = "failed";
|
|
19
|
-
PreparedLaunchVariantStatus["Retired"] = "retired";
|
|
20
|
-
})(PreparedLaunchVariantStatus || (exports.PreparedLaunchVariantStatus = PreparedLaunchVariantStatus = {}));
|
|
21
|
-
const KEY_KEYS = [
|
|
22
|
-
'schemaVersion',
|
|
23
|
-
'runtimeKind',
|
|
24
|
-
'runtimeRevision',
|
|
25
|
-
'imageDigest',
|
|
26
|
-
'layoutProfileRef',
|
|
27
|
-
'staticDependencyClosureHash',
|
|
28
|
-
'tenantDependency',
|
|
29
|
-
'trustPolicy',
|
|
30
|
-
'policyGenerationHash',
|
|
31
|
-
'region',
|
|
32
|
-
];
|
|
33
|
-
const VARIANT_KEYS = [
|
|
34
|
-
'id',
|
|
35
|
-
'preparationGenerationId',
|
|
36
|
-
'key',
|
|
37
|
-
'keyHash',
|
|
38
|
-
'compiledLaunchPlanHash',
|
|
39
|
-
'preparedRuntimeTemplateHash',
|
|
40
|
-
'preparedRuntimeTemplateRef',
|
|
41
|
-
'status',
|
|
42
|
-
'rowVersion',
|
|
43
|
-
];
|
|
44
|
-
const VARIANT_OPTIONAL_KEYS = ['failure'];
|
|
45
|
-
const RUNTIME_KINDS = Object.values(worker_runtime_1.WorkerRuntimeKind);
|
|
46
|
-
const TENANT_DEPENDENCY_KINDS = Object.values(runtime_template_key_1.RuntimeTemplateTenantDependency);
|
|
47
|
-
const TRUST_POLICIES = Object.values(runtime_template_key_1.RuntimeTemplateTrustPolicy);
|
|
48
|
-
const VARIANT_STATUSES = Object.values(PreparedLaunchVariantStatus);
|
|
49
|
-
function createPreparedLaunchVariantKey(input) {
|
|
50
|
-
const object = (0, canonical_contract_1.requireExactObject)(input, 'PreparedLaunchVariantKey', KEY_KEYS);
|
|
51
|
-
if (object.schemaVersion !== 1) {
|
|
52
|
-
throw new TypeError('PreparedLaunchVariantKey.schemaVersion must be 1.');
|
|
53
|
-
}
|
|
54
|
-
return Object.freeze({
|
|
55
|
-
schemaVersion: 1,
|
|
56
|
-
runtimeKind: (0, canonical_contract_1.requireEnumValue)(object.runtimeKind, 'PreparedLaunchVariantKey.runtimeKind', RUNTIME_KINDS),
|
|
57
|
-
runtimeRevision: (0, canonical_contract_1.requireNonEmptyString)(object.runtimeRevision, 'PreparedLaunchVariantKey.runtimeRevision'),
|
|
58
|
-
imageDigest: (0, canonical_contract_1.requireImageDigest)(object.imageDigest, 'PreparedLaunchVariantKey.imageDigest'),
|
|
59
|
-
layoutProfileRef: (0, canonical_contract_1.requireNonEmptyString)(object.layoutProfileRef, 'PreparedLaunchVariantKey.layoutProfileRef'),
|
|
60
|
-
staticDependencyClosureHash: (0, canonical_contract_1.requireSha256)(object.staticDependencyClosureHash, 'PreparedLaunchVariantKey.staticDependencyClosureHash'),
|
|
61
|
-
tenantDependency: requireTenantDependency(object.tenantDependency),
|
|
62
|
-
trustPolicy: (0, canonical_contract_1.requireEnumValue)(object.trustPolicy, 'PreparedLaunchVariantKey.trustPolicy', TRUST_POLICIES),
|
|
63
|
-
policyGenerationHash: (0, canonical_contract_1.requireSha256)(object.policyGenerationHash, 'PreparedLaunchVariantKey.policyGenerationHash'),
|
|
64
|
-
region: (0, canonical_contract_1.requireNonEmptyString)(object.region, 'PreparedLaunchVariantKey.region'),
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
function serializePreparedLaunchVariantKey(input) {
|
|
68
|
-
return (0, canonical_contract_1.canonicalContractJson)(createPreparedLaunchVariantKey(input));
|
|
69
|
-
}
|
|
70
|
-
function hashPreparedLaunchVariantKey(input) {
|
|
71
|
-
return (0, canonical_contract_1.hashCanonicalContract)(createPreparedLaunchVariantKey(input));
|
|
72
|
-
}
|
|
73
|
-
function createPreparedLaunchVariant(input) {
|
|
74
|
-
const object = (0, canonical_contract_1.requireExactObject)(input, 'PreparedLaunchVariant', VARIANT_KEYS, VARIANT_OPTIONAL_KEYS);
|
|
75
|
-
const key = createPreparedLaunchVariantKey(object.key);
|
|
76
|
-
const keyHash = (0, canonical_contract_1.requireSha256)(object.keyHash, 'PreparedLaunchVariant.keyHash');
|
|
77
|
-
if (keyHash !== hashPreparedLaunchVariantKey(key)) {
|
|
78
|
-
throw new TypeError('PreparedLaunchVariant.keyHash must equal the canonical key hash.');
|
|
79
|
-
}
|
|
80
|
-
const status = (0, canonical_contract_1.requireEnumValue)(object.status, 'PreparedLaunchVariant.status', VARIANT_STATUSES);
|
|
81
|
-
const failure = (0, preparation_generation_1.requirePreparationFailureForStatus)(object.failure, Object.hasOwn(object, 'failure'), status === PreparedLaunchVariantStatus.Failed, 'PreparedLaunchVariant');
|
|
82
|
-
return Object.freeze({
|
|
83
|
-
id: (0, canonical_contract_1.requireNonEmptyString)(object.id, 'PreparedLaunchVariant.id'),
|
|
84
|
-
preparationGenerationId: (0, canonical_contract_1.requireNonEmptyString)(object.preparationGenerationId, 'PreparedLaunchVariant.preparationGenerationId'),
|
|
85
|
-
key,
|
|
86
|
-
keyHash,
|
|
87
|
-
compiledLaunchPlanHash: (0, canonical_contract_1.requireSha256)(object.compiledLaunchPlanHash, 'PreparedLaunchVariant.compiledLaunchPlanHash'),
|
|
88
|
-
preparedRuntimeTemplateHash: (0, canonical_contract_1.requireSha256)(object.preparedRuntimeTemplateHash, 'PreparedLaunchVariant.preparedRuntimeTemplateHash'),
|
|
89
|
-
preparedRuntimeTemplateRef: (0, canonical_contract_1.requireNonEmptyString)(object.preparedRuntimeTemplateRef, 'PreparedLaunchVariant.preparedRuntimeTemplateRef'),
|
|
90
|
-
status,
|
|
91
|
-
...(failure === undefined ? {} : { failure }),
|
|
92
|
-
rowVersion: (0, canonical_contract_1.requireNonNegativeSafeInteger)(object.rowVersion, 'PreparedLaunchVariant.rowVersion'),
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
function serializePreparedLaunchVariant(input) {
|
|
96
|
-
return (0, canonical_contract_1.canonicalContractJson)(createPreparedLaunchVariant(input));
|
|
97
|
-
}
|
|
98
|
-
function hashPreparedLaunchVariant(input) {
|
|
99
|
-
return (0, canonical_contract_1.hashCanonicalContract)(createPreparedLaunchVariant(input));
|
|
100
|
-
}
|
|
101
|
-
function requireTenantDependency(input) {
|
|
102
|
-
const base = (0, canonical_contract_1.requireExactObject)(input, 'PreparedLaunchVariantKey.tenantDependency', ['kind'], ['organizationScopeHash']);
|
|
103
|
-
const kind = (0, canonical_contract_1.requireEnumValue)(base.kind, 'PreparedLaunchVariantKey.tenantDependency.kind', TENANT_DEPENDENCY_KINDS);
|
|
104
|
-
if (kind === runtime_template_key_1.RuntimeTemplateTenantDependency.OrganizationNeutral) {
|
|
105
|
-
if (Object.hasOwn(base, 'organizationScopeHash')) {
|
|
106
|
-
throw new TypeError('PreparedLaunchVariantKey.tenantDependency.organizationScopeHash is forbidden for organization-neutral variants.');
|
|
107
|
-
}
|
|
108
|
-
return Object.freeze({ kind });
|
|
109
|
-
}
|
|
110
|
-
if (!Object.hasOwn(base, 'organizationScopeHash')) {
|
|
111
|
-
throw new TypeError('PreparedLaunchVariantKey.tenantDependency.organizationScopeHash is required for organization-bound variants.');
|
|
112
|
-
}
|
|
113
|
-
return Object.freeze({
|
|
114
|
-
kind,
|
|
115
|
-
organizationScopeHash: (0, canonical_contract_1.requireSha256)(base.organizationScopeHash, 'PreparedLaunchVariantKey.tenantDependency.organizationScopeHash'),
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=prepared-launch-variant.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prepared-launch-variant.js","sourceRoot":"","sources":["../../../src/lib/launch-identity/prepared-launch-variant.ts"],"names":[],"mappings":";;;AA4FA,wEAkDC;AAED,8EAIC;AAED,oEAIC;AAED,kEA0DC;AAED,wEAIC;AAED,8DAIC;AAlOD,4EAA4E;AAE5E,6DAS8B;AAC9B,qEAGkC;AAClC,iEAGgC;AAEhC,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACrC,8DAA+B,CAAA;IAC/B,8CAAe,CAAA;IACf,gDAAiB,CAAA;IACjB,kDAAmB,CAAA;AACrB,CAAC,EALW,2BAA2B,2CAA3B,2BAA2B,QAKtC;AAqCD,MAAM,QAAQ,GAAG;IACf,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,aAAa;IACb,kBAAkB;IAClB,6BAA6B;IAC7B,kBAAkB;IAClB,aAAa;IACb,sBAAsB;IACtB,QAAQ;CACA,CAAC;AACX,MAAM,YAAY,GAAG;IACnB,IAAI;IACJ,yBAAyB;IACzB,KAAK;IACL,SAAS;IACT,wBAAwB;IACxB,6BAA6B;I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,CACjB,iHAAiH,CAClH,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,uBAAuB,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,SAAS,CACjB,8GAA8G,CAC/G,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI;QACJ,qBAAqB,EAAE,IAAA,kCAAa,EAClC,IAAI,CAAC,qBAAqB,EAC1B,iEAAiE,CAClE;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { requireSha256 } from './canonical-contract';
|
|
2
|
-
import {
|
|
3
|
-
createCompiledSessionLaunchPlan,
|
|
4
|
-
decodeCompiledSessionLaunchPlan,
|
|
5
|
-
encodeCompiledSessionLaunchPlan,
|
|
6
|
-
hashCompiledSessionLaunchPlan,
|
|
7
|
-
type CompiledSessionLaunchPlan,
|
|
8
|
-
} from './compiled-session-launch-plan';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Storage boundary exposed to session launchers. Reads never degrade to a
|
|
12
|
-
* recompute path: a missing or corrupt plan is an explicit launch failure.
|
|
13
|
-
*/
|
|
14
|
-
export interface CompiledSessionLaunchPlanStore {
|
|
15
|
-
getByHash(contentHash: string): Promise<CompiledSessionLaunchPlan>;
|
|
16
|
-
putByHash(
|
|
17
|
-
contentHash: string,
|
|
18
|
-
plan: CompiledSessionLaunchPlan,
|
|
19
|
-
): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Minimal immutable byte-store seam implemented by the eventual database or
|
|
24
|
-
* object-store adapter. `create` must be atomic and must not overwrite.
|
|
25
|
-
*/
|
|
26
|
-
export interface ImmutableCompiledSessionLaunchPlanContentStore {
|
|
27
|
-
read(contentHash: string): Promise<string | undefined>;
|
|
28
|
-
create(contentHash: string, encodedPlan: string): Promise<boolean>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class CompiledSessionLaunchPlanMissingError extends Error {
|
|
32
|
-
override readonly name = 'CompiledSessionLaunchPlanMissingError';
|
|
33
|
-
|
|
34
|
-
constructor(readonly contentHash: string) {
|
|
35
|
-
super(`Compiled session launch plan '${contentHash}' does not exist.`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export class CompiledSessionLaunchPlanAddressMismatchError extends Error {
|
|
40
|
-
override readonly name = 'CompiledSessionLaunchPlanAddressMismatchError';
|
|
41
|
-
|
|
42
|
-
constructor(
|
|
43
|
-
readonly expectedHash: string,
|
|
44
|
-
readonly actualHash: string,
|
|
45
|
-
) {
|
|
46
|
-
super(
|
|
47
|
-
`Compiled session launch plan address '${expectedHash}' does not match its content hash '${actualHash}'.`,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export class CompiledSessionLaunchPlanCollisionError extends Error {
|
|
53
|
-
override readonly name = 'CompiledSessionLaunchPlanCollisionError';
|
|
54
|
-
|
|
55
|
-
constructor(readonly contentHash: string) {
|
|
56
|
-
super(
|
|
57
|
-
`Immutable content collision at compiled session launch plan '${contentHash}'.`,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export class CompiledSessionLaunchPlanIntegrityError extends Error {
|
|
63
|
-
override readonly name = 'CompiledSessionLaunchPlanIntegrityError';
|
|
64
|
-
|
|
65
|
-
constructor(
|
|
66
|
-
readonly contentHash: string,
|
|
67
|
-
override readonly cause: unknown,
|
|
68
|
-
) {
|
|
69
|
-
super(
|
|
70
|
-
`Compiled session launch plan '${contentHash}' failed content verification.`,
|
|
71
|
-
{ cause },
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Verifies canonical bytes and content address on every read and write. This
|
|
78
|
-
* keeps corruption and impossible hash collisions observable at the storage
|
|
79
|
-
* boundary instead of passing damaged launch state to a runtime.
|
|
80
|
-
*/
|
|
81
|
-
export class VerifyingCompiledSessionLaunchPlanStore
|
|
82
|
-
implements CompiledSessionLaunchPlanStore
|
|
83
|
-
{
|
|
84
|
-
constructor(
|
|
85
|
-
private readonly contentStore: ImmutableCompiledSessionLaunchPlanContentStore,
|
|
86
|
-
) {}
|
|
87
|
-
|
|
88
|
-
async getByHash(contentHash: string): Promise<CompiledSessionLaunchPlan> {
|
|
89
|
-
const hash = requireSha256(contentHash, 'contentHash');
|
|
90
|
-
const encoded = await this.contentStore.read(hash);
|
|
91
|
-
if (encoded === undefined) {
|
|
92
|
-
throw new CompiledSessionLaunchPlanMissingError(hash);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
const plan = decodeCompiledSessionLaunchPlan(encoded);
|
|
97
|
-
const actualHash = hashCompiledSessionLaunchPlan(plan);
|
|
98
|
-
if (actualHash !== hash) {
|
|
99
|
-
throw new CompiledSessionLaunchPlanAddressMismatchError(
|
|
100
|
-
hash,
|
|
101
|
-
actualHash,
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
if (encodeCompiledSessionLaunchPlan(plan) !== encoded) {
|
|
105
|
-
throw new TypeError(
|
|
106
|
-
'Stored launch plan bytes are not in canonical encoding.',
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
return plan;
|
|
110
|
-
} catch (error) {
|
|
111
|
-
throw new CompiledSessionLaunchPlanIntegrityError(hash, error);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async putByHash(
|
|
116
|
-
contentHash: string,
|
|
117
|
-
plan: CompiledSessionLaunchPlan,
|
|
118
|
-
): Promise<void> {
|
|
119
|
-
const hash = requireSha256(contentHash, 'contentHash');
|
|
120
|
-
const canonicalPlan = createCompiledSessionLaunchPlan(plan);
|
|
121
|
-
const actualHash = hashCompiledSessionLaunchPlan(canonicalPlan);
|
|
122
|
-
if (actualHash !== hash) {
|
|
123
|
-
throw new CompiledSessionLaunchPlanAddressMismatchError(hash, actualHash);
|
|
124
|
-
}
|
|
125
|
-
const encoded = encodeCompiledSessionLaunchPlan(canonicalPlan);
|
|
126
|
-
|
|
127
|
-
const existing = await this.contentStore.read(hash);
|
|
128
|
-
if (existing !== undefined) {
|
|
129
|
-
this.assertSameContent(hash, existing, encoded);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const created = await this.contentStore.create(hash, encoded);
|
|
134
|
-
if (created) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const racedExisting = await this.contentStore.read(hash);
|
|
139
|
-
if (racedExisting === undefined) {
|
|
140
|
-
throw new CompiledSessionLaunchPlanIntegrityError(
|
|
141
|
-
hash,
|
|
142
|
-
new Error(
|
|
143
|
-
'Immutable content store reported an existing value but returned no content.',
|
|
144
|
-
),
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
this.assertSameContent(hash, racedExisting, encoded);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private assertSameContent(
|
|
151
|
-
contentHash: string,
|
|
152
|
-
existing: string,
|
|
153
|
-
expected: string,
|
|
154
|
-
): void {
|
|
155
|
-
if (existing !== expected) {
|
|
156
|
-
throw new CompiledSessionLaunchPlanCollisionError(contentHash);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/** Deterministic in-memory adapter for tests and process-local tooling. */
|
|
162
|
-
export class InMemoryCompiledSessionLaunchPlanContentStore
|
|
163
|
-
implements ImmutableCompiledSessionLaunchPlanContentStore
|
|
164
|
-
{
|
|
165
|
-
private readonly values = new Map<string, string>();
|
|
166
|
-
|
|
167
|
-
async read(contentHash: string): Promise<string | undefined> {
|
|
168
|
-
return this.values.get(contentHash);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async create(contentHash: string, encodedPlan: string): Promise<boolean> {
|
|
172
|
-
if (this.values.has(contentHash)) {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
this.values.set(contentHash, encodedPlan);
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
}
|