@techis/ai-contracts 0.0.0-stage → 0.3.0-rc.15
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/LICENSE +122 -0
- package/README.md +28 -3
- package/THIRD_PARTY_NOTICES +34 -0
- package/dist/availability.d.ts +21 -0
- package/dist/availability.d.ts.map +1 -0
- package/dist/availability.js +2 -0
- package/dist/availability.js.map +1 -0
- package/dist/catalog-adoption.d.ts +20 -0
- package/dist/catalog-adoption.d.ts.map +1 -0
- package/dist/catalog-adoption.js +76 -0
- package/dist/catalog-adoption.js.map +1 -0
- package/dist/catalog-composition.d.ts +10 -0
- package/dist/catalog-composition.d.ts.map +1 -0
- package/dist/catalog-composition.js +58 -0
- package/dist/catalog-composition.js.map +1 -0
- package/dist/catalog-delivery.d.ts +47 -0
- package/dist/catalog-delivery.d.ts.map +1 -0
- package/dist/catalog-delivery.js +83 -0
- package/dist/catalog-delivery.js.map +1 -0
- package/dist/catalog-package-data.d.ts +8 -0
- package/dist/catalog-package-data.d.ts.map +1 -0
- package/dist/catalog-package-data.js +2640 -0
- package/dist/catalog-package-data.js.map +1 -0
- package/dist/compatibility.d.ts +68 -0
- package/dist/compatibility.d.ts.map +1 -0
- package/dist/compatibility.js +207 -0
- package/dist/compatibility.js.map +1 -0
- package/dist/configuration-bundle.d.ts +201 -0
- package/dist/configuration-bundle.d.ts.map +1 -0
- package/dist/configuration-bundle.js +619 -0
- package/dist/configuration-bundle.js.map +1 -0
- package/dist/entities.d.ts +619 -0
- package/dist/entities.d.ts.map +1 -0
- package/dist/entities.js +2 -0
- package/dist/entities.js.map +1 -0
- package/dist/fixtures.d.ts +25 -0
- package/dist/fixtures.d.ts.map +1 -0
- package/dist/fixtures.js +546 -0
- package/dist/fixtures.js.map +1 -0
- package/dist/hash.d.ts +8 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +13 -0
- package/dist/hash.js.map +1 -0
- package/dist/host-qualification.d.ts +90 -0
- package/dist/host-qualification.d.ts.map +1 -0
- package/dist/host-qualification.js +65 -0
- package/dist/host-qualification.js.map +1 -0
- package/dist/icc-catalog.d.ts +31 -0
- package/dist/icc-catalog.d.ts.map +1 -0
- package/dist/icc-catalog.js +321 -0
- package/dist/icc-catalog.js.map +1 -0
- package/dist/icc-csf-profiles.d.ts +28 -0
- package/dist/icc-csf-profiles.d.ts.map +1 -0
- package/dist/icc-csf-profiles.js +394 -0
- package/dist/icc-csf-profiles.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/model-maintenance.d.ts +216 -0
- package/dist/model-maintenance.d.ts.map +1 -0
- package/dist/model-maintenance.js +387 -0
- package/dist/model-maintenance.js.map +1 -0
- package/dist/model-package-data.d.ts +3 -0
- package/dist/model-package-data.d.ts.map +1 -0
- package/dist/model-package-data.js +867 -0
- package/dist/model-package-data.js.map +1 -0
- package/dist/persona-inventory.d.ts +143 -0
- package/dist/persona-inventory.d.ts.map +1 -0
- package/dist/persona-inventory.js +56 -0
- package/dist/persona-inventory.js.map +1 -0
- package/dist/profile-identity.d.ts +27 -0
- package/dist/profile-identity.d.ts.map +1 -0
- package/dist/profile-identity.js +30 -0
- package/dist/profile-identity.js.map +1 -0
- package/dist/reasoning-validation.d.ts +9 -0
- package/dist/reasoning-validation.d.ts.map +1 -0
- package/dist/reasoning-validation.js +79 -0
- package/dist/reasoning-validation.js.map +1 -0
- package/dist/reasoning.d.ts +55 -0
- package/dist/reasoning.d.ts.map +1 -0
- package/dist/reasoning.js +13 -0
- package/dist/reasoning.js.map +1 -0
- package/dist/receipt.d.ts +16 -0
- package/dist/receipt.d.ts.map +1 -0
- package/dist/receipt.js +18 -0
- package/dist/receipt.js.map +1 -0
- package/dist/schemas/adoption-change-set.schema.json +91 -0
- package/dist/schemas/bundle.d.ts +124 -0
- package/dist/schemas/bundle.d.ts.map +1 -0
- package/dist/schemas/bundle.js +84 -0
- package/dist/schemas/bundle.js.map +1 -0
- package/dist/schemas/catalog-release.schema.json +110 -0
- package/dist/schemas/catalog-review-input.schema.json +179 -0
- package/dist/schemas/catalog-review-output.schema.json +259 -0
- package/dist/schemas/catalog-review-output.v2.schema.json +251 -0
- package/dist/schemas/catalog-review-record.schema.json +391 -0
- package/dist/schemas/client-persona-inventory.schema.json +107 -0
- package/dist/schemas/common.schema.json +324 -0
- package/dist/schemas/config.d.ts +1106 -0
- package/dist/schemas/config.d.ts.map +1 -0
- package/dist/schemas/config.js +496 -0
- package/dist/schemas/config.js.map +1 -0
- package/dist/schemas/configuration-bundle-manifest.schema.json +143 -0
- package/dist/schemas/configuration-manifest.schema.json +109 -0
- package/dist/schemas/connection.schema.json +49 -0
- package/dist/schemas/core.d.ts +1333 -0
- package/dist/schemas/core.d.ts.map +1 -0
- package/dist/schemas/core.js +341 -0
- package/dist/schemas/core.js.map +1 -0
- package/dist/schemas/desktop-configuration-revision.schema.json +146 -0
- package/dist/schemas/execution-profile-revision.schema.json +235 -0
- package/dist/schemas/execution-receipt.schema.json +431 -0
- package/dist/schemas/host-adapter-qualification.schema.json +161 -0
- package/dist/schemas/host-qualification-policy.schema.json +50 -0
- package/dist/schemas/index.d.ts +11 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +34 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/inventory.d.ts +170 -0
- package/dist/schemas/inventory.d.ts.map +1 -0
- package/dist/schemas/inventory.js +87 -0
- package/dist/schemas/inventory.js.map +1 -0
- package/dist/schemas/model-definition.schema.json +429 -0
- package/dist/schemas/model-package-release.schema.json +594 -0
- package/dist/schemas/model-upgrade-advisory.schema.json +191 -0
- package/dist/schemas/operation-contract-document.schema.json +153 -0
- package/dist/schemas/persona-assignments.schema.json +125 -0
- package/dist/schemas/persona-registry-overlay.schema.json +93 -0
- package/dist/schemas/persona-source-document.schema.json +86 -0
- package/dist/schemas/persona-specification.schema.json +122 -0
- package/dist/schemas/price-revision.schema.json +299 -0
- package/dist/schemas/profile-assessment.schema.json +288 -0
- package/dist/schemas/scoped.d.ts +424 -0
- package/dist/schemas/scoped.d.ts.map +1 -0
- package/dist/schemas/scoped.js +203 -0
- package/dist/schemas/scoped.js.map +1 -0
- package/dist/schemas/usage-aggregate-query.schema.json +86 -0
- package/dist/schemas/usage-page.schema.json +22 -0
- package/dist/schemas/usage-query.schema.json +77 -0
- package/dist/schemas/usage-summary.schema.json +468 -0
- package/dist/schemas/usage.d.ts +527 -0
- package/dist/schemas/usage.d.ts.map +1 -0
- package/dist/schemas/usage.js +142 -0
- package/dist/schemas/usage.js.map +1 -0
- package/dist/scoped-configuration.d.ts +208 -0
- package/dist/scoped-configuration.d.ts.map +1 -0
- package/dist/scoped-configuration.js +425 -0
- package/dist/scoped-configuration.js.map +1 -0
- package/dist/scripts/emit-schemas.d.ts +2 -0
- package/dist/scripts/emit-schemas.d.ts.map +1 -0
- package/dist/scripts/emit-schemas.js +24 -0
- package/dist/scripts/emit-schemas.js.map +1 -0
- package/dist/scripts/verify-bundle.d.ts +3 -0
- package/dist/scripts/verify-bundle.d.ts.map +1 -0
- package/dist/scripts/verify-bundle.js +59 -0
- package/dist/scripts/verify-bundle.js.map +1 -0
- package/dist/validation.d.ts +11 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +41 -0
- package/dist/validation.js.map +1 -0
- package/package.json +33 -6
- package/third-party-licenses/ajv-formats@3.0.1/LICENSE +21 -0
- package/third-party-licenses/ajv@8.20.0/LICENSE +22 -0
- package/third-party-licenses/fast-deep-equal@3.1.3/LICENSE +21 -0
- package/third-party-licenses/fast-uri@3.1.7/LICENSE +30 -0
- package/third-party-licenses/json-schema-traverse@1.0.0/LICENSE +21 -0
- package/third-party-licenses/require-from-string@2.0.2/license +21 -0
- package/third-party-licenses/typescript@5.9.3/LICENSE.txt +55 -0
- package/third-party-licenses/typescript@5.9.3/ThirdPartyNoticeText.txt +193 -0
- package/third-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AAkB,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE;SACpH;KACF;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,WAAW,4BAA4B,CAAC;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,GAAG,EAAE,oBAAoB;IACzB,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC9B,UAAU,EAAE;QACV,MAAM,EAAE,iBAAiB;QACzB,MAAM,EAAE;YACN,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;gBAC3B,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC;gBAC1C,UAAU,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE;aAC3F;SACF;KACF;CACO,CAAC"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import type { CatalogRelease, Connection, ExecutionProfileRevision, Modality } from "./entities.js";
|
|
2
|
+
/**
|
|
3
|
+
* v2 scoped configuration contracts (implementation plan sections 4-5).
|
|
4
|
+
*
|
|
5
|
+
* Source-neutral by design: the same exact-reference types, path layouts, canonical
|
|
6
|
+
* hashing and validation serve the managed HTTP routes and the ICC host-owned local
|
|
7
|
+
* snapshot repository. v2 never reinterprets missing v1 fields as a desktop or workspace,
|
|
8
|
+
* never resolves "latest"/channel references, and always pins exact immutable revisions.
|
|
9
|
+
*/
|
|
10
|
+
export type ScopedEnvironmentId = "development" | "test" | "production";
|
|
11
|
+
export interface ScopedConfigurationScopeV2 {
|
|
12
|
+
applicationId: string;
|
|
13
|
+
environmentId: ScopedEnvironmentId;
|
|
14
|
+
desktopConfigurationId: string;
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function isScopedEnvironmentId(value: unknown): value is ScopedEnvironmentId;
|
|
18
|
+
export declare class ScopedConfigurationValidationError extends Error {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
21
|
+
/** Validates and normalizes a full v2 scope. Omitted or mixed scope parts are rejected. */
|
|
22
|
+
export declare function assertValidScopeV2(scope: unknown): asserts scope is ScopedConfigurationScopeV2;
|
|
23
|
+
export interface ExactProfileRef {
|
|
24
|
+
profileId: string;
|
|
25
|
+
revision: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ExactDocumentRef {
|
|
28
|
+
id: string;
|
|
29
|
+
revision: string;
|
|
30
|
+
sha256: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function isExactRevisionV2(value: unknown): value is string;
|
|
33
|
+
export declare function assertExactRevisionV2(value: unknown, label: string): asserts value is string;
|
|
34
|
+
export declare function assertExactProfileRefV2(value: unknown, label: string): asserts value is ExactProfileRef;
|
|
35
|
+
export declare function assertExactDocumentRefV2(value: unknown, label: string): asserts value is ExactDocumentRef;
|
|
36
|
+
export interface DesktopConfigurationRevisionV2 {
|
|
37
|
+
schemaVersion: 2;
|
|
38
|
+
applicationId: string;
|
|
39
|
+
environmentId: ScopedEnvironmentId;
|
|
40
|
+
desktopConfigurationId: string;
|
|
41
|
+
revision: string;
|
|
42
|
+
parentRevision: string | null;
|
|
43
|
+
restoredFromRevision?: string;
|
|
44
|
+
bindings: Record<string, ExactProfileRef>;
|
|
45
|
+
catalog: ExactDocumentRef;
|
|
46
|
+
connections: Record<string, ExactDocumentRef>;
|
|
47
|
+
workspaces: Record<string, {
|
|
48
|
+
personaSources: Record<string, ExactDocumentRef>;
|
|
49
|
+
operationContract: ExactDocumentRef;
|
|
50
|
+
}>;
|
|
51
|
+
operationId: string;
|
|
52
|
+
changedBy: string;
|
|
53
|
+
createdAt: string;
|
|
54
|
+
}
|
|
55
|
+
export declare function assertDesktopConfigurationRevisionV2(value: unknown): asserts value is DesktopConfigurationRevisionV2;
|
|
56
|
+
export interface PersonaSourceDocumentV2 {
|
|
57
|
+
schemaVersion: 2;
|
|
58
|
+
kind: "persona-source";
|
|
59
|
+
applicationId: string;
|
|
60
|
+
bindingId: string;
|
|
61
|
+
workspaceId: string;
|
|
62
|
+
systemInstructions: string;
|
|
63
|
+
instructionHash: string;
|
|
64
|
+
/** Hash-based revision for v2 persona documents; never v1's numeric instructionVersion. */
|
|
65
|
+
revision: string;
|
|
66
|
+
/** Original source version recorded separately for provenance. */
|
|
67
|
+
sourceVersion?: string;
|
|
68
|
+
provenance: {
|
|
69
|
+
registeredBy: string;
|
|
70
|
+
registeredAt: string;
|
|
71
|
+
baseDocumentRef?: ExactDocumentRef;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export interface OperationRequirementV2 {
|
|
75
|
+
operationId: string;
|
|
76
|
+
bindingId: string;
|
|
77
|
+
inputModalities: Modality[];
|
|
78
|
+
providerTools: string[];
|
|
79
|
+
protectedPayloadPolicy: "none" | "sanitized" | "forbidden";
|
|
80
|
+
timeoutMs: number;
|
|
81
|
+
webSearch: boolean;
|
|
82
|
+
structuredOutput: boolean;
|
|
83
|
+
outputSchema?: Record<string, unknown>;
|
|
84
|
+
imageDetail?: "low" | "medium" | "high" | "original";
|
|
85
|
+
compositionVersion?: string;
|
|
86
|
+
executionVariants?: string[];
|
|
87
|
+
}
|
|
88
|
+
export interface OperationContractDocumentV2 {
|
|
89
|
+
schemaVersion: 2;
|
|
90
|
+
kind: "operation-contract";
|
|
91
|
+
applicationId: string;
|
|
92
|
+
workspaceId: string;
|
|
93
|
+
contractId: string;
|
|
94
|
+
revision: string;
|
|
95
|
+
operations: OperationRequirementV2[];
|
|
96
|
+
provenance: {
|
|
97
|
+
registeredBy: string;
|
|
98
|
+
registeredAt: string;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export declare function assertPersonaSourceDocumentV2(value: unknown): asserts value is PersonaSourceDocumentV2;
|
|
102
|
+
export declare function assertOperationContractDocumentV2(value: unknown): asserts value is OperationContractDocumentV2;
|
|
103
|
+
/** Deterministic JSON serialization: recursively key-sorted, no insignificant whitespace. */
|
|
104
|
+
export declare function canonicalJsonV2(value: unknown): string;
|
|
105
|
+
export declare function sha256HexV2(content: string | Uint8Array): string;
|
|
106
|
+
export declare function hashDocumentV2(value: unknown): string;
|
|
107
|
+
/** Content-addressed revision for workspace documents: stable, immutable, non-reserved. */
|
|
108
|
+
export declare function contentRevisionV2(value: unknown): string;
|
|
109
|
+
export interface WorkspaceChangeSetV2 {
|
|
110
|
+
personaSources?: Record<string, ExactDocumentRef>;
|
|
111
|
+
operationContract?: ExactDocumentRef;
|
|
112
|
+
removePersonaSources?: string[];
|
|
113
|
+
}
|
|
114
|
+
export interface AdoptionChangeSetV2 {
|
|
115
|
+
/** Omitted fields mean preserve exactly. No latest, channel, null-to-default or hidden assignment. */
|
|
116
|
+
bindings?: Record<string, ExactProfileRef>;
|
|
117
|
+
removeBindings?: string[];
|
|
118
|
+
catalog?: ExactDocumentRef;
|
|
119
|
+
connections?: Record<string, ExactDocumentRef>;
|
|
120
|
+
removeConnections?: string[];
|
|
121
|
+
workspaces?: Record<string, WorkspaceChangeSetV2>;
|
|
122
|
+
removeWorkspaces?: string[];
|
|
123
|
+
restoreFromRevision?: string;
|
|
124
|
+
}
|
|
125
|
+
export declare function assertAdoptionChangeSetV2(value: unknown): asserts value is AdoptionChangeSetV2;
|
|
126
|
+
export interface AdoptionRequestV2 {
|
|
127
|
+
scope: ScopedConfigurationScopeV2;
|
|
128
|
+
/** Expected base desktop revision; null only for initial provisioning. */
|
|
129
|
+
expectedDesktopRevision: string | null;
|
|
130
|
+
expectedAvailabilityRevision?: string;
|
|
131
|
+
operationId: string;
|
|
132
|
+
changes: AdoptionChangeSetV2;
|
|
133
|
+
}
|
|
134
|
+
export interface AdoptionDependencyDiffV2 {
|
|
135
|
+
binding: string;
|
|
136
|
+
kind: "binding" | "catalog" | "connection" | "persona-source" | "operation-contract";
|
|
137
|
+
key: string;
|
|
138
|
+
from: string | null;
|
|
139
|
+
to: string | null;
|
|
140
|
+
}
|
|
141
|
+
export interface AdoptionPreviewV2 {
|
|
142
|
+
/** Canonical SHA-256 of the adoption request; the commit must present the same hash. */
|
|
143
|
+
proposalHash: string;
|
|
144
|
+
baseDesktopRevision: string | null;
|
|
145
|
+
resultingDesktopRevision: DesktopConfigurationRevisionV2;
|
|
146
|
+
dependencyDiff: AdoptionDependencyDiffV2[];
|
|
147
|
+
affectedBindings: string[];
|
|
148
|
+
affectedWorkspaces: string[];
|
|
149
|
+
compatible: boolean;
|
|
150
|
+
validationReasons: string[];
|
|
151
|
+
}
|
|
152
|
+
export declare function assertOperationIdV2(value: unknown): asserts value is string;
|
|
153
|
+
export declare function newOperationIdV2(): string;
|
|
154
|
+
/** Canonical adoption request hash used for idempotency and preview/commit agreement. */
|
|
155
|
+
export declare function hashAdoptionRequestV2(request: AdoptionRequestV2): string;
|
|
156
|
+
/** Derives the complete next desktop revision from a base and an exact patch. Omitted fields are preserved exactly. */
|
|
157
|
+
export declare function deriveDesktopRevisionV2(input: {
|
|
158
|
+
base: DesktopConfigurationRevisionV2 | null;
|
|
159
|
+
changes: AdoptionChangeSetV2;
|
|
160
|
+
scope: ScopedConfigurationScopeV2;
|
|
161
|
+
operationId: string;
|
|
162
|
+
changedBy: string;
|
|
163
|
+
now?: () => Date;
|
|
164
|
+
}): DesktopConfigurationRevisionV2;
|
|
165
|
+
export declare function assertSafePathSegmentV2(value: unknown, label: string): asserts value is string;
|
|
166
|
+
export declare const V2_APPLICATION_HEAD_KEY: (applicationId: string) => string;
|
|
167
|
+
export declare const V2_DESKTOP_REVISION_KEY: (applicationId: string, environmentId: ScopedEnvironmentId, desktopConfigurationId: string, revision: string) => string;
|
|
168
|
+
export declare const V2_WORKSPACE_PERSONA_SOURCE_KEY: (applicationId: string, environmentId: ScopedEnvironmentId, workspaceId: string, bindingId: string, revision: string) => string;
|
|
169
|
+
export declare const V2_OPERATION_CONTRACT_KEY: (applicationId: string, environmentId: ScopedEnvironmentId, workspaceId: string, revision: string) => string;
|
|
170
|
+
export type ScopedConfigurationErrorCodeV2 = "invalid-request" | "authentication-failed" | "scope-denied" | "not-found" | "conflict" | "revoked" | "incompatible" | "unavailable";
|
|
171
|
+
export declare const scopedConfigurationHttpStatusV2: Record<ScopedConfigurationErrorCodeV2, number>;
|
|
172
|
+
export interface ScopedConfigurationErrorV2 {
|
|
173
|
+
code: ScopedConfigurationErrorCodeV2;
|
|
174
|
+
message: string;
|
|
175
|
+
details?: Record<string, unknown>;
|
|
176
|
+
}
|
|
177
|
+
/** v2 request/response bodies are capped at 2 MiB; oversized submissions are rejected before any publication. */
|
|
178
|
+
export declare const MAX_V2_BODY_BYTES: number;
|
|
179
|
+
export declare function assertV2BodySizeV2(serializedBytes: number, label: string): void;
|
|
180
|
+
export interface ScopedConfigurationSnapshotV2 {
|
|
181
|
+
schemaVersion: 2;
|
|
182
|
+
kind: "scoped-configuration-snapshot";
|
|
183
|
+
scope: ScopedConfigurationScopeV2;
|
|
184
|
+
mode: "local" | "managed";
|
|
185
|
+
desktopRevision: DesktopConfigurationRevisionV2;
|
|
186
|
+
catalog: CatalogRelease;
|
|
187
|
+
profiles: Record<string, ExecutionProfileRevision>;
|
|
188
|
+
connections: Record<string, Connection>;
|
|
189
|
+
workspaces: Record<string, {
|
|
190
|
+
personaSources: Record<string, PersonaSourceDocumentV2>;
|
|
191
|
+
operationContract: OperationContractDocumentV2;
|
|
192
|
+
}>;
|
|
193
|
+
adapterRequirements: Record<string, {
|
|
194
|
+
minVersion: string;
|
|
195
|
+
}>;
|
|
196
|
+
provenance: {
|
|
197
|
+
loadedAt: string;
|
|
198
|
+
sourceDescription: string;
|
|
199
|
+
lastOnlineValidationAt?: string;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Validates structural and cross-reference consistency of a v2 snapshot against the
|
|
204
|
+
* requested scope: schema conformance, hash agreement, exact reference resolution,
|
|
205
|
+
* ownership and workspace coverage. Readers never observe a partial snapshot.
|
|
206
|
+
*/
|
|
207
|
+
export declare function validateScopedConfigurationSnapshotV2(data: unknown, scope: ScopedConfigurationScopeV2): ScopedConfigurationSnapshotV2;
|
|
208
|
+
//# sourceMappingURL=scoped-configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped-configuration.d.ts","sourceRoot":"","sources":["../src/scoped-configuration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIpG;;;;;;;GAOG;AAMH,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG,MAAM,GAAG,YAAY,CAAC;AAExE,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,mBAAmB,CAAC;IACnC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;CACrB;AAID,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAElF;AAED,qBAAa,kCAAmC,SAAQ,KAAK;gBAC/C,OAAO,EAAE,MAAM;CAI5B;AAED,2FAA2F;AAC3F,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,0BAA0B,CAmB9F;AAMD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAKD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAIjE;AAED,wBAAgB,qBAAqB,CAAC,K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AAC;IACtC,KAAK,EAAE,0BAA0B,CAAC;IAClC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,eAAe,EAAE,8BAA8B,CAAC;IAChD,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IACnD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;QACzB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;QACxD,iBAAiB,EAAE,2BAA2B,CAAC;KAChD,CAAC,CAAC;IACH,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5D,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,sBAAsB,CAAC,EAAE,MAAM,CAAC;KACjC,CAAC;CACH;AAED;;;;GAIG;AACH,wBAAgB,qCAAqC,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,0BAA0B,GAAG,6BAA6B,CAkHrI"}
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { hashInstructions } from "./hash.js";
|
|
3
|
+
import { assertValidEntity, validateEntity } from "./validation.js";
|
|
4
|
+
const uuidPattern = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
|
|
5
|
+
export function isScopedEnvironmentId(value) {
|
|
6
|
+
return value === "development" || value === "test" || value === "production";
|
|
7
|
+
}
|
|
8
|
+
export class ScopedConfigurationValidationError extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "ScopedConfigurationValidationError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Validates and normalizes a full v2 scope. Omitted or mixed scope parts are rejected. */
|
|
15
|
+
export function assertValidScopeV2(scope) {
|
|
16
|
+
if (!scope || typeof scope !== "object") {
|
|
17
|
+
throw new ScopedConfigurationValidationError("v2 scope must be an object with applicationId, environmentId, desktopConfigurationId and workspaceId.");
|
|
18
|
+
}
|
|
19
|
+
const candidate = scope;
|
|
20
|
+
if (typeof candidate.applicationId !== "string" || !/^[a-z0-9][a-z0-9._-]*$/.test(candidate.applicationId)) {
|
|
21
|
+
throw new ScopedConfigurationValidationError("v2 scope applicationId is missing or malformed.");
|
|
22
|
+
}
|
|
23
|
+
if (!isScopedEnvironmentId(candidate.environmentId)) {
|
|
24
|
+
throw new ScopedConfigurationValidationError(`v2 scope environmentId must be exactly development, test or production; received ${JSON.stringify(candidate.environmentId)}.`);
|
|
25
|
+
}
|
|
26
|
+
if (typeof candidate.desktopConfigurationId !== "string" || !new RegExp(uuidPattern, "i").test(candidate.desktopConfigurationId)) {
|
|
27
|
+
throw new ScopedConfigurationValidationError("v2 scope desktopConfigurationId must be a UUID.");
|
|
28
|
+
}
|
|
29
|
+
if (typeof candidate.workspaceId !== "string" || !new RegExp(uuidPattern, "i").test(candidate.workspaceId)) {
|
|
30
|
+
throw new ScopedConfigurationValidationError("v2 scope workspaceId must be a UUID.");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Revisions that resolve dynamically are forbidden in v2; references must be exact. */
|
|
34
|
+
const reservedRevisions = new Set(["latest", "current", "head", "default", "stable", "next", "channel"]);
|
|
35
|
+
export function isExactRevisionV2(value) {
|
|
36
|
+
return typeof value === "string" && value.length > 0 && value.length <= 128 &&
|
|
37
|
+
(/^[A-Za-z0-9][A-Za-z0-9._+=-]*$/.test(value) || /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value)) &&
|
|
38
|
+
!reservedRevisions.has(value.toLowerCase());
|
|
39
|
+
}
|
|
40
|
+
export function assertExactRevisionV2(value, label) {
|
|
41
|
+
if (!isExactRevisionV2(value)) {
|
|
42
|
+
throw new ScopedConfigurationValidationError(`${label} must be an exact revision string; latest/channel/default references are not valid in v2.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function assertExactProfileRefV2(value, label) {
|
|
46
|
+
if (!value || typeof value !== "object") {
|
|
47
|
+
throw new ScopedConfigurationValidationError(`${label} must be an exact profile reference object.`);
|
|
48
|
+
}
|
|
49
|
+
const candidate = value;
|
|
50
|
+
if ("channel" in candidate) {
|
|
51
|
+
throw new ScopedConfigurationValidationError(`${label} uses a channel reference; v2 requires exact revisions.`);
|
|
52
|
+
}
|
|
53
|
+
if (typeof candidate.profileId !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(candidate.profileId)) {
|
|
54
|
+
throw new ScopedConfigurationValidationError(`${label} profileId is missing or malformed.`);
|
|
55
|
+
}
|
|
56
|
+
assertExactRevisionV2(candidate.revision, `${label} revision`);
|
|
57
|
+
}
|
|
58
|
+
export function assertExactDocumentRefV2(value, label) {
|
|
59
|
+
if (!value || typeof value !== "object") {
|
|
60
|
+
throw new ScopedConfigurationValidationError(`${label} must be an exact document reference object.`);
|
|
61
|
+
}
|
|
62
|
+
const candidate = value;
|
|
63
|
+
if (typeof candidate.id !== "string" || !candidate.id || candidate.id.length > 256) {
|
|
64
|
+
throw new ScopedConfigurationValidationError(`${label} id is missing or too long.`);
|
|
65
|
+
}
|
|
66
|
+
assertExactRevisionV2(candidate.revision, `${label} revision`);
|
|
67
|
+
if (typeof candidate.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(candidate.sha256)) {
|
|
68
|
+
throw new ScopedConfigurationValidationError(`${label} sha256 must be a lowercase hex digest.`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export function assertDesktopConfigurationRevisionV2(value) {
|
|
72
|
+
const validation = validateEntity("desktop-configuration-revision-v2", value);
|
|
73
|
+
if (!validation.valid) {
|
|
74
|
+
throw new ScopedConfigurationValidationError(`Invalid desktop configuration revision: ${validation.errors.join("; ")}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function assertPersonaSourceDocumentV2(value) {
|
|
78
|
+
const validation = validateEntity("persona-source-document-v2", value);
|
|
79
|
+
if (!validation.valid) {
|
|
80
|
+
throw new ScopedConfigurationValidationError(`Invalid persona source document: ${validation.errors.join("; ")}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export function assertOperationContractDocumentV2(value) {
|
|
84
|
+
const validation = validateEntity("operation-contract-document-v2", value);
|
|
85
|
+
if (!validation.valid) {
|
|
86
|
+
throw new ScopedConfigurationValidationError(`Invalid operation contract document: ${validation.errors.join("; ")}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Canonical document hashing
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
/** Deterministic JSON serialization: recursively key-sorted, no insignificant whitespace. */
|
|
93
|
+
export function canonicalJsonV2(value) {
|
|
94
|
+
if (value === null || typeof value !== "object")
|
|
95
|
+
return JSON.stringify(value);
|
|
96
|
+
if (Array.isArray(value))
|
|
97
|
+
return `[${value.map((item) => canonicalJsonV2(item)).join(",")}]`;
|
|
98
|
+
const entries = Object.entries(value)
|
|
99
|
+
.filter(([, item]) => item !== undefined)
|
|
100
|
+
.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));
|
|
101
|
+
return `{${entries.map(([key, item]) => `${JSON.stringify(key)}:${canonicalJsonV2(item)}`).join(",")}}`;
|
|
102
|
+
}
|
|
103
|
+
export function sha256HexV2(content) {
|
|
104
|
+
return createHash("sha256").update(content).digest("hex");
|
|
105
|
+
}
|
|
106
|
+
export function hashDocumentV2(value) {
|
|
107
|
+
return sha256HexV2(canonicalJsonV2(value));
|
|
108
|
+
}
|
|
109
|
+
/** Content-addressed revision for workspace documents: stable, immutable, non-reserved. */
|
|
110
|
+
export function contentRevisionV2(value) {
|
|
111
|
+
return `sha256-${hashDocumentV2(value).slice(0, 40)}`;
|
|
112
|
+
}
|
|
113
|
+
export function assertAdoptionChangeSetV2(value) {
|
|
114
|
+
const validation = validateEntity("adoption-change-set-v2", value);
|
|
115
|
+
if (!validation.valid) {
|
|
116
|
+
throw new ScopedConfigurationValidationError(`Invalid adoption change set: ${validation.errors.join("; ")}`);
|
|
117
|
+
}
|
|
118
|
+
const changeSet = value;
|
|
119
|
+
if (changeSet.restoreFromRevision)
|
|
120
|
+
assertExactRevisionV2(changeSet.restoreFromRevision, "restoreFromRevision");
|
|
121
|
+
for (const [added, removed, label] of [
|
|
122
|
+
[changeSet.bindings ?? {}, changeSet.removeBindings ?? [], "binding"],
|
|
123
|
+
[changeSet.connections ?? {}, changeSet.removeConnections ?? [], "connection"],
|
|
124
|
+
[changeSet.workspaces ?? {}, changeSet.removeWorkspaces ?? [], "workspace"]
|
|
125
|
+
]) {
|
|
126
|
+
if (removed.some(key => key in added))
|
|
127
|
+
throw new ScopedConfigurationValidationError(`Cannot add and remove the same ${label} in one adoption.`);
|
|
128
|
+
}
|
|
129
|
+
for (const [binding, ref] of Object.entries(changeSet.bindings ?? {})) {
|
|
130
|
+
assertExactProfileRefV2(ref, `binding ${binding}`);
|
|
131
|
+
}
|
|
132
|
+
for (const [key, ref] of Object.entries(changeSet.connections ?? {})) {
|
|
133
|
+
assertExactDocumentRefV2(ref, `connection ${key}`);
|
|
134
|
+
}
|
|
135
|
+
for (const [workspace, change] of Object.entries(changeSet.workspaces ?? {})) {
|
|
136
|
+
if ((change.removePersonaSources ?? []).some(binding => binding in (change.personaSources ?? {}))) {
|
|
137
|
+
throw new ScopedConfigurationValidationError(`Workspace ${workspace} cannot add and remove the same persona source.`);
|
|
138
|
+
}
|
|
139
|
+
for (const [binding, ref] of Object.entries(change.personaSources ?? {})) {
|
|
140
|
+
assertExactDocumentRefV2(ref, `workspace ${workspace} persona source ${binding}`);
|
|
141
|
+
}
|
|
142
|
+
if (change.operationContract)
|
|
143
|
+
assertExactDocumentRefV2(change.operationContract, `workspace ${workspace} operation contract`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export function assertOperationIdV2(value) {
|
|
147
|
+
if (typeof value !== "string" || !new RegExp(uuidPattern).test(value)) {
|
|
148
|
+
throw new ScopedConfigurationValidationError("operationId must be a UUID.");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
export function newOperationIdV2() {
|
|
152
|
+
return randomUUID();
|
|
153
|
+
}
|
|
154
|
+
/** Canonical adoption request hash used for idempotency and preview/commit agreement. */
|
|
155
|
+
export function hashAdoptionRequestV2(request) {
|
|
156
|
+
assertValidScopeV2(request.scope);
|
|
157
|
+
assertAdoptionChangeSetV2(request.changes);
|
|
158
|
+
assertOperationIdV2(request.operationId);
|
|
159
|
+
if (request.expectedDesktopRevision !== null) {
|
|
160
|
+
assertExactRevisionV2(request.expectedDesktopRevision, "expectedDesktopRevision");
|
|
161
|
+
}
|
|
162
|
+
return sha256HexV2(canonicalJsonV2({
|
|
163
|
+
scope: request.scope,
|
|
164
|
+
expectedDesktopRevision: request.expectedDesktopRevision,
|
|
165
|
+
expectedAvailabilityRevision: request.expectedAvailabilityRevision ?? null,
|
|
166
|
+
operationId: request.operationId,
|
|
167
|
+
changes: request.changes
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
/** Derives the complete next desktop revision from a base and an exact patch. Omitted fields are preserved exactly. */
|
|
171
|
+
export function deriveDesktopRevisionV2(input) {
|
|
172
|
+
assertValidScopeV2(input.scope);
|
|
173
|
+
assertAdoptionChangeSetV2(input.changes);
|
|
174
|
+
assertOperationIdV2(input.operationId);
|
|
175
|
+
if (input.base) {
|
|
176
|
+
assertDesktopConfigurationRevisionV2(input.base);
|
|
177
|
+
if (input.base.applicationId !== input.scope.applicationId ||
|
|
178
|
+
input.base.environmentId !== input.scope.environmentId ||
|
|
179
|
+
input.base.desktopConfigurationId !== input.scope.desktopConfigurationId) {
|
|
180
|
+
throw new ScopedConfigurationValidationError("Base desktop revision belongs to a different desktop scope.");
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const now = (input.now ?? (() => new Date))().toISOString();
|
|
184
|
+
const bindings = { ...(input.base?.bindings ?? {}) };
|
|
185
|
+
for (const binding of input.changes.removeBindings ?? [])
|
|
186
|
+
delete bindings[binding];
|
|
187
|
+
for (const [binding, ref] of Object.entries(input.changes.bindings ?? {})) {
|
|
188
|
+
assertExactProfileRefV2(ref, `binding ${binding}`);
|
|
189
|
+
bindings[binding] = { ...ref };
|
|
190
|
+
}
|
|
191
|
+
const connections = { ...(input.base?.connections ?? {}) };
|
|
192
|
+
for (const key of input.changes.removeConnections ?? [])
|
|
193
|
+
delete connections[key];
|
|
194
|
+
for (const [key, ref] of Object.entries(input.changes.connections ?? {})) {
|
|
195
|
+
assertExactDocumentRefV2(ref, `connection ${key}`);
|
|
196
|
+
connections[key] = { ...ref };
|
|
197
|
+
}
|
|
198
|
+
const workspaces = { ...(input.base?.workspaces ?? {}) };
|
|
199
|
+
for (const workspace of input.changes.removeWorkspaces ?? [])
|
|
200
|
+
delete workspaces[workspace];
|
|
201
|
+
for (const [workspace, change] of Object.entries(input.changes.workspaces ?? {})) {
|
|
202
|
+
const existing = workspaces[workspace] ?? { personaSources: {}, operationContract: undefined };
|
|
203
|
+
const personaSources = { ...existing.personaSources };
|
|
204
|
+
for (const binding of change.removePersonaSources ?? [])
|
|
205
|
+
delete personaSources[binding];
|
|
206
|
+
for (const [binding, ref] of Object.entries(change.personaSources ?? {})) {
|
|
207
|
+
assertExactDocumentRefV2(ref, `workspace ${workspace} persona source ${binding}`);
|
|
208
|
+
personaSources[binding] = { ...ref };
|
|
209
|
+
}
|
|
210
|
+
if (!change.operationContract && !existing.operationContract) {
|
|
211
|
+
throw new ScopedConfigurationValidationError(`Workspace ${workspace} still has no operation contract after the change.`);
|
|
212
|
+
}
|
|
213
|
+
workspaces[workspace] = {
|
|
214
|
+
personaSources,
|
|
215
|
+
operationContract: change.operationContract ? { ...change.operationContract } : existing.operationContract
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
if (!input.changes.catalog && !input.base?.catalog) {
|
|
219
|
+
throw new ScopedConfigurationValidationError("No catalog reference after the change; initial provisioning must supply all required refs.");
|
|
220
|
+
}
|
|
221
|
+
if (!input.base) {
|
|
222
|
+
const initialWorkspace = input.changes.workspaces?.[input.scope.workspaceId];
|
|
223
|
+
if (!initialWorkspace) {
|
|
224
|
+
throw new ScopedConfigurationValidationError(`Initial provisioning must supply workspace ${input.scope.workspaceId} persona sources and operation contract.`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const draft = {
|
|
228
|
+
schemaVersion: 2,
|
|
229
|
+
applicationId: input.scope.applicationId,
|
|
230
|
+
environmentId: input.scope.environmentId,
|
|
231
|
+
desktopConfigurationId: input.scope.desktopConfigurationId,
|
|
232
|
+
revision: "",
|
|
233
|
+
parentRevision: input.base?.revision ?? null,
|
|
234
|
+
...(input.changes.restoreFromRevision ? { restoredFromRevision: input.changes.restoreFromRevision } : {}),
|
|
235
|
+
bindings,
|
|
236
|
+
catalog: input.changes.catalog ? { ...input.changes.catalog } : input.base.catalog,
|
|
237
|
+
connections,
|
|
238
|
+
workspaces,
|
|
239
|
+
operationId: input.operationId,
|
|
240
|
+
changedBy: input.changedBy,
|
|
241
|
+
createdAt: now
|
|
242
|
+
};
|
|
243
|
+
// Revision identity derives from the full content so equal states cannot masquerade as different revisions.
|
|
244
|
+
draft.revision = `sha256-${hashDocumentV2({ ...draft, revision: "" }).slice(0, 40)}`;
|
|
245
|
+
assertDesktopConfigurationRevisionV2(draft);
|
|
246
|
+
return draft;
|
|
247
|
+
}
|
|
248
|
+
// ---------------------------------------------------------------------------
|
|
249
|
+
// Storage paths (managed layout; the local repository mirrors the same segment rules)
|
|
250
|
+
// ---------------------------------------------------------------------------
|
|
251
|
+
export function assertSafePathSegmentV2(value, label) {
|
|
252
|
+
if (typeof value !== "string" || value.length === 0 || value.length > 256) {
|
|
253
|
+
throw new ScopedConfigurationValidationError(`${label} must be a safe path segment (non-empty, no separators).`);
|
|
254
|
+
}
|
|
255
|
+
if (value === "." || value === ".." || value.includes("/") || value.includes("\\") || /[\u0000-\u001f]/.test(value)) {
|
|
256
|
+
throw new ScopedConfigurationValidationError(`${label} is not a safe path segment: ${JSON.stringify(value)}.`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
export const V2_APPLICATION_HEAD_KEY = (applicationId) => {
|
|
260
|
+
assertSafePathSegmentV2(applicationId, "applicationId");
|
|
261
|
+
return `v2/applications/${applicationId}/head.json`;
|
|
262
|
+
};
|
|
263
|
+
export const V2_DESKTOP_REVISION_KEY = (applicationId, environmentId, desktopConfigurationId, revision) => {
|
|
264
|
+
assertSafePathSegmentV2(applicationId, "applicationId");
|
|
265
|
+
if (!isScopedEnvironmentId(environmentId))
|
|
266
|
+
throw new ScopedConfigurationValidationError("environmentId must be a v2 environment.");
|
|
267
|
+
assertSafePathSegmentV2(desktopConfigurationId, "desktopConfigurationId");
|
|
268
|
+
assertExactRevisionV2(revision, "revision");
|
|
269
|
+
return `v2/applications/${applicationId}/environments/${environmentId}/desktops/${desktopConfigurationId}/revisions/${revision}.json`;
|
|
270
|
+
};
|
|
271
|
+
export const V2_WORKSPACE_PERSONA_SOURCE_KEY = (applicationId, environmentId, workspaceId, bindingId, revision) => {
|
|
272
|
+
assertSafePathSegmentV2(applicationId, "applicationId");
|
|
273
|
+
if (!isScopedEnvironmentId(environmentId))
|
|
274
|
+
throw new ScopedConfigurationValidationError("environmentId must be a v2 environment.");
|
|
275
|
+
assertSafePathSegmentV2(workspaceId, "workspaceId");
|
|
276
|
+
assertSafePathSegmentV2(bindingId, "bindingId");
|
|
277
|
+
assertExactRevisionV2(revision, "revision");
|
|
278
|
+
return `v2/applications/${applicationId}/environments/${environmentId}/workspaces/${workspaceId}/personas/${bindingId}/${revision}.json`;
|
|
279
|
+
};
|
|
280
|
+
export const V2_OPERATION_CONTRACT_KEY = (applicationId, environmentId, workspaceId, revision) => {
|
|
281
|
+
assertSafePathSegmentV2(applicationId, "applicationId");
|
|
282
|
+
if (!isScopedEnvironmentId(environmentId))
|
|
283
|
+
throw new ScopedConfigurationValidationError("environmentId must be a v2 environment.");
|
|
284
|
+
assertSafePathSegmentV2(workspaceId, "workspaceId");
|
|
285
|
+
assertExactRevisionV2(revision, "revision");
|
|
286
|
+
return `v2/applications/${applicationId}/environments/${environmentId}/workspaces/${workspaceId}/operation-contracts/${revision}.json`;
|
|
287
|
+
};
|
|
288
|
+
export const scopedConfigurationHttpStatusV2 = {
|
|
289
|
+
"invalid-request": 400,
|
|
290
|
+
"authentication-failed": 401,
|
|
291
|
+
"scope-denied": 403,
|
|
292
|
+
"not-found": 404,
|
|
293
|
+
conflict: 409,
|
|
294
|
+
revoked: 410,
|
|
295
|
+
incompatible: 422,
|
|
296
|
+
unavailable: 503
|
|
297
|
+
};
|
|
298
|
+
/** v2 request/response bodies are capped at 2 MiB; oversized submissions are rejected before any publication. */
|
|
299
|
+
export const MAX_V2_BODY_BYTES = 2 * 1024 * 1024;
|
|
300
|
+
export function assertV2BodySizeV2(serializedBytes, label) {
|
|
301
|
+
if (!Number.isFinite(serializedBytes) || serializedBytes < 0) {
|
|
302
|
+
throw new ScopedConfigurationValidationError(`${label} size must be a non-negative byte count.`);
|
|
303
|
+
}
|
|
304
|
+
if (serializedBytes > MAX_V2_BODY_BYTES) {
|
|
305
|
+
throw new ScopedConfigurationValidationError(`${label} exceeds the v2 ${MAX_V2_BODY_BYTES}-byte body limit; paginate the option list or split the submission.`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Validates structural and cross-reference consistency of a v2 snapshot against the
|
|
310
|
+
* requested scope: schema conformance, hash agreement, exact reference resolution,
|
|
311
|
+
* ownership and workspace coverage. Readers never observe a partial snapshot.
|
|
312
|
+
*/
|
|
313
|
+
export function validateScopedConfigurationSnapshotV2(data, scope) {
|
|
314
|
+
assertValidScopeV2(scope);
|
|
315
|
+
const invalid = (reason) => new ScopedConfigurationValidationError(`Scoped configuration snapshot for ${scope.applicationId}/${scope.environmentId}/desktop/${scope.desktopConfigurationId.slice(0, 8)}/workspace/${scope.workspaceId.slice(0, 8)} is invalid: ${reason}`);
|
|
316
|
+
if (!data || typeof data !== "object")
|
|
317
|
+
throw invalid("snapshot is not an object");
|
|
318
|
+
const raw = data;
|
|
319
|
+
if (raw.schemaVersion !== 2 || raw.kind !== "scoped-configuration-snapshot") {
|
|
320
|
+
throw invalid("snapshot is not a v2 scoped-configuration snapshot");
|
|
321
|
+
}
|
|
322
|
+
if (raw.mode !== "local" && raw.mode !== "managed")
|
|
323
|
+
throw invalid("snapshot mode must be local or managed");
|
|
324
|
+
const desktopRevision = raw.desktopRevision;
|
|
325
|
+
assertDesktopConfigurationRevisionV2(desktopRevision);
|
|
326
|
+
if (desktopRevision.applicationId !== scope.applicationId ||
|
|
327
|
+
desktopRevision.environmentId !== scope.environmentId ||
|
|
328
|
+
desktopRevision.desktopConfigurationId !== scope.desktopConfigurationId) {
|
|
329
|
+
throw invalid("desktop revision scope does not match the requested desktop scope");
|
|
330
|
+
}
|
|
331
|
+
const snapshotScope = raw.scope;
|
|
332
|
+
assertValidScopeV2(snapshotScope);
|
|
333
|
+
if (snapshotScope.applicationId !== scope.applicationId ||
|
|
334
|
+
snapshotScope.environmentId !== scope.environmentId ||
|
|
335
|
+
snapshotScope.desktopConfigurationId !== scope.desktopConfigurationId ||
|
|
336
|
+
snapshotScope.workspaceId !== scope.workspaceId) {
|
|
337
|
+
throw invalid("snapshot scope does not exactly match the requested scope (mixed scopes are rejected)");
|
|
338
|
+
}
|
|
339
|
+
const workspaceId = scope.workspaceId;
|
|
340
|
+
const workspaceEntry = desktopRevision.workspaces[workspaceId];
|
|
341
|
+
if (!workspaceEntry)
|
|
342
|
+
throw invalid(`desktop revision does not adopt workspace ${workspaceId}`);
|
|
343
|
+
const catalog = raw.catalog;
|
|
344
|
+
if (!catalog)
|
|
345
|
+
throw invalid("catalog release is missing");
|
|
346
|
+
assertValidEntity("catalog-release", catalog);
|
|
347
|
+
if (catalog.catalogRevision !== desktopRevision.catalog.revision) {
|
|
348
|
+
throw invalid(`catalog release ${catalog.catalogRevision} does not match the pinned reference ${desktopRevision.catalog.revision}`);
|
|
349
|
+
}
|
|
350
|
+
if (hashDocumentV2(catalog) !== desktopRevision.catalog.sha256) {
|
|
351
|
+
throw invalid("catalog document sha256 does not match the pinned reference");
|
|
352
|
+
}
|
|
353
|
+
const profiles = raw.profiles ?? {};
|
|
354
|
+
for (const [binding, ref] of Object.entries(desktopRevision.bindings)) {
|
|
355
|
+
const profile = profiles[ref.profileId];
|
|
356
|
+
if (!profile)
|
|
357
|
+
throw invalid(`binding ${binding} references missing profile ${ref.profileId}@${ref.revision}`);
|
|
358
|
+
assertValidEntity("execution-profile-revision", profile);
|
|
359
|
+
if (profile.profileId !== ref.profileId || profile.revision !== ref.revision) {
|
|
360
|
+
throw invalid(`binding ${binding} references ${ref.profileId}@${ref.revision} but the snapshot carries ${profile.profileId}@${profile.revision}`);
|
|
361
|
+
}
|
|
362
|
+
const shared = profile.visibility === "shared" || profile.owner.applicationId === "shared";
|
|
363
|
+
if (!shared && profile.owner.applicationId !== scope.applicationId) {
|
|
364
|
+
throw invalid(`profile ${ref.profileId} is private to ${profile.owner.applicationId}`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
const connections = raw.connections ?? {};
|
|
368
|
+
for (const [key, ref] of Object.entries(desktopRevision.connections)) {
|
|
369
|
+
const connection = connections[key];
|
|
370
|
+
if (!connection)
|
|
371
|
+
throw invalid(`connection ${key} reference is missing from the snapshot`);
|
|
372
|
+
assertValidEntity("connection", connection);
|
|
373
|
+
if (connection.provider !== key.split(":")[0] && connection.applicationId !== scope.applicationId) {
|
|
374
|
+
throw invalid(`connection ${key} does not belong to ${scope.applicationId}`);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
const workspaces = raw.workspaces ?? {};
|
|
378
|
+
const workspaceDocuments = workspaces[workspaceId];
|
|
379
|
+
if (!workspaceDocuments)
|
|
380
|
+
throw invalid(`workspace document bundle for ${workspaceId} is missing`);
|
|
381
|
+
for (const [binding, ref] of Object.entries(workspaceEntry.personaSources)) {
|
|
382
|
+
const source = workspaceDocuments.personaSources[binding];
|
|
383
|
+
if (!source)
|
|
384
|
+
throw invalid(`persona source ${binding}@${ref.revision} is missing from the workspace bundle`);
|
|
385
|
+
assertPersonaSourceDocumentV2(source);
|
|
386
|
+
if (source.applicationId !== scope.applicationId || source.workspaceId !== workspaceId || source.bindingId !== binding) {
|
|
387
|
+
throw invalid(`persona source ${binding} document scope does not match the snapshot scope`);
|
|
388
|
+
}
|
|
389
|
+
if (hashInstructions(source.systemInstructions) !== source.instructionHash) {
|
|
390
|
+
throw invalid(`persona source ${binding} instruction hash mismatch`);
|
|
391
|
+
}
|
|
392
|
+
if (source.revision !== ref.revision || hashDocumentV2(source) !== ref.sha256) {
|
|
393
|
+
throw invalid(`persona source ${binding} does not match its pinned reference`);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
const operationContract = workspaceDocuments.operationContract;
|
|
397
|
+
assertOperationContractDocumentV2(operationContract);
|
|
398
|
+
if (operationContract.applicationId !== scope.applicationId || operationContract.workspaceId !== workspaceId) {
|
|
399
|
+
throw invalid("operation contract scope does not match the snapshot scope");
|
|
400
|
+
}
|
|
401
|
+
if (operationContract.revision !== workspaceEntry.operationContract.revision ||
|
|
402
|
+
hashDocumentV2(operationContract) !== workspaceEntry.operationContract.sha256) {
|
|
403
|
+
throw invalid("operation contract does not match its pinned reference");
|
|
404
|
+
}
|
|
405
|
+
if (!raw.adapterRequirements || typeof raw.adapterRequirements !== "object") {
|
|
406
|
+
throw invalid("adapter requirements are missing");
|
|
407
|
+
}
|
|
408
|
+
if (!raw.provenance || typeof raw.provenance.loadedAt !== "string" || typeof raw.provenance.sourceDescription !== "string") {
|
|
409
|
+
throw invalid("provenance is missing or malformed");
|
|
410
|
+
}
|
|
411
|
+
return {
|
|
412
|
+
schemaVersion: 2,
|
|
413
|
+
kind: "scoped-configuration-snapshot",
|
|
414
|
+
scope,
|
|
415
|
+
mode: raw.mode,
|
|
416
|
+
desktopRevision,
|
|
417
|
+
catalog,
|
|
418
|
+
profiles,
|
|
419
|
+
connections,
|
|
420
|
+
workspaces,
|
|
421
|
+
adapterRequirements: raw.adapterRequirements,
|
|
422
|
+
provenance: raw.provenance
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
//# sourceMappingURL=scoped-configuration.js.map
|