@openplanr/protocol 0.6.1 → 0.7.0

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