@openplanr/protocol 0.6.1 → 0.6.2
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/lib/dashboard/closed-json-contract.mjs +99 -109
- package/lib/dashboard/operate-experience-audit-display-contract.d.mts +128 -153
- package/lib/dashboard/operate-experience-audit-display-contract.mjs +530 -585
- package/lib/dashboard/operate-experience-display-contract.d.mts +415 -437
- package/lib/dashboard/operate-experience-display-contract.mjs +768 -831
- package/lib/dashboard/operate-experience-surface-contract.d.mts +143 -148
- package/lib/dashboard/operate-experience-surface-contract.mjs +72 -73
- package/lib/dashboard/operate-review-contract.d.mts +7 -14
- package/lib/dashboard/operate-review-contract.mjs +46 -42
- package/lib/dashboard/operate-review-display-workspace-contract.d.mts +2 -5
- package/lib/dashboard/operate-review-display-workspace-contract.mjs +158 -104
- package/lib/dashboard/operate-review-payload-safety.mjs +4 -2
- package/lib/dashboard/operate-review-workspace-projection-v2.d.mts +47 -33
- package/lib/protocol/index.d.ts +2647 -543
- package/package.json +1 -1
- package/registries/commands.json +3 -3
- package/registries/skills.json +5 -5
- package/src/browser-contracts.d.mts +4 -1
- package/src/browser-contracts.mjs +16 -5
- package/src/canonical-json.d.mts +3 -1
- package/src/canonical-json.mjs +57 -20
- package/src/compat/live-evidence-v2.mjs +1604 -485
- package/src/compat/operate-experience-live-patch.mjs +67 -15
- package/src/compat/operating-planning-contracts.mjs +183 -51
- package/src/contracts.d.mts +54 -13
- package/src/contracts.mjs +625 -335
- package/src/design-contracts.mjs +58 -21
- package/src/design-handoff-contracts.d.mts +67 -11
- package/src/design-handoff-contracts.mjs +243 -98
- package/src/design-publication-contracts.mjs +98 -33
- package/src/diagram-authoring-contracts.d.mts +422 -78
- package/src/diagram-authoring-contracts.mjs +1697 -326
- package/src/diagram-contracts.d.mts +4 -1
- package/src/diagram-contracts.mjs +16 -4
- package/src/enterprise-contracts.d.mts +211 -46
- package/src/enterprise-contracts.mjs +727 -175
- package/src/errors.mjs +4 -0
- package/src/generated/canonical-registries.mjs +8 -8
- package/src/index.d.mts +8 -8
- package/src/index.mjs +36 -20
- package/src/json-schema.d.mts +21 -6
- package/src/json-schema.mjs +66 -18
- package/src/planning-contracts.d.mts +8 -2
- package/src/planning-contracts.mjs +33 -7
- package/src/registries.d.mts +11 -3
- package/src/registries.mjs +369 -87
- package/src/review-experience-contracts.d.mts +7 -2
- package/src/review-experience-contracts.mjs +198 -49
- package/src/semver.mjs +5 -1
- package/src/skill-source-contracts.d.mts +36 -16
- package/src/skill-source-contracts.mjs +25 -6
- package/src/task-contracts.d.mts +13 -3
- package/src/task-contracts.mjs +181 -40
- package/src/workspace-contracts.d.mts +38 -10
- package/src/workspace-contracts.mjs +147 -33
package/src/contracts.mjs
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
import { readFileSync } from 'node:fs';
|
|
2
3
|
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
|
|
5
|
-
import {
|
|
5
|
+
import { DESIGN_HANDOFF_CONTRACT_FILES } from './design-handoff-contracts.mjs';
|
|
6
|
+
import {
|
|
7
|
+
DIAGRAM_AUTHORING_CONTRACT_FILES,
|
|
8
|
+
validateDiagramAuthoringArtifact,
|
|
9
|
+
} from './diagram-authoring-contracts.mjs';
|
|
6
10
|
import { ENTERPRISE_SCHEMAS } from './enterprise-contracts.mjs';
|
|
7
|
-
import { OPERATE_CONTRACT_CATALOG_V2 } from './generated/contract-catalog-v2.mjs';
|
|
8
11
|
import { PipelineError } from './errors.mjs';
|
|
12
|
+
import { OPERATE_CONTRACT_CATALOG_V2 } from './generated/contract-catalog-v2.mjs';
|
|
13
|
+
import { validateJson } from './json-schema.mjs';
|
|
9
14
|
import {
|
|
10
15
|
PROTOCOL_V16_CONTRACT_FILES,
|
|
11
16
|
PROTOCOL_V17_CONTRACT_FILES,
|
|
12
17
|
PROTOCOL_V18_CONTRACT_FILES,
|
|
13
18
|
} from './skill-source-contracts.mjs';
|
|
14
|
-
import { DESIGN_HANDOFF_CONTRACT_FILES } from './design-handoff-contracts.mjs';
|
|
15
|
-
import { DIAGRAM_AUTHORING_CONTRACT_FILES, validateDiagramAuthoringArtifact } from './diagram-authoring-contracts.mjs';
|
|
16
19
|
|
|
17
20
|
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
18
21
|
|
|
@@ -23,17 +26,33 @@ const v17Schema = (kind) => `schemas/v1.7.0/${PROTOCOL_V17_CONTRACT_FILES[kind]}
|
|
|
23
26
|
const v18Schema = (kind) => `schemas/v1.8.0/${PROTOCOL_V18_CONTRACT_FILES[kind]}`;
|
|
24
27
|
|
|
25
28
|
const foundationPaths = {
|
|
26
|
-
...Object.fromEntries(
|
|
29
|
+
...Object.fromEntries(
|
|
30
|
+
Object.keys(ENTERPRISE_SCHEMAS).map((name) => [
|
|
31
|
+
name,
|
|
32
|
+
{ '1.12.0': `schemas/v1.12.0/${name}.schema.json` },
|
|
33
|
+
]),
|
|
34
|
+
),
|
|
27
35
|
'design-document': { '1.9.0': 'schemas/v1.9.0/design-document.schema.json' },
|
|
28
36
|
'design-review-workspace': { '1.9.0': 'schemas/v1.9.0/design-review-workspace.schema.json' },
|
|
29
37
|
'design-workspace-create': { '1.9.0': 'schemas/v1.9.0/design-workspace-create.schema.json' },
|
|
30
38
|
'design-workspace-revision': { '1.9.0': 'schemas/v1.9.0/design-workspace-revision.schema.json' },
|
|
31
39
|
'design-workspace-event': { '1.9.0': 'schemas/v1.9.0/design-workspace-event.schema.json' },
|
|
32
|
-
'design-review-bundle': {
|
|
40
|
+
'design-review-bundle': {
|
|
41
|
+
'1.9.0': 'schemas/v1.9.0/design-review-bundle.schema.json',
|
|
42
|
+
'1.10.0': 'schemas/v1.10.0/design-review-bundle.schema.json',
|
|
43
|
+
},
|
|
33
44
|
'design-review-context': { '1.10.0': 'schemas/v1.10.0/design-review-context.schema.json' },
|
|
34
45
|
'design-review-handoff': { '1.10.0': 'schemas/v1.10.0/design-review-handoff.schema.json' },
|
|
35
|
-
'design-review-metadata-payload': {
|
|
36
|
-
|
|
46
|
+
'design-review-metadata-payload': {
|
|
47
|
+
'1.10.0': 'schemas/v1.10.0/design-review-metadata-payload.schema.json',
|
|
48
|
+
'1.11.0': 'schemas/v1.11.0/design-review-metadata-payload.schema.json',
|
|
49
|
+
},
|
|
50
|
+
...Object.fromEntries(
|
|
51
|
+
Object.keys(DESIGN_HANDOFF_CONTRACT_FILES).map((name) => [
|
|
52
|
+
name,
|
|
53
|
+
{ '1.11.0': `schemas/v1.11.0/${DESIGN_HANDOFF_CONTRACT_FILES[name]}` },
|
|
54
|
+
]),
|
|
55
|
+
),
|
|
37
56
|
|
|
38
57
|
spec: { '1.0.0': 'schemas/v1.0.0/spec.schema.json', '1.7.0': v17Schema('spec') },
|
|
39
58
|
story: { '1.0.0': 'schemas/v1.0.0/story.schema.json', '1.7.0': v17Schema('story') },
|
|
@@ -43,12 +62,16 @@ const foundationPaths = {
|
|
|
43
62
|
'runtime-lock': { '1.1.0': 'schemas/v1.1.0/runtime-lock.schema.json' },
|
|
44
63
|
'provenance-event': { '1.1.0': 'schemas/v1.1.0/provenance-event.schema.json' },
|
|
45
64
|
'ship-closure': { '1.1.0': 'schemas/v1.1.0/ship-closure.schema.json' },
|
|
46
|
-
'professional-specification': {
|
|
65
|
+
'professional-specification': {
|
|
66
|
+
'1.1.0': 'schemas/v1.1.0/professional-specification.schema.json',
|
|
67
|
+
},
|
|
47
68
|
'planning-review-record': { '1.1.0': 'schemas/v1.1.0/planning-review-record.schema.json' },
|
|
48
69
|
'planning-review-state': { '1.1.0': 'schemas/v1.1.0/planning-review-state.schema.json' },
|
|
49
70
|
'planning-review-event': { '1.1.0': 'schemas/v1.1.0/planning-review-event.schema.json' },
|
|
50
71
|
'planning-review-receipt': { '1.1.0': 'schemas/v1.1.0/planning-review-receipt.schema.json' },
|
|
51
|
-
'ship-review-specialist-registry': {
|
|
72
|
+
'ship-review-specialist-registry': {
|
|
73
|
+
'1.1.0': 'schemas/v1.1.0/ship-review-specialist-registry.schema.json',
|
|
74
|
+
},
|
|
52
75
|
'specialist-review-result': { '1.1.0': 'schemas/v1.1.0/specialist-review-result.schema.json' },
|
|
53
76
|
'ship-risk-classification': { '1.1.0': 'schemas/v1.1.0/ship-risk-classification.schema.json' },
|
|
54
77
|
'browser-qa-session': { '1.1.0': 'schemas/v1.1.0/browser-qa-session.schema.json' },
|
|
@@ -73,16 +96,22 @@ const foundationPaths = {
|
|
|
73
96
|
'1.3.0': 'schemas/v1.3.0/ecosystem-manifest.schema.json',
|
|
74
97
|
},
|
|
75
98
|
'release-ledger': { '1.3.0': 'schemas/v1.3.0/release-ledger.schema.json' },
|
|
76
|
-
'release-compatibility-claim': {
|
|
99
|
+
'release-compatibility-claim': {
|
|
100
|
+
'1.3.0': 'schemas/v1.3.0/release-compatibility-claim.schema.json',
|
|
101
|
+
},
|
|
77
102
|
'release-ledger-receipt': { '1.3.0': 'schemas/v1.3.0/release-ledger-receipt.schema.json' },
|
|
78
103
|
'artifact-envelope': { '1.1.0': 'schemas/v1.1.0/artifact-envelope.schema.json' },
|
|
79
104
|
'artifact-review': { '1.1.0': 'schemas/v1.1.0/artifact-review.schema.json' },
|
|
80
105
|
'artifact-paste': { '1.1.0': 'schemas/v1.1.0/artifact-paste.schema.json' },
|
|
81
106
|
'artifact-room-event': { '1.1.0': 'schemas/v1.1.0/artifact-room-event.schema.json' },
|
|
82
107
|
'artifact-room-descriptor': { '1.1.0': 'schemas/v1.1.0/artifact-room-descriptor.schema.json' },
|
|
83
|
-
'artifact-room-signed-event': {
|
|
108
|
+
'artifact-room-signed-event': {
|
|
109
|
+
'1.1.0': 'schemas/v1.1.0/artifact-room-signed-event.schema.json',
|
|
110
|
+
},
|
|
84
111
|
'ecosystem-saga': { '1.2.0': 'schemas/v1.2.0/ecosystem-saga.schema.json' },
|
|
85
|
-
'ecosystem-release-operation': {
|
|
112
|
+
'ecosystem-release-operation': {
|
|
113
|
+
'1.2.0': 'schemas/v1.2.0/ecosystem-release-operation.schema.json',
|
|
114
|
+
},
|
|
86
115
|
'guided-question': { '1.2.0': 'schemas/v1.2.0/guided-question.schema.json' },
|
|
87
116
|
'guided-questionnaire': { '1.2.0': 'schemas/v1.2.0/guided-questionnaire.schema.json' },
|
|
88
117
|
'guided-answer-envelope': { '1.2.0': 'schemas/v1.2.0/guided-answer-envelope.schema.json' },
|
|
@@ -96,22 +125,34 @@ const foundationPaths = {
|
|
|
96
125
|
'landing-event': { '1.2.0': 'schemas/v1.2.0/landing-event.schema.json' },
|
|
97
126
|
'landing-phase-receipt': { '1.2.0': 'schemas/v1.2.0/landing-phase-receipt.schema.json' },
|
|
98
127
|
'landing-receipt': { '1.2.0': 'schemas/v1.2.0/landing-receipt.schema.json' },
|
|
99
|
-
'landing-operation-registry': {
|
|
128
|
+
'landing-operation-registry': {
|
|
129
|
+
'1.2.0': 'schemas/v1.2.0/landing-operation-registry.schema.json',
|
|
130
|
+
},
|
|
100
131
|
'landing-workflow-catalog': { '1.2.0': 'schemas/v1.2.0/landing-workflow-catalog.schema.json' },
|
|
101
132
|
'evaluation-scenario': { '1.4.0': 'schemas/v1.4.0/evaluation-scenario.schema.json' },
|
|
102
133
|
'evaluation-corpus': { '1.4.0': 'schemas/v1.4.0/evaluation-corpus.schema.json' },
|
|
103
134
|
'evaluation-fixture': { '1.4.0': 'schemas/v1.4.0/evaluation-fixture.schema.json' },
|
|
104
135
|
'evaluation-host-profile': { '1.4.0': 'schemas/v1.4.0/evaluation-host-profile.schema.json' },
|
|
105
|
-
'evaluation-host-profile-registry': {
|
|
106
|
-
|
|
107
|
-
|
|
136
|
+
'evaluation-host-profile-registry': {
|
|
137
|
+
'1.4.0': 'schemas/v1.4.0/evaluation-host-profile-registry.schema.json',
|
|
138
|
+
},
|
|
139
|
+
'evaluation-grader-registration': {
|
|
140
|
+
'1.4.0': 'schemas/v1.4.0/evaluation-grader-registration.schema.json',
|
|
141
|
+
},
|
|
142
|
+
'evaluation-grader-registry': {
|
|
143
|
+
'1.4.0': 'schemas/v1.4.0/evaluation-grader-registry.schema.json',
|
|
144
|
+
},
|
|
108
145
|
'evaluation-budget': { '1.4.0': 'schemas/v1.4.0/evaluation-budget.schema.json' },
|
|
109
146
|
'evaluation-gate-policy': { '1.4.0': 'schemas/v1.4.0/evaluation-gate-policy.schema.json' },
|
|
110
147
|
'evaluation-observation': { '1.4.0': 'schemas/v1.4.0/evaluation-observation.schema.json' },
|
|
111
148
|
'evaluation-run-result': { '1.4.0': 'schemas/v1.4.0/evaluation-run-result.schema.json' },
|
|
112
|
-
'evaluation-aggregate-report': {
|
|
149
|
+
'evaluation-aggregate-report': {
|
|
150
|
+
'1.4.0': 'schemas/v1.4.0/evaluation-aggregate-report.schema.json',
|
|
151
|
+
},
|
|
113
152
|
'evaluation-waiver': { '1.4.0': 'schemas/v1.4.0/evaluation-waiver.schema.json' },
|
|
114
|
-
'skill-certification-receipt': {
|
|
153
|
+
'skill-certification-receipt': {
|
|
154
|
+
'1.4.0': 'schemas/v1.4.0/skill-certification-receipt.schema.json',
|
|
155
|
+
},
|
|
115
156
|
'role-registry': {
|
|
116
157
|
'1.1.0': 'schemas/v1.1.0/role-registry.schema.json',
|
|
117
158
|
'1.5.0': 'schemas/v1.5.0/role-registry.schema.json',
|
|
@@ -134,14 +175,34 @@ const foundationPaths = {
|
|
|
134
175
|
'1.6.0': v16Schema('generated-asset-manifest'),
|
|
135
176
|
'1.7.0': v17Schema('generated-asset-manifest'),
|
|
136
177
|
},
|
|
137
|
-
'migration-preservation-manifest': {
|
|
178
|
+
'migration-preservation-manifest': {
|
|
179
|
+
'1.5.0': 'schemas/v1.5.0/migration-preservation-manifest.schema.json',
|
|
180
|
+
},
|
|
138
181
|
'skill-source': { '1.6.0': v16Schema('skill-source'), '1.7.0': v17Schema('skill-source') },
|
|
139
|
-
'skill-module-registry': {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
'skill-
|
|
144
|
-
|
|
182
|
+
'skill-module-registry': {
|
|
183
|
+
'1.6.0': v16Schema('skill-module-registry'),
|
|
184
|
+
'1.7.0': v17Schema('skill-module-registry'),
|
|
185
|
+
},
|
|
186
|
+
'skill-host-profile-registry': {
|
|
187
|
+
'1.6.0': v16Schema('skill-host-profile-registry'),
|
|
188
|
+
'1.7.0': v17Schema('skill-host-profile-registry'),
|
|
189
|
+
},
|
|
190
|
+
'skill-routing-registry': {
|
|
191
|
+
'1.6.0': v16Schema('skill-routing-registry'),
|
|
192
|
+
'1.7.0': v17Schema('skill-routing-registry'),
|
|
193
|
+
},
|
|
194
|
+
'skill-completion-receipt': {
|
|
195
|
+
'1.6.0': v16Schema('skill-completion-receipt'),
|
|
196
|
+
'1.7.0': v17Schema('skill-completion-receipt'),
|
|
197
|
+
},
|
|
198
|
+
'skill-consent-record': {
|
|
199
|
+
'1.6.0': v16Schema('skill-consent-record'),
|
|
200
|
+
'1.7.0': v17Schema('skill-consent-record'),
|
|
201
|
+
},
|
|
202
|
+
'skill-learning-record': {
|
|
203
|
+
'1.6.0': v16Schema('skill-learning-record'),
|
|
204
|
+
'1.7.0': v17Schema('skill-learning-record'),
|
|
205
|
+
},
|
|
145
206
|
'skill-session': { '1.6.0': v16Schema('skill-session'), '1.7.0': v17Schema('skill-session') },
|
|
146
207
|
'planning-id-sequence': { '1.7.0': v17Schema('planning-id-sequence') },
|
|
147
208
|
'request-authority': { '1.7.0': v17Schema('request-authority') },
|
|
@@ -165,11 +226,11 @@ for (const [kind, filename] of Object.entries(DIAGRAM_AUTHORING_CONTRACT_FILES))
|
|
|
165
226
|
function compiledOperatePaths() {
|
|
166
227
|
const catalog = OPERATE_CONTRACT_CATALOG_V2;
|
|
167
228
|
if (
|
|
168
|
-
catalog?.kind !== 'operate-contract-catalog'
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
229
|
+
catalog?.kind !== 'operate-contract-catalog' ||
|
|
230
|
+
catalog.protocol?.id !== 'operate' ||
|
|
231
|
+
catalog.protocol?.version !== '2.0.0' ||
|
|
232
|
+
catalog.protocol?.versionPolicy !== 'exact' ||
|
|
233
|
+
!Array.isArray(catalog.contracts)
|
|
173
234
|
) {
|
|
174
235
|
throw new PipelineError(
|
|
175
236
|
'E_SCHEMA_VERSION_UNSUPPORTED',
|
|
@@ -178,7 +239,10 @@ function compiledOperatePaths() {
|
|
|
178
239
|
}
|
|
179
240
|
const entries = catalog.contracts.map(({ id, schemaPath }) => [id, { '2.0.0': schemaPath }]);
|
|
180
241
|
if (new Set(entries.map(([id]) => id)).size !== entries.length) {
|
|
181
|
-
throw new PipelineError(
|
|
242
|
+
throw new PipelineError(
|
|
243
|
+
'E_SCHEMA_UNKNOWN',
|
|
244
|
+
'The packaged Operate contract catalog contains duplicate contract IDs.',
|
|
245
|
+
);
|
|
182
246
|
}
|
|
183
247
|
return Object.fromEntries(entries);
|
|
184
248
|
}
|
|
@@ -200,27 +264,40 @@ function compiledOperateExperienceVocabulary() {
|
|
|
200
264
|
const kinds = Array.isArray(experience?.contracts)
|
|
201
265
|
? experience.contracts.map(({ id }) => id).sort()
|
|
202
266
|
: [];
|
|
203
|
-
const routes = Array.isArray(experience?.deliveryRoutes)
|
|
267
|
+
const routes = Array.isArray(experience?.deliveryRoutes)
|
|
268
|
+
? [...experience.deliveryRoutes].sort()
|
|
269
|
+
: [];
|
|
204
270
|
if (
|
|
205
|
-
JSON.stringify(kinds) !== JSON.stringify(expectedKinds)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
version
|
|
209
|
-
|
|
271
|
+
JSON.stringify(kinds) !== JSON.stringify(expectedKinds) ||
|
|
272
|
+
JSON.stringify(routes) !== JSON.stringify(expectedRoutes) ||
|
|
273
|
+
experience.contracts.some(
|
|
274
|
+
({ version, schemaPath }) =>
|
|
275
|
+
version !== '1.0.0' ||
|
|
276
|
+
typeof schemaPath !== 'string' ||
|
|
277
|
+
!schemaPath.startsWith('schemas/v2.0.0/'),
|
|
278
|
+
)
|
|
210
279
|
) {
|
|
211
|
-
throw new PipelineError(
|
|
280
|
+
throw new PipelineError(
|
|
281
|
+
'E_SCHEMA_VERSION_UNSUPPORTED',
|
|
282
|
+
'The packaged Operate catalog does not declare the exact public experience contract family.',
|
|
283
|
+
);
|
|
212
284
|
}
|
|
213
285
|
return Object.freeze({
|
|
214
286
|
kinds: Object.freeze(kinds),
|
|
215
287
|
routes: Object.freeze(routes),
|
|
216
|
-
paths: Object.freeze(
|
|
288
|
+
paths: Object.freeze(
|
|
289
|
+
Object.fromEntries(experience.contracts.map(({ id, schemaPath }) => [id, schemaPath])),
|
|
290
|
+
),
|
|
217
291
|
});
|
|
218
292
|
}
|
|
219
293
|
|
|
220
294
|
function compiledOperateRoleMandates() {
|
|
221
295
|
const catalog = OPERATE_CONTRACT_CATALOG_V2;
|
|
222
296
|
if (!Array.isArray(catalog?.roles)) {
|
|
223
|
-
throw new PipelineError(
|
|
297
|
+
throw new PipelineError(
|
|
298
|
+
'E_SCHEMA_VERSION_UNSUPPORTED',
|
|
299
|
+
'The packaged Operate contract catalog does not declare role mandates.',
|
|
300
|
+
);
|
|
224
301
|
}
|
|
225
302
|
const mandates = catalog.roles.map((role) => ({
|
|
226
303
|
id: role?.id,
|
|
@@ -229,44 +306,55 @@ function compiledOperateRoleMandates() {
|
|
|
229
306
|
limits: role?.limits,
|
|
230
307
|
}));
|
|
231
308
|
if (
|
|
232
|
-
mandates.some(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
309
|
+
mandates.some(
|
|
310
|
+
({ id, version, output, limits }) =>
|
|
311
|
+
typeof id !== 'string' ||
|
|
312
|
+
version !== '2.0.0' ||
|
|
313
|
+
typeof output?.schemaId !== 'string' ||
|
|
314
|
+
output.schemaVersion !== '2.0.0' ||
|
|
315
|
+
!Number.isSafeInteger(output.maxBytes) ||
|
|
316
|
+
output.maxBytes < 1 ||
|
|
317
|
+
!Number.isSafeInteger(limits?.maxProposals) ||
|
|
318
|
+
!Number.isSafeInteger(limits?.maxActions),
|
|
319
|
+
) ||
|
|
320
|
+
new Set(mandates.map(({ id, version }) => `${id}@${version}`)).size !== mandates.length
|
|
243
321
|
) {
|
|
244
|
-
throw new PipelineError(
|
|
322
|
+
throw new PipelineError(
|
|
323
|
+
'E_SCHEMA_UNKNOWN',
|
|
324
|
+
'The packaged Operate contract catalog has invalid role mandates.',
|
|
325
|
+
);
|
|
245
326
|
}
|
|
246
|
-
return mandates.map(({ id, version, output, limits }) =>
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
327
|
+
return mandates.map(({ id, version, output, limits }) =>
|
|
328
|
+
Object.freeze({
|
|
329
|
+
id,
|
|
330
|
+
version,
|
|
331
|
+
output: Object.freeze({ ...output }),
|
|
332
|
+
limits: Object.freeze({ ...limits }),
|
|
333
|
+
}),
|
|
334
|
+
);
|
|
252
335
|
}
|
|
253
336
|
|
|
254
337
|
function compiledOperateEvidenceVocabulary() {
|
|
255
338
|
const evidence = OPERATE_CONTRACT_CATALOG_V2?.evidence;
|
|
256
339
|
const fields = ['contractIds', 'kinds', 'edgeRelations', 'resolverErrorCodes'];
|
|
257
340
|
if (
|
|
258
|
-
!evidence
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
341
|
+
!evidence ||
|
|
342
|
+
fields.some((field) => !Array.isArray(evidence[field])) ||
|
|
343
|
+
evidence.contractIds.length !== 7 ||
|
|
344
|
+
evidence.kinds.length !== 4 ||
|
|
345
|
+
evidence.edgeRelations.length !== 2 ||
|
|
346
|
+
evidence.contractIds.some(
|
|
347
|
+
(id) => !OPERATE_CONTRACT_CATALOG_V2.contracts.some((contract) => contract.id === id),
|
|
348
|
+
) ||
|
|
349
|
+
new Set(evidence.contractIds).size !== evidence.contractIds.length ||
|
|
350
|
+
new Set(evidence.kinds).size !== evidence.kinds.length ||
|
|
351
|
+
new Set(evidence.edgeRelations).size !== evidence.edgeRelations.length ||
|
|
352
|
+
new Set(evidence.resolverErrorCodes).size !== evidence.resolverErrorCodes.length
|
|
268
353
|
) {
|
|
269
|
-
throw new PipelineError(
|
|
354
|
+
throw new PipelineError(
|
|
355
|
+
'E_SCHEMA_VERSION_UNSUPPORTED',
|
|
356
|
+
'The packaged Operate catalog does not declare the exact Phase 4 evidence vocabulary.',
|
|
357
|
+
);
|
|
270
358
|
}
|
|
271
359
|
return Object.freeze({
|
|
272
360
|
contractIds: Object.freeze([...evidence.contractIds]),
|
|
@@ -280,17 +368,23 @@ function compiledOperateOperatingIntelligenceVocabulary() {
|
|
|
280
368
|
const vocabulary = OPERATE_CONTRACT_CATALOG_V2?.operatingIntelligence;
|
|
281
369
|
const fields = ['contractIds', 'projectionIdentities', 'providerRegistrationContractIds'];
|
|
282
370
|
if (
|
|
283
|
-
!vocabulary
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
371
|
+
!vocabulary ||
|
|
372
|
+
fields.some((field) => !Array.isArray(vocabulary[field])) ||
|
|
373
|
+
vocabulary.contractIds.length !== 25 ||
|
|
374
|
+
vocabulary.projectionIdentities.length !== 2 ||
|
|
375
|
+
vocabulary.providerRegistrationContractIds.length !== 3 ||
|
|
376
|
+
vocabulary.contractIds.some(
|
|
377
|
+
(id) => !OPERATE_CONTRACT_CATALOG_V2.contracts.some((contract) => contract.id === id),
|
|
378
|
+
) ||
|
|
379
|
+
new Set(vocabulary.contractIds).size !== vocabulary.contractIds.length ||
|
|
380
|
+
new Set(vocabulary.projectionIdentities).size !== vocabulary.projectionIdentities.length ||
|
|
381
|
+
new Set(vocabulary.providerRegistrationContractIds).size !==
|
|
382
|
+
vocabulary.providerRegistrationContractIds.length
|
|
292
383
|
) {
|
|
293
|
-
throw new PipelineError(
|
|
384
|
+
throw new PipelineError(
|
|
385
|
+
'E_SCHEMA_VERSION_UNSUPPORTED',
|
|
386
|
+
'The packaged Operate catalog does not declare the exact Phase 5 operating-intelligence vocabulary.',
|
|
387
|
+
);
|
|
294
388
|
}
|
|
295
389
|
return Object.freeze({
|
|
296
390
|
contractIds: Object.freeze([...vocabulary.contractIds]),
|
|
@@ -302,32 +396,60 @@ function compiledOperateOperatingIntelligenceVocabulary() {
|
|
|
302
396
|
function compiledOperateGovernedExecutionVocabulary() {
|
|
303
397
|
const vocabulary = OPERATE_CONTRACT_CATALOG_V2?.governedExecution;
|
|
304
398
|
const fields = [
|
|
305
|
-
'contractIds',
|
|
306
|
-
'
|
|
399
|
+
'contractIds',
|
|
400
|
+
'providerRegistrationContractIds',
|
|
401
|
+
'effectClasses',
|
|
402
|
+
'policyOutcomes',
|
|
403
|
+
'policyTiers',
|
|
404
|
+
'coreProhibitions',
|
|
405
|
+
'operationStates',
|
|
406
|
+
'toolOperations',
|
|
307
407
|
];
|
|
308
408
|
if (
|
|
309
|
-
!vocabulary
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
409
|
+
!vocabulary ||
|
|
410
|
+
fields.some((field) => !Array.isArray(vocabulary[field])) ||
|
|
411
|
+
vocabulary.contractIds.length !== 13 ||
|
|
412
|
+
vocabulary.providerRegistrationContractIds.length !== 3 ||
|
|
413
|
+
vocabulary.effectClasses.length !== 6 ||
|
|
414
|
+
vocabulary.policyOutcomes.length !== 7 ||
|
|
415
|
+
vocabulary.policyTiers.length !== 3 ||
|
|
416
|
+
vocabulary.coreProhibitions.length !== 9 ||
|
|
417
|
+
vocabulary.operationStates.length !== 10 ||
|
|
418
|
+
vocabulary.toolOperations.length !== 3 ||
|
|
419
|
+
vocabulary.contractIds.some(
|
|
420
|
+
(id) => !OPERATE_CONTRACT_CATALOG_V2.contracts.some((contract) => contract.id === id),
|
|
421
|
+
) ||
|
|
422
|
+
[
|
|
423
|
+
'contractIds',
|
|
424
|
+
'providerRegistrationContractIds',
|
|
425
|
+
'effectClasses',
|
|
426
|
+
'policyOutcomes',
|
|
427
|
+
'coreProhibitions',
|
|
428
|
+
'operationStates',
|
|
429
|
+
].some((field) => new Set(vocabulary[field]).size !== vocabulary[field].length) ||
|
|
430
|
+
new Set(vocabulary.policyTiers.map(({ id }) => id)).size !== vocabulary.policyTiers.length ||
|
|
431
|
+
vocabulary.toolOperations.some(
|
|
432
|
+
({ id }) => !OPERATE_CONTRACT_CATALOG_V2.operations.some((operation) => operation.id === id),
|
|
433
|
+
) ||
|
|
434
|
+
new Set(vocabulary.toolOperations.map(({ id }) => id)).size !== vocabulary.toolOperations.length
|
|
325
435
|
) {
|
|
326
|
-
throw new PipelineError(
|
|
436
|
+
throw new PipelineError(
|
|
437
|
+
'E_SCHEMA_VERSION_UNSUPPORTED',
|
|
438
|
+
'The packaged Operate catalog does not declare the exact Phase 6 governed-execution vocabulary.',
|
|
439
|
+
);
|
|
327
440
|
}
|
|
328
|
-
return Object.freeze(
|
|
329
|
-
|
|
330
|
-
|
|
441
|
+
return Object.freeze(
|
|
442
|
+
Object.fromEntries(
|
|
443
|
+
fields.map((field) => [
|
|
444
|
+
field,
|
|
445
|
+
Object.freeze(
|
|
446
|
+
vocabulary[field].map((entry) =>
|
|
447
|
+
typeof entry === 'object' ? Object.freeze({ ...entry }) : entry,
|
|
448
|
+
),
|
|
449
|
+
),
|
|
450
|
+
]),
|
|
451
|
+
),
|
|
452
|
+
);
|
|
331
453
|
}
|
|
332
454
|
|
|
333
455
|
function compiledPublicOperateDomainContractBindings() {
|
|
@@ -337,13 +459,21 @@ function compiledPublicOperateDomainContractBindings() {
|
|
|
337
459
|
software: { apiDomainId: 'software', id: 'software-domain', version: '1.0.0' },
|
|
338
460
|
};
|
|
339
461
|
if (!Array.isArray(domains)) {
|
|
340
|
-
throw new PipelineError(
|
|
462
|
+
throw new PipelineError(
|
|
463
|
+
'E_SCHEMA_VERSION_UNSUPPORTED',
|
|
464
|
+
'The packaged Operate catalog does not declare public domain registrations.',
|
|
465
|
+
);
|
|
341
466
|
}
|
|
342
467
|
const bindings = {};
|
|
343
468
|
for (const [domainId, binding] of Object.entries(expected)) {
|
|
344
|
-
const domain = domains.find(
|
|
469
|
+
const domain = domains.find(
|
|
470
|
+
(entry) => entry?.domainId === domainId && entry?.domainVersion === binding.version,
|
|
471
|
+
);
|
|
345
472
|
if (domain === undefined || JSON.stringify(domain.domainContract) !== JSON.stringify(binding)) {
|
|
346
|
-
throw new PipelineError(
|
|
473
|
+
throw new PipelineError(
|
|
474
|
+
'E_SCHEMA_VERSION_UNSUPPORTED',
|
|
475
|
+
'The packaged Operate catalog has an invalid explicit API-domain contract binding.',
|
|
476
|
+
);
|
|
347
477
|
}
|
|
348
478
|
bindings[domainId] = Object.freeze({ ...binding });
|
|
349
479
|
}
|
|
@@ -356,50 +486,68 @@ const paths = {
|
|
|
356
486
|
};
|
|
357
487
|
|
|
358
488
|
const OPERATE_EXPERIENCE_VOCABULARY_V1 = compiledOperateExperienceVocabulary();
|
|
359
|
-
const experiencePaths = Object.freeze(
|
|
360
|
-
Object.
|
|
361
|
-
))
|
|
489
|
+
const experiencePaths = Object.freeze(
|
|
490
|
+
Object.fromEntries(
|
|
491
|
+
Object.entries(OPERATE_EXPERIENCE_VOCABULARY_V1.paths).map(([kind, path]) => [
|
|
492
|
+
kind,
|
|
493
|
+
Object.freeze({ '2.0.0': path }),
|
|
494
|
+
]),
|
|
495
|
+
),
|
|
496
|
+
);
|
|
362
497
|
|
|
363
498
|
// Every Operate v2 identity is compiler-owned. Keeping this set derived avoids
|
|
364
499
|
// a second hand-maintained version boundary when the canonical registry grows.
|
|
365
|
-
const explicitProtocolVersionKinds = new Set(
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
],
|
|
388
|
-
);
|
|
500
|
+
const explicitProtocolVersionKinds = new Set([
|
|
501
|
+
...OPERATE_CONTRACT_CATALOG_V2.contracts.map(({ id }) => id),
|
|
502
|
+
'role-registry',
|
|
503
|
+
'task-kind-registry',
|
|
504
|
+
'task-manifest',
|
|
505
|
+
'task-output-manifest',
|
|
506
|
+
'rule-catalog',
|
|
507
|
+
'command-catalog',
|
|
508
|
+
'skill-catalog',
|
|
509
|
+
'output-catalog',
|
|
510
|
+
'output-path-catalog',
|
|
511
|
+
'generated-asset-manifest',
|
|
512
|
+
'migration-preservation-manifest',
|
|
513
|
+
'skill-source',
|
|
514
|
+
'skill-module-registry',
|
|
515
|
+
'skill-host-profile-registry',
|
|
516
|
+
'skill-routing-registry',
|
|
517
|
+
'skill-completion-receipt',
|
|
518
|
+
'skill-consent-record',
|
|
519
|
+
'skill-learning-record',
|
|
520
|
+
'skill-session',
|
|
521
|
+
]);
|
|
389
522
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
523
|
+
/** @type {typeof import('./contracts.d.mts').PROTOCOL_SCHEMA_REGISTRY} */
|
|
524
|
+
export const PROTOCOL_SCHEMA_REGISTRY = Object.freeze(
|
|
525
|
+
Object.fromEntries(
|
|
526
|
+
Object.entries(paths).map(([kind, versions]) => [kind, Object.freeze({ ...versions })]),
|
|
527
|
+
),
|
|
528
|
+
);
|
|
393
529
|
|
|
394
|
-
/**
|
|
530
|
+
/**
|
|
531
|
+
* Closed public product-experience and Operate-to-Planning contract identities.
|
|
532
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_EXPERIENCE_CONTRACT_KINDS_V2}
|
|
533
|
+
*/
|
|
395
534
|
export const OPERATE_EXPERIENCE_CONTRACT_KINDS_V2 = OPERATE_EXPERIENCE_VOCABULARY_V1.kinds;
|
|
396
|
-
/**
|
|
535
|
+
/**
|
|
536
|
+
* The only delivery classifications accepted by the Operate-to-Planning bridge.
|
|
537
|
+
* @type {typeof import('./contracts.d.mts').OPERATING_DELIVERY_ROUTES_V1}
|
|
538
|
+
*/
|
|
397
539
|
export const OPERATING_DELIVERY_ROUTES_V1 = OPERATE_EXPERIENCE_VOCABULARY_V1.routes;
|
|
398
540
|
|
|
399
|
-
/**
|
|
541
|
+
/**
|
|
542
|
+
* Compiler-owned, explicit Protocol 2.0 role mandates.
|
|
543
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_ROLE_MANDATES_V2}
|
|
544
|
+
*/
|
|
400
545
|
export const OPERATE_ROLE_MANDATES_V2 = Object.freeze(compiledOperateRoleMandates());
|
|
401
546
|
|
|
402
|
-
/**
|
|
547
|
+
/**
|
|
548
|
+
* Compiler-owned public extension record identities.
|
|
549
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_EXTENSION_CONTRACT_KINDS_V2}
|
|
550
|
+
*/
|
|
403
551
|
export const OPERATE_EXTENSION_CONTRACT_KINDS_V2 = Object.freeze(
|
|
404
552
|
OPERATE_CONTRACT_CATALOG_V2.contracts
|
|
405
553
|
.filter(({ category }) => category === 'extension')
|
|
@@ -408,133 +556,193 @@ export const OPERATE_EXTENSION_CONTRACT_KINDS_V2 = Object.freeze(
|
|
|
408
556
|
);
|
|
409
557
|
|
|
410
558
|
const OPERATE_EVIDENCE_VOCABULARY_V2 = compiledOperateEvidenceVocabulary();
|
|
411
|
-
/**
|
|
559
|
+
/**
|
|
560
|
+
* Compiler-owned Phase 4 evidence record identities.
|
|
561
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_EVIDENCE_CONTRACT_KINDS_V2}
|
|
562
|
+
*/
|
|
412
563
|
export const OPERATE_EVIDENCE_CONTRACT_KINDS_V2 = OPERATE_EVIDENCE_VOCABULARY_V2.contractIds;
|
|
413
|
-
/**
|
|
564
|
+
/**
|
|
565
|
+
* The four shipped local evidence source kinds.
|
|
566
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_EVIDENCE_KINDS_V2}
|
|
567
|
+
*/
|
|
414
568
|
export const OPERATE_EVIDENCE_KINDS_V2 = OPERATE_EVIDENCE_VOCABULARY_V2.kinds;
|
|
415
|
-
/**
|
|
569
|
+
/**
|
|
570
|
+
* The only Phase 4 source-Artifact-local evidence edge relations.
|
|
571
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_EVIDENCE_EDGE_RELATIONS_V2}
|
|
572
|
+
*/
|
|
416
573
|
export const OPERATE_EVIDENCE_EDGE_RELATIONS_V2 = OPERATE_EVIDENCE_VOCABULARY_V2.edgeRelations;
|
|
417
|
-
/**
|
|
418
|
-
|
|
574
|
+
/**
|
|
575
|
+
* Stable, safe resolver failure reasons.
|
|
576
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_EVIDENCE_RESOLVER_ERROR_CODES_V2}
|
|
577
|
+
*/
|
|
578
|
+
export const OPERATE_EVIDENCE_RESOLVER_ERROR_CODES_V2 =
|
|
579
|
+
OPERATE_EVIDENCE_VOCABULARY_V2.resolverErrorCodes;
|
|
419
580
|
|
|
420
|
-
const OPERATE_OPERATING_INTELLIGENCE_VOCABULARY_V2 =
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
export const
|
|
581
|
+
const OPERATE_OPERATING_INTELLIGENCE_VOCABULARY_V2 =
|
|
582
|
+
compiledOperateOperatingIntelligenceVocabulary();
|
|
583
|
+
/**
|
|
584
|
+
* Compiler-owned Phase 5 operating-intelligence record identities.
|
|
585
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_OPERATING_INTELLIGENCE_CONTRACT_KINDS_V2}
|
|
586
|
+
*/
|
|
587
|
+
export const OPERATE_OPERATING_INTELLIGENCE_CONTRACT_KINDS_V2 =
|
|
588
|
+
OPERATE_OPERATING_INTELLIGENCE_VOCABULARY_V2.contractIds;
|
|
589
|
+
/**
|
|
590
|
+
* Exact public domain-projection identities; no implicit string derivation is allowed.
|
|
591
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_OPERATING_PROJECTION_IDENTITIES_V2}
|
|
592
|
+
*/
|
|
593
|
+
export const OPERATE_OPERATING_PROJECTION_IDENTITIES_V2 =
|
|
594
|
+
OPERATE_OPERATING_INTELLIGENCE_VOCABULARY_V2.projectionIdentities;
|
|
595
|
+
/**
|
|
596
|
+
* Public Phase 5 provider declaration identities. Registration grants no authority.
|
|
597
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_OPERATING_PROVIDER_REGISTRATION_CONTRACT_KINDS_V2}
|
|
598
|
+
*/
|
|
599
|
+
export const OPERATE_OPERATING_PROVIDER_REGISTRATION_CONTRACT_KINDS_V2 =
|
|
600
|
+
OPERATE_OPERATING_INTELLIGENCE_VOCABULARY_V2.providerRegistrationContractIds;
|
|
427
601
|
const OPERATE_GOVERNED_EXECUTION_VOCABULARY_V2 = compiledOperateGovernedExecutionVocabulary();
|
|
428
|
-
/**
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
/**
|
|
602
|
+
/**
|
|
603
|
+
* Compiler-owned Phase 6 authority and execution contract identities.
|
|
604
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_GOVERNED_EXECUTION_CONTRACT_KINDS_V2}
|
|
605
|
+
*/
|
|
606
|
+
export const OPERATE_GOVERNED_EXECUTION_CONTRACT_KINDS_V2 =
|
|
607
|
+
OPERATE_GOVERNED_EXECUTION_VOCABULARY_V2.contractIds;
|
|
608
|
+
/**
|
|
609
|
+
* Data-only capability, policy, and executor registration identities.
|
|
610
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_GOVERNED_PROVIDER_REGISTRATION_CONTRACT_KINDS_V2}
|
|
611
|
+
*/
|
|
612
|
+
export const OPERATE_GOVERNED_PROVIDER_REGISTRATION_CONTRACT_KINDS_V2 =
|
|
613
|
+
OPERATE_GOVERNED_EXECUTION_VOCABULARY_V2.providerRegistrationContractIds;
|
|
614
|
+
/**
|
|
615
|
+
* Exact classification vocabulary; classification alone never grants authority.
|
|
616
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_GOVERNED_EFFECT_CLASSES_V2}
|
|
617
|
+
*/
|
|
618
|
+
export const OPERATE_GOVERNED_EFFECT_CLASSES_V2 =
|
|
619
|
+
OPERATE_GOVERNED_EXECUTION_VOCABULARY_V2.effectClasses;
|
|
620
|
+
/**
|
|
621
|
+
* Exact closed policy disposition vocabulary.
|
|
622
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_GOVERNED_POLICY_OUTCOMES_V2}
|
|
623
|
+
*/
|
|
624
|
+
export const OPERATE_GOVERNED_POLICY_OUTCOMES_V2 =
|
|
625
|
+
OPERATE_GOVERNED_EXECUTION_VOCABULARY_V2.policyOutcomes;
|
|
626
|
+
/**
|
|
627
|
+
* Immutable core > project > narrowing domain policy precedence.
|
|
628
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_GOVERNED_POLICY_TIERS_V2}
|
|
629
|
+
*/
|
|
630
|
+
export const OPERATE_GOVERNED_POLICY_TIERS_V2 =
|
|
631
|
+
OPERATE_GOVERNED_EXECUTION_VOCABULARY_V2.policyTiers;
|
|
632
|
+
/**
|
|
633
|
+
* Non-overridable reference policy prohibitions.
|
|
634
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_GOVERNED_CORE_PROHIBITIONS_V2}
|
|
635
|
+
*/
|
|
636
|
+
export const OPERATE_GOVERNED_CORE_PROHIBITIONS_V2 =
|
|
637
|
+
OPERATE_GOVERNED_EXECUTION_VOCABULARY_V2.coreProhibitions;
|
|
638
|
+
/**
|
|
639
|
+
* Closed crash-recovery outcomes; none of these outcomes independently grants authority.
|
|
640
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_GOVERNED_RECOVERY_CLASSIFICATIONS_V2}
|
|
641
|
+
*/
|
|
441
642
|
export const OPERATE_GOVERNED_RECOVERY_CLASSIFICATIONS_V2 = Object.freeze([
|
|
442
|
-
'applied',
|
|
643
|
+
'applied',
|
|
644
|
+
'not-applied',
|
|
645
|
+
'partial',
|
|
646
|
+
'unknown',
|
|
443
647
|
]);
|
|
444
648
|
|
|
445
|
-
const OPERATE_CORE_PROHIBITION_TOKEN_EXPANSIONS_V2 = Object.freeze(
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
649
|
+
const OPERATE_CORE_PROHIBITION_TOKEN_EXPANSIONS_V2 = Object.freeze(
|
|
650
|
+
Object.assign(Object.create(null), {
|
|
651
|
+
credentials: ['credential'],
|
|
652
|
+
customers: ['customer'],
|
|
653
|
+
funds: ['fund'],
|
|
654
|
+
funding: ['fund'],
|
|
655
|
+
money: ['fund'],
|
|
656
|
+
monies: ['fund'],
|
|
657
|
+
payments: ['payment'],
|
|
658
|
+
pay: ['payment'],
|
|
659
|
+
pays: ['payment'],
|
|
660
|
+
paying: ['payment'],
|
|
661
|
+
paid: ['payment'],
|
|
662
|
+
payout: ['payment', 'transfer'],
|
|
663
|
+
payouts: ['payment', 'transfer'],
|
|
664
|
+
transfers: ['transfer'],
|
|
665
|
+
transferred: ['transfer'],
|
|
666
|
+
transferring: ['transfer'],
|
|
667
|
+
remits: ['transfer'],
|
|
668
|
+
remit: ['transfer'],
|
|
669
|
+
remitted: ['transfer'],
|
|
670
|
+
remitting: ['transfer'],
|
|
671
|
+
contacted: ['contact'],
|
|
672
|
+
contacting: ['contact'],
|
|
673
|
+
contacts: ['contact'],
|
|
674
|
+
message: ['contact'],
|
|
675
|
+
messages: ['contact'],
|
|
676
|
+
messaged: ['contact'],
|
|
677
|
+
messaging: ['contact'],
|
|
678
|
+
email: ['contact'],
|
|
679
|
+
emails: ['contact'],
|
|
680
|
+
emailed: ['contact'],
|
|
681
|
+
emailing: ['contact'],
|
|
682
|
+
reachout: ['contact'],
|
|
683
|
+
reachouts: ['contact'],
|
|
684
|
+
deployed: ['deploy'],
|
|
685
|
+
deploying: ['deploy'],
|
|
686
|
+
deploys: ['deploy'],
|
|
687
|
+
ship: ['deploy'],
|
|
688
|
+
ships: ['deploy'],
|
|
689
|
+
shipped: ['deploy'],
|
|
690
|
+
shipping: ['deploy'],
|
|
691
|
+
deliver: ['deploy'],
|
|
692
|
+
delivers: ['deploy'],
|
|
693
|
+
delivered: ['deploy'],
|
|
694
|
+
delivering: ['deploy'],
|
|
695
|
+
delivery: ['deploy'],
|
|
696
|
+
deliveries: ['deploy'],
|
|
697
|
+
merged: ['merge'],
|
|
698
|
+
merging: ['merge'],
|
|
699
|
+
merges: ['merge'],
|
|
700
|
+
published: ['publish'],
|
|
701
|
+
publishing: ['publish'],
|
|
702
|
+
publishes: ['publish'],
|
|
703
|
+
publication: ['publish'],
|
|
704
|
+
publications: ['publish'],
|
|
705
|
+
released: ['publish'],
|
|
706
|
+
release: ['publish'],
|
|
707
|
+
releasing: ['publish'],
|
|
708
|
+
releases: ['publish'],
|
|
709
|
+
rotated: ['rotate'],
|
|
710
|
+
rotating: ['rotate'],
|
|
711
|
+
mutated: ['mutate'],
|
|
712
|
+
mutating: ['mutate'],
|
|
713
|
+
changed: ['change'],
|
|
714
|
+
changing: ['change'],
|
|
715
|
+
sent: ['send'],
|
|
716
|
+
sending: ['send'],
|
|
717
|
+
destroyed: ['destroy'],
|
|
718
|
+
destroying: ['destroy'],
|
|
719
|
+
deletes: ['delete'],
|
|
720
|
+
deleting: ['delete'],
|
|
721
|
+
deleted: ['delete'],
|
|
722
|
+
erased: ['delete'],
|
|
723
|
+
erase: ['delete'],
|
|
724
|
+
erasing: ['delete'],
|
|
725
|
+
removed: ['delete'],
|
|
726
|
+
remove: ['delete'],
|
|
727
|
+
removing: ['delete'],
|
|
728
|
+
wiped: ['delete'],
|
|
729
|
+
wipe: ['delete'],
|
|
730
|
+
wiping: ['delete'],
|
|
731
|
+
secrets: ['secret'],
|
|
732
|
+
prod: ['production'],
|
|
733
|
+
}),
|
|
734
|
+
);
|
|
529
735
|
|
|
530
736
|
function operateCoreProhibitionTokens(value) {
|
|
531
737
|
if (typeof value !== 'string') return [];
|
|
532
|
-
const normalized = value
|
|
738
|
+
const normalized = value
|
|
739
|
+
.normalize('NFKC')
|
|
533
740
|
.replace(/([a-z0-9])([A-Z])/gu, '$1-$2')
|
|
534
741
|
.toLowerCase()
|
|
535
742
|
.replace(/[^a-z0-9]+/gu, '-')
|
|
536
743
|
.replace(/^-+|-+$/gu, '');
|
|
537
|
-
return normalized
|
|
744
|
+
return normalized
|
|
745
|
+
.split('-')
|
|
538
746
|
.filter((token) => token.length > 0 && !/^\d+$/u.test(token))
|
|
539
747
|
.flatMap((token) => OPERATE_CORE_PROHIBITION_TOKEN_EXPANSIONS_V2[token] ?? [token]);
|
|
540
748
|
}
|
|
@@ -543,15 +751,18 @@ function operateCoreProhibitionTokens(value) {
|
|
|
543
751
|
* Resolve one non-overridable governed-execution prohibition from semantic
|
|
544
752
|
* identifier fragments. Matching is normalized, order-independent, and
|
|
545
753
|
* intentionally shared by registration and contained-input validation.
|
|
754
|
+
* @type {typeof import('./contracts.d.mts').findOperateCoreProhibitionV2}
|
|
546
755
|
*/
|
|
547
756
|
export function findOperateCoreProhibitionV2(values) {
|
|
548
757
|
const input = Array.isArray(values) ? values : [values];
|
|
549
758
|
const words = new Set(input.flatMap(operateCoreProhibitionTokens));
|
|
550
|
-
|
|
759
|
+
/** @type {Array<[string, boolean]>} */
|
|
760
|
+
const candidates = [
|
|
551
761
|
['credential-change', words.has('credential')],
|
|
552
|
-
[
|
|
553
|
-
|
|
554
|
-
|
|
762
|
+
[
|
|
763
|
+
'customer-contact',
|
|
764
|
+
words.has('customer') && (words.has('contact') || (words.has('reach') && words.has('out'))),
|
|
765
|
+
],
|
|
555
766
|
['destructive', ['destructive', 'destroy', 'delete'].some((word) => words.has(word))],
|
|
556
767
|
['funds-transfer', words.has('fund') && (words.has('transfer') || words.has('send'))],
|
|
557
768
|
['payment-transfer', words.has('payment') && (words.has('transfer') || words.has('send'))],
|
|
@@ -559,36 +770,79 @@ export function findOperateCoreProhibitionV2(values) {
|
|
|
559
770
|
['production-merge', words.has('production') && words.has('merge')],
|
|
560
771
|
['publication', words.has('publish')],
|
|
561
772
|
['secret-mutation', words.has('secret')],
|
|
562
|
-
]
|
|
773
|
+
];
|
|
774
|
+
const matched = candidates.find(([, present]) => present);
|
|
563
775
|
return matched && OPERATE_GOVERNED_CORE_PROHIBITIONS_V2.includes(matched[0]) ? matched[0] : null;
|
|
564
776
|
}
|
|
565
|
-
/**
|
|
566
|
-
|
|
567
|
-
|
|
777
|
+
/**
|
|
778
|
+
* Exact durable governed-operation lifecycle vocabulary.
|
|
779
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_GOVERNED_OPERATION_STATES_V2}
|
|
780
|
+
*/
|
|
781
|
+
export const OPERATE_GOVERNED_OPERATION_STATES_V2 =
|
|
782
|
+
OPERATE_GOVERNED_EXECUTION_VOCABULARY_V2.operationStates;
|
|
783
|
+
/**
|
|
784
|
+
* Terminal result-bearing states eligible for pure at-most-once replay.
|
|
785
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_GOVERNED_OPERATION_TERMINAL_STATES_V2}
|
|
786
|
+
*/
|
|
568
787
|
export const OPERATE_GOVERNED_OPERATION_TERMINAL_STATES_V2 = Object.freeze(
|
|
569
|
-
OPERATE_GOVERNED_OPERATION_STATES_V2
|
|
570
|
-
|
|
571
|
-
|
|
788
|
+
OPERATE_GOVERNED_OPERATION_STATES_V2.filter((state) =>
|
|
789
|
+
['succeeded', 'failed', 'partial', 'uncertain', 'blocked'].includes(state),
|
|
790
|
+
).sort(),
|
|
572
791
|
);
|
|
573
|
-
/**
|
|
792
|
+
/**
|
|
793
|
+
* Result truth retained independently from the later Action hypothesis verdict.
|
|
794
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_EXECUTION_VERIFICATION_STATUSES_V2}
|
|
795
|
+
*/
|
|
574
796
|
export const OPERATE_EXECUTION_VERIFICATION_STATUSES_V2 = Object.freeze([
|
|
575
|
-
'success',
|
|
797
|
+
'success',
|
|
798
|
+
'failure',
|
|
799
|
+
'blocked',
|
|
800
|
+
'uncertain',
|
|
801
|
+
'partial',
|
|
802
|
+
'cancelled',
|
|
803
|
+
'rolled-back',
|
|
576
804
|
]);
|
|
577
|
-
/**
|
|
805
|
+
/**
|
|
806
|
+
* Bounded verification truth; `success` is intentionally absent.
|
|
807
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_HYPOTHESIS_VERIFICATION_STATUSES_V2}
|
|
808
|
+
*/
|
|
578
809
|
export const OPERATE_HYPOTHESIS_VERIFICATION_STATUSES_V2 = Object.freeze([
|
|
579
|
-
'pending',
|
|
810
|
+
'pending',
|
|
811
|
+
'confirmed',
|
|
812
|
+
'failed',
|
|
813
|
+
'blocked',
|
|
814
|
+
'cancelled',
|
|
815
|
+
'revisit',
|
|
580
816
|
]);
|
|
581
|
-
/**
|
|
582
|
-
|
|
583
|
-
|
|
817
|
+
/**
|
|
818
|
+
* Exact public tools owned by the canonical Phase 6 authority guard.
|
|
819
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_GOVERNED_TOOL_OPERATIONS_V2}
|
|
820
|
+
*/
|
|
821
|
+
export const OPERATE_GOVERNED_TOOL_OPERATIONS_V2 =
|
|
822
|
+
OPERATE_GOVERNED_EXECUTION_VOCABULARY_V2.toolOperations;
|
|
823
|
+
/**
|
|
824
|
+
* Compiler-owned guard identities used by governed Review and Action authority.
|
|
825
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_AUTHORITY_GUARD_IDS_V2}
|
|
826
|
+
*/
|
|
584
827
|
export const OPERATE_AUTHORITY_GUARD_IDS_V2 = Object.freeze(
|
|
585
828
|
OPERATE_CONTRACT_CATALOG_V2.guards
|
|
586
|
-
.filter(({ id }) =>
|
|
829
|
+
.filter(({ id }) =>
|
|
830
|
+
[
|
|
831
|
+
'review-submit-authorized',
|
|
832
|
+
'action-approval-authorized',
|
|
833
|
+
'action-execution-authorized',
|
|
834
|
+
'action-rollback-authorized',
|
|
835
|
+
].includes(id),
|
|
836
|
+
)
|
|
587
837
|
.map(({ id }) => id)
|
|
588
838
|
.sort(),
|
|
589
839
|
);
|
|
590
|
-
/**
|
|
591
|
-
|
|
840
|
+
/**
|
|
841
|
+
* Exact compiler-owned public API-domain bindings; no string conversion is permitted.
|
|
842
|
+
* @type {typeof import('./contracts.d.mts').OPERATE_PUBLIC_DOMAIN_CONTRACT_BINDINGS_V2}
|
|
843
|
+
*/
|
|
844
|
+
export const OPERATE_PUBLIC_DOMAIN_CONTRACT_BINDINGS_V2 =
|
|
845
|
+
compiledPublicOperateDomainContractBindings();
|
|
592
846
|
|
|
593
847
|
const OPERATE_INTELLIGENCE_KERNEL_KINDS_V2 = Object.freeze(['advisor', 'challenger', 'chair']);
|
|
594
848
|
|
|
@@ -618,9 +872,7 @@ function assertCanonicalOperateIntelligencePlanTopologyV2(plan) {
|
|
|
618
872
|
if (role.roleKind === 'advisor') return [];
|
|
619
873
|
if (role.roleKind === 'challenger') return [...advisorIds];
|
|
620
874
|
if (role.roleKind === 'chair') {
|
|
621
|
-
return plan.challengerRequired
|
|
622
|
-
? [...advisorIds, challengers[0].roleId]
|
|
623
|
-
: [...advisorIds];
|
|
875
|
+
return plan.challengerRequired ? [...advisorIds, challengers[0].roleId] : [...advisorIds];
|
|
624
876
|
}
|
|
625
877
|
return null;
|
|
626
878
|
};
|
|
@@ -629,27 +881,32 @@ function assertCanonicalOperateIntelligencePlanTopologyV2(plan) {
|
|
|
629
881
|
challenger: 'operating-challenger-review',
|
|
630
882
|
chair: 'operating-decision-ledger',
|
|
631
883
|
};
|
|
632
|
-
const topologyInvalid =
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
884
|
+
const topologyInvalid =
|
|
885
|
+
advisors.length < 1 ||
|
|
886
|
+
chairs.length !== 1 ||
|
|
887
|
+
challengers.length !== (plan.challengerRequired ? 1 : 0) ||
|
|
888
|
+
omittedChallengers.length !== (plan.challengerRequired ? 0 : 1) ||
|
|
889
|
+
JSON.stringify(selected.map(({ roleId }) => roleId)) !== JSON.stringify(expectedSelectedIds) ||
|
|
890
|
+
JSON.stringify(omitted.map(({ roleId }) => roleId)) !== JSON.stringify(expectedOmittedIds) ||
|
|
891
|
+
selected.some((role) => {
|
|
639
892
|
const expectedDeps = dependencyExpectation(role);
|
|
640
|
-
return
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
||
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
893
|
+
return (
|
|
894
|
+
role.roleVersion !== '2.0.0' ||
|
|
895
|
+
role.outputContract.schemaId !== outputSchemaByRoleKind[role.roleKind] ||
|
|
896
|
+
role.outputContract.schemaVersion !== '2.0.0' ||
|
|
897
|
+
!OPERATE_INTELLIGENCE_KERNEL_KINDS_V2.includes(role.roleKind) ||
|
|
898
|
+
expectedDeps === null ||
|
|
899
|
+
JSON.stringify([...role.dependsOnRoleIds].sort()) !==
|
|
900
|
+
JSON.stringify([...expectedDeps].sort())
|
|
901
|
+
);
|
|
902
|
+
}) ||
|
|
903
|
+
omitted.some(
|
|
904
|
+
(role) =>
|
|
905
|
+
role.roleVersion !== '2.0.0' ||
|
|
906
|
+
!OPERATE_INTELLIGENCE_KERNEL_KINDS_V2.includes(role.roleKind) ||
|
|
907
|
+
typeof role.reason !== 'string' ||
|
|
908
|
+
!role.reason.startsWith('not-selected:'),
|
|
909
|
+
);
|
|
653
910
|
if (topologyInvalid) {
|
|
654
911
|
throw new PipelineError(
|
|
655
912
|
'E_PROTOCOL_ARTIFACT_INVALID',
|
|
@@ -660,7 +917,10 @@ function assertCanonicalOperateIntelligencePlanTopologyV2(plan) {
|
|
|
660
917
|
}
|
|
661
918
|
}
|
|
662
919
|
|
|
663
|
-
/**
|
|
920
|
+
/**
|
|
921
|
+
* Validate the exact compiler-owned explainable-plan contract and canonical topology.
|
|
922
|
+
* @returns {ReturnType<typeof import('./contracts.d.mts').assertOperateIntelligencePlanContractV2>}
|
|
923
|
+
*/
|
|
664
924
|
export function assertOperateIntelligencePlanContractV2(value) {
|
|
665
925
|
const plan = assertProtocolArtifact('operating-intelligence-plan', value, {
|
|
666
926
|
protocolVersion: '2.0.0',
|
|
@@ -694,10 +954,10 @@ function assertCompiledOperateSchemaIdentities() {
|
|
|
694
954
|
const expectedId = `https://openplanr.dev/${schemaPath}`;
|
|
695
955
|
const declared = schema?.['x-openplanr-contract'];
|
|
696
956
|
if (
|
|
697
|
-
schema?.$schema !== 'https://json-schema.org/draft/2020-12/schema'
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
957
|
+
schema?.$schema !== 'https://json-schema.org/draft/2020-12/schema' ||
|
|
958
|
+
schema?.$id !== expectedId ||
|
|
959
|
+
declared?.id !== id ||
|
|
960
|
+
declared?.version !== version
|
|
701
961
|
) {
|
|
702
962
|
throw new PipelineError(
|
|
703
963
|
'E_SCHEMA_VERSION_UNSUPPORTED',
|
|
@@ -716,7 +976,9 @@ function requireOperateRoleMandate(roleId, roleVersion) {
|
|
|
716
976
|
`Operate role mandate "${roleId}" requires an explicit version.`,
|
|
717
977
|
);
|
|
718
978
|
}
|
|
719
|
-
const mandate = OPERATE_ROLE_MANDATES_V2.find(
|
|
979
|
+
const mandate = OPERATE_ROLE_MANDATES_V2.find(
|
|
980
|
+
({ id, version }) => id === roleId && version === roleVersion,
|
|
981
|
+
);
|
|
720
982
|
if (!mandate) {
|
|
721
983
|
throw new PipelineError(
|
|
722
984
|
'E_SCHEMA_VERSION_UNSUPPORTED',
|
|
@@ -730,6 +992,7 @@ function requireOperateRoleMandate(roleId, roleVersion) {
|
|
|
730
992
|
* Resolve the exact mandate that an Operate Assignment can advertise. The
|
|
731
993
|
* caller supplies a role version deliberately; no previous role version is
|
|
732
994
|
* selected as a fallback.
|
|
995
|
+
* @type {typeof import('./contracts.d.mts').loadOperateRoleMandateV2}
|
|
733
996
|
*/
|
|
734
997
|
export function loadOperateRoleMandateV2(roleId, { roleVersion } = {}) {
|
|
735
998
|
const mandate = requireOperateRoleMandate(roleId, roleVersion);
|
|
@@ -742,10 +1005,11 @@ export function loadOperateRoleMandateV2(roleId, { roleVersion } = {}) {
|
|
|
742
1005
|
* The runtime continues to validate the resulting Assignment at submission;
|
|
743
1006
|
* this boundary makes the advertised template and that validation input one
|
|
744
1007
|
* explicit, versioned contract.
|
|
1008
|
+
* @type {typeof import('./contracts.d.mts').assertOperateRoleOutputContractV2}
|
|
745
1009
|
*/
|
|
746
1010
|
export function assertOperateRoleOutputContractV2(roleId, outputContract, { roleVersion } = {}) {
|
|
747
1011
|
const mandate = requireOperateRoleMandate(roleId, roleVersion);
|
|
748
|
-
const expected = mandate.output;
|
|
1012
|
+
const expected = /** @type {Record<string, unknown>} */ (mandate.output);
|
|
749
1013
|
const actual = outputContract ?? {};
|
|
750
1014
|
for (const field of ['schemaId', 'schemaVersion', 'mediaType', 'maxBytes']) {
|
|
751
1015
|
if (actual[field] !== expected[field]) {
|
|
@@ -777,9 +1041,9 @@ function referencedSchemaPath(basePath, reference) {
|
|
|
777
1041
|
// safe.
|
|
778
1042
|
const packageRelative = relative(packageRoot, absolute).split(sep).join('/');
|
|
779
1043
|
if (
|
|
780
|
-
packageRelative.startsWith('..')
|
|
781
|
-
|
|
782
|
-
|
|
1044
|
+
packageRelative.startsWith('..') ||
|
|
1045
|
+
packageRelative.includes('/../') ||
|
|
1046
|
+
!packageRelative.startsWith('schemas/')
|
|
783
1047
|
) {
|
|
784
1048
|
throw new PipelineError(
|
|
785
1049
|
'E_SCHEMA_REFERENCE_UNSAFE',
|
|
@@ -794,10 +1058,10 @@ function resolveSchemaFragment(schema, reference) {
|
|
|
794
1058
|
if (fragmentIndex < 0 || reference.slice(fragmentIndex) === '#') return schema;
|
|
795
1059
|
const fragment = reference.slice(fragmentIndex);
|
|
796
1060
|
if (!fragment.startsWith('#/')) return null;
|
|
797
|
-
return fragment
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
1061
|
+
return fragment
|
|
1062
|
+
.slice(2)
|
|
1063
|
+
.split('/')
|
|
1064
|
+
.reduce((value, part) => value?.[part.replaceAll('~1', '/').replaceAll('~0', '~')], schema);
|
|
801
1065
|
}
|
|
802
1066
|
|
|
803
1067
|
function compareProtocolVersions(left, right) {
|
|
@@ -834,15 +1098,17 @@ function inferredVersion(kind, value, explicitVersion) {
|
|
|
834
1098
|
);
|
|
835
1099
|
}
|
|
836
1100
|
|
|
1101
|
+
/** @type {typeof import('./contracts.d.mts').listProtocolSchemas} */
|
|
837
1102
|
export function listProtocolSchemas() {
|
|
838
|
-
return Object.entries(PROTOCOL_SCHEMA_REGISTRY).flatMap(([kind, versions]) =>
|
|
839
|
-
Object.entries(versions).map(([protocolVersion, path]) => ({ kind, protocolVersion, path }))
|
|
840
|
-
)
|
|
1103
|
+
return Object.entries(PROTOCOL_SCHEMA_REGISTRY).flatMap(([kind, versions]) =>
|
|
1104
|
+
Object.entries(versions).map(([protocolVersion, path]) => ({ kind, protocolVersion, path })),
|
|
1105
|
+
);
|
|
841
1106
|
}
|
|
842
1107
|
|
|
843
1108
|
function sharedProtocolSchema(kind, protocolVersion) {
|
|
844
1109
|
const versions = PROTOCOL_SCHEMA_REGISTRY[kind];
|
|
845
|
-
if (!versions)
|
|
1110
|
+
if (!versions)
|
|
1111
|
+
throw new PipelineError('E_SCHEMA_UNKNOWN', `Unknown protocol artifact kind: ${kind}`);
|
|
846
1112
|
const path = versions[protocolVersion];
|
|
847
1113
|
if (!path) {
|
|
848
1114
|
throw new PipelineError(
|
|
@@ -856,7 +1122,11 @@ function sharedProtocolSchema(kind, protocolVersion) {
|
|
|
856
1122
|
|
|
857
1123
|
function sharedOperateExperienceSchemaV2(kind, protocolVersion) {
|
|
858
1124
|
const versions = experiencePaths[kind];
|
|
859
|
-
if (!versions)
|
|
1125
|
+
if (!versions)
|
|
1126
|
+
throw new PipelineError(
|
|
1127
|
+
'E_SCHEMA_UNKNOWN',
|
|
1128
|
+
`Unknown Operate experience artifact kind: ${kind}`,
|
|
1129
|
+
);
|
|
860
1130
|
if (protocolVersion !== '2.0.0') {
|
|
861
1131
|
throw new PipelineError(
|
|
862
1132
|
protocolVersion ? 'E_SCHEMA_VERSION_UNSUPPORTED' : 'E_SCHEMA_VERSION_REQUIRED',
|
|
@@ -873,11 +1143,15 @@ function sharedOperateExperienceSchemaV2(kind, protocolVersion) {
|
|
|
873
1143
|
// Public resolvers hand out a mutable copy so callers can never reach the cache.
|
|
874
1144
|
const withSchemaCopy = (resolved) => ({ ...resolved, schema: structuredClone(resolved.schema) });
|
|
875
1145
|
|
|
1146
|
+
/** @type {typeof import('./contracts.d.mts').resolveProtocolSchema} */
|
|
876
1147
|
export function resolveProtocolSchema(kind, { protocolVersion } = {}) {
|
|
877
1148
|
return withSchemaCopy(sharedProtocolSchema(kind, protocolVersion));
|
|
878
1149
|
}
|
|
879
1150
|
|
|
880
|
-
/**
|
|
1151
|
+
/**
|
|
1152
|
+
* Resolve a public experience schema without adding it to the 61-contract runtime kernel.
|
|
1153
|
+
* @type {typeof import('./contracts.d.mts').resolveOperateExperienceSchemaV2}
|
|
1154
|
+
*/
|
|
881
1155
|
export function resolveOperateExperienceSchemaV2(kind, { protocolVersion } = {}) {
|
|
882
1156
|
return withSchemaCopy(sharedOperateExperienceSchemaV2(kind, protocolVersion));
|
|
883
1157
|
}
|
|
@@ -897,25 +1171,25 @@ function validateResolvedArtifact(value, resolved) {
|
|
|
897
1171
|
});
|
|
898
1172
|
}
|
|
899
1173
|
|
|
900
|
-
const GUIDED_ANSWER_COPY_FIELDS = Object.freeze([
|
|
901
|
-
'questionId',
|
|
902
|
-
'questionVersion',
|
|
903
|
-
'sensitivity',
|
|
904
|
-
]);
|
|
1174
|
+
const GUIDED_ANSWER_COPY_FIELDS = Object.freeze(['questionId', 'questionVersion', 'sensitivity']);
|
|
905
1175
|
|
|
906
1176
|
function guidedQuestionnaireCompatibilityErrors(value) {
|
|
907
1177
|
const copyFields = value?.submission?.envelope?.dynamicFields?.answers?.copyFields;
|
|
908
1178
|
if (
|
|
909
|
-
!Array.isArray(copyFields)
|
|
910
|
-
|
|
911
|
-
)
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1179
|
+
!Array.isArray(copyFields) ||
|
|
1180
|
+
JSON.stringify(copyFields) === JSON.stringify(GUIDED_ANSWER_COPY_FIELDS)
|
|
1181
|
+
)
|
|
1182
|
+
return [];
|
|
1183
|
+
return [
|
|
1184
|
+
{
|
|
1185
|
+
path: '$.submission.envelope.dynamicFields.answers.copyFields',
|
|
1186
|
+
rule: 'exactAnswerCopyFields',
|
|
1187
|
+
detail: 'answer copy fields must match the guided answer envelope schema',
|
|
1188
|
+
},
|
|
1189
|
+
];
|
|
917
1190
|
}
|
|
918
1191
|
|
|
1192
|
+
/** @type {typeof import('./contracts.d.mts').validateProtocolArtifact} */
|
|
919
1193
|
export function validateProtocolArtifact(kind, value, { protocolVersion } = {}) {
|
|
920
1194
|
const authoringKind = Object.hasOwn(DIAGRAM_AUTHORING_CONTRACT_FILES, kind);
|
|
921
1195
|
let versionInput = value;
|
|
@@ -924,12 +1198,15 @@ export function validateProtocolArtifact(kind, value, { protocolVersion } = {})
|
|
|
924
1198
|
// Its safety preflight owns the resulting located diagnostic.
|
|
925
1199
|
let descriptor;
|
|
926
1200
|
try {
|
|
927
|
-
descriptor =
|
|
928
|
-
|
|
1201
|
+
descriptor =
|
|
1202
|
+
value !== null && typeof value === 'object'
|
|
1203
|
+
? Object.getOwnPropertyDescriptor(value, 'protocolVersion')
|
|
1204
|
+
: undefined;
|
|
929
1205
|
} catch {
|
|
930
1206
|
return validateDiagramAuthoringArtifact(kind, value);
|
|
931
1207
|
}
|
|
932
|
-
if (descriptor && !Object.hasOwn(descriptor, 'value'))
|
|
1208
|
+
if (descriptor && !Object.hasOwn(descriptor, 'value'))
|
|
1209
|
+
return validateDiagramAuthoringArtifact(kind, value);
|
|
933
1210
|
versionInput = { protocolVersion: descriptor?.value };
|
|
934
1211
|
}
|
|
935
1212
|
const version = inferredVersion(kind, versionInput, protocolVersion);
|
|
@@ -947,6 +1224,7 @@ export function validateProtocolArtifact(kind, value, { protocolVersion } = {})
|
|
|
947
1224
|
/**
|
|
948
1225
|
* Validate the dashboard bootstrap schema plus invariants JSON Schema cannot
|
|
949
1226
|
* express, most importantly equality of the served and embedded build IDs.
|
|
1227
|
+
* @returns {ReturnType<typeof import('./contracts.d.mts').validateDashboardBootstrapV1>}
|
|
950
1228
|
*/
|
|
951
1229
|
export function validateDashboardBootstrapV1(value) {
|
|
952
1230
|
const errors = validateProtocolArtifact('dashboard-bootstrap', value, {
|
|
@@ -986,7 +1264,10 @@ export function validateDashboardBootstrapV1(value) {
|
|
|
986
1264
|
return errors;
|
|
987
1265
|
}
|
|
988
1266
|
|
|
989
|
-
/**
|
|
1267
|
+
/**
|
|
1268
|
+
* Assert the complete public dashboard bootstrap contract.
|
|
1269
|
+
* @type {typeof import('./contracts.d.mts').assertDashboardBootstrapV1}
|
|
1270
|
+
*/
|
|
990
1271
|
export function assertDashboardBootstrapV1(value) {
|
|
991
1272
|
const errors = validateDashboardBootstrapV1(value);
|
|
992
1273
|
if (errors.length) {
|
|
@@ -998,19 +1279,25 @@ export function assertDashboardBootstrapV1(value) {
|
|
|
998
1279
|
return value;
|
|
999
1280
|
}
|
|
1000
1281
|
|
|
1282
|
+
/** @type {typeof import('./contracts.d.mts').validateOperateExperienceArtifactV2} */
|
|
1001
1283
|
export function validateOperateExperienceArtifactV2(kind, value) {
|
|
1002
1284
|
const resolved = sharedOperateExperienceSchemaV2(kind, '2.0.0');
|
|
1003
1285
|
return validateResolvedArtifact(value, resolved);
|
|
1004
1286
|
}
|
|
1005
1287
|
|
|
1288
|
+
/** @type {typeof import('./contracts.d.mts').assertOperateExperienceArtifactV2} */
|
|
1006
1289
|
export function assertOperateExperienceArtifactV2(kind, value) {
|
|
1007
1290
|
const errors = validateOperateExperienceArtifactV2(kind, value);
|
|
1008
1291
|
if (errors.length) {
|
|
1009
|
-
throw new PipelineError(
|
|
1292
|
+
throw new PipelineError(
|
|
1293
|
+
'E_PROTOCOL_ARTIFACT_INVALID',
|
|
1294
|
+
`${kind}: ${errors[0].path} ${errors[0].detail}`,
|
|
1295
|
+
);
|
|
1010
1296
|
}
|
|
1011
1297
|
return value;
|
|
1012
1298
|
}
|
|
1013
1299
|
|
|
1300
|
+
/** @type {typeof import('./contracts.d.mts').assertProtocolArtifact} */
|
|
1014
1301
|
export function assertProtocolArtifact(kind, value, options) {
|
|
1015
1302
|
const errors = validateProtocolArtifact(kind, value, options);
|
|
1016
1303
|
if (errors.length) {
|
|
@@ -1024,7 +1311,10 @@ export function assertProtocolArtifact(kind, value, options) {
|
|
|
1024
1311
|
return value;
|
|
1025
1312
|
}
|
|
1026
1313
|
|
|
1027
|
-
/**
|
|
1314
|
+
/**
|
|
1315
|
+
* Validate only one of the three Phase 6 data-only registration contracts.
|
|
1316
|
+
* @type {typeof import('./contracts.d.mts').assertOperateGovernedExtensionRegistrationV2}
|
|
1317
|
+
*/
|
|
1028
1318
|
export function assertOperateGovernedExtensionRegistrationV2(kind, value) {
|
|
1029
1319
|
if (!OPERATE_GOVERNED_PROVIDER_REGISTRATION_CONTRACT_KINDS_V2.includes(kind)) {
|
|
1030
1320
|
throw new PipelineError(
|