@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.
Files changed (55) hide show
  1. package/lib/dashboard/closed-json-contract.mjs +99 -109
  2. package/lib/dashboard/operate-experience-audit-display-contract.d.mts +128 -153
  3. package/lib/dashboard/operate-experience-audit-display-contract.mjs +530 -585
  4. package/lib/dashboard/operate-experience-display-contract.d.mts +415 -437
  5. package/lib/dashboard/operate-experience-display-contract.mjs +768 -831
  6. package/lib/dashboard/operate-experience-surface-contract.d.mts +143 -148
  7. package/lib/dashboard/operate-experience-surface-contract.mjs +72 -73
  8. package/lib/dashboard/operate-review-contract.d.mts +7 -14
  9. package/lib/dashboard/operate-review-contract.mjs +46 -42
  10. package/lib/dashboard/operate-review-display-workspace-contract.d.mts +2 -5
  11. package/lib/dashboard/operate-review-display-workspace-contract.mjs +158 -104
  12. package/lib/dashboard/operate-review-payload-safety.mjs +4 -2
  13. package/lib/dashboard/operate-review-workspace-projection-v2.d.mts +47 -33
  14. package/lib/protocol/index.d.ts +2647 -543
  15. package/package.json +1 -1
  16. package/registries/commands.json +3 -3
  17. package/registries/skills.json +5 -5
  18. package/src/browser-contracts.d.mts +4 -1
  19. package/src/browser-contracts.mjs +16 -5
  20. package/src/canonical-json.d.mts +3 -1
  21. package/src/canonical-json.mjs +57 -20
  22. package/src/compat/live-evidence-v2.mjs +1604 -485
  23. package/src/compat/operate-experience-live-patch.mjs +67 -15
  24. package/src/compat/operating-planning-contracts.mjs +183 -51
  25. package/src/contracts.d.mts +54 -13
  26. package/src/contracts.mjs +625 -335
  27. package/src/design-contracts.mjs +58 -21
  28. package/src/design-handoff-contracts.d.mts +67 -11
  29. package/src/design-handoff-contracts.mjs +243 -98
  30. package/src/design-publication-contracts.mjs +98 -33
  31. package/src/diagram-authoring-contracts.d.mts +422 -78
  32. package/src/diagram-authoring-contracts.mjs +1697 -326
  33. package/src/diagram-contracts.d.mts +4 -1
  34. package/src/diagram-contracts.mjs +16 -4
  35. package/src/enterprise-contracts.d.mts +211 -46
  36. package/src/enterprise-contracts.mjs +727 -175
  37. package/src/errors.mjs +4 -0
  38. package/src/generated/canonical-registries.mjs +8 -8
  39. package/src/index.d.mts +8 -8
  40. package/src/index.mjs +36 -20
  41. package/src/json-schema.d.mts +21 -6
  42. package/src/json-schema.mjs +66 -18
  43. package/src/planning-contracts.d.mts +8 -2
  44. package/src/planning-contracts.mjs +33 -7
  45. package/src/registries.d.mts +11 -3
  46. package/src/registries.mjs +369 -87
  47. package/src/review-experience-contracts.d.mts +7 -2
  48. package/src/review-experience-contracts.mjs +198 -49
  49. package/src/semver.mjs +5 -1
  50. package/src/skill-source-contracts.d.mts +36 -16
  51. package/src/skill-source-contracts.mjs +25 -6
  52. package/src/task-contracts.d.mts +13 -3
  53. package/src/task-contracts.mjs +181 -40
  54. package/src/workspace-contracts.d.mts +38 -10
  55. package/src/workspace-contracts.mjs +147 -33
@@ -6,14 +6,13 @@
6
6
  * rather than shared: the projection module has 111 `fail` and 46 `clone` call sites, and these
7
7
  * duplicates are meant to die with it.
8
8
  */
9
- import { PipelineError } from '../errors.mjs';
10
- import { assertOperateExperienceArtifactV2 } from '../contracts.mjs';
9
+
11
10
  import { sha256Jcs } from '../canonical-json.mjs';
11
+ import { assertOperateExperienceArtifactV2 } from '../contracts.mjs';
12
+ import { PipelineError } from '../errors.mjs';
12
13
 
13
14
  const PROTOCOL_VERSION = '2.0.0';
14
15
 
15
-
16
-
17
16
  function fail(code, message, context = {}) {
18
17
  throw new PipelineError(code, message, '', { retryable: false, context });
19
18
  }
@@ -40,26 +39,79 @@ function stableId(prefix, value) {
40
39
 
41
40
  function assertCanonicalView(view) {
42
41
  assertOperateExperienceArtifactV2('operate-experience-view', view);
43
- if (view.viewHash !== sha256Jcs(without(view, 'viewHash'))) fail('E_OPERATE_BINDING_MISMATCH', 'Experience viewHash does not equal its canonical content.');
42
+ if (view.viewHash !== sha256Jcs(without(view, 'viewHash')))
43
+ fail('E_OPERATE_BINDING_MISMATCH', 'Experience viewHash does not equal its canonical content.');
44
44
  return view;
45
45
  }
46
46
 
47
47
  function validInstant(value, field) {
48
- if (typeof value !== 'string' || Number.isNaN(Date.parse(value))) fail('RESULT_CONTRACT_INVALID', `${field} must be an RFC 3339 instant.`);
48
+ if (typeof value !== 'string' || Number.isNaN(Date.parse(value)))
49
+ fail('RESULT_CONTRACT_INVALID', `${field} must be an RFC 3339 instant.`);
49
50
  return value;
50
51
  }
51
52
 
52
- export function buildOperateExperienceLivePatchV2(previous, next, { createdAt = next?.generatedAt } = {}) {
53
- assertCanonicalView(previous); assertCanonicalView(next);
54
- for (const field of ['scopeId', 'domainId', 'domainVersion', 'actorId', 'accessLevel']) if (previous[field] !== next[field]) fail('E_OPERATE_BINDING_MISMATCH', `Live patch binding changed at ${field}.`);
55
- if (next.eventHead.sequence !== previous.eventHead.sequence + 1
56
- || (previous.eventHead.sequence > 0 && next.eventHead.hash === previous.eventHead.hash)) {
57
- fail('STATE_TRANSITION_INVALID', 'Live patch requires one exact contiguous, non-forking Event-head advance.');
53
+ export function buildOperateExperienceLivePatchV2(
54
+ previous,
55
+ next,
56
+ { createdAt = next?.generatedAt } = {},
57
+ ) {
58
+ assertCanonicalView(previous);
59
+ assertCanonicalView(next);
60
+ for (const field of ['scopeId', 'domainId', 'domainVersion', 'actorId', 'accessLevel'])
61
+ if (previous[field] !== next[field])
62
+ fail('E_OPERATE_BINDING_MISMATCH', `Live patch binding changed at ${field}.`);
63
+ if (
64
+ next.eventHead.sequence !== previous.eventHead.sequence + 1 ||
65
+ (previous.eventHead.sequence > 0 && next.eventHead.hash === previous.eventHead.hash)
66
+ ) {
67
+ fail(
68
+ 'STATE_TRANSITION_INVALID',
69
+ 'Live patch requires one exact contiguous, non-forking Event-head advance.',
70
+ );
58
71
  }
59
72
  validInstant(createdAt, 'createdAt');
60
- const paths = ['status', 'attention', 'domainMetrics', 'cycles', 'inbox', 'actions', 'evidence', 'claims', 'rationale', 'outcomes', 'learnings', 'history', 'replay', 'allowedActions', 'omissions', 'export'];
61
- const operations = paths.filter((path) => sha256Jcs(previous[path]) !== sha256Jcs(next[path])).map((path) => ({ op: 'replace', path: `/${path}`, valueHash: sha256Jcs(next[path]), value: clone(next[path]) }));
62
- const base = { kind: 'operate-experience-live-patch', schemaVersion: '1.0.0', protocolVersion: PROTOCOL_VERSION, patchId: stableId('xpatch', { from: previous.viewHash, to: next.viewHash }), scopeId: next.scopeId, domainId: next.domainId, domainVersion: next.domainVersion, actorId: next.actorId, fromEventHead: clone(previous.eventHead), toEventHead: clone(next.eventHead), fromViewHash: previous.viewHash, toViewHash: next.viewHash, operations, createdAt };
73
+ const paths = [
74
+ 'status',
75
+ 'attention',
76
+ 'domainMetrics',
77
+ 'cycles',
78
+ 'inbox',
79
+ 'actions',
80
+ 'evidence',
81
+ 'claims',
82
+ 'rationale',
83
+ 'outcomes',
84
+ 'learnings',
85
+ 'history',
86
+ 'replay',
87
+ 'allowedActions',
88
+ 'omissions',
89
+ 'export',
90
+ ];
91
+ const operations = paths
92
+ .filter((path) => sha256Jcs(previous[path]) !== sha256Jcs(next[path]))
93
+ .map((path) => ({
94
+ op: 'replace',
95
+ path: `/${path}`,
96
+ valueHash: sha256Jcs(next[path]),
97
+ value: clone(next[path]),
98
+ }));
99
+ const base = {
100
+ kind: 'operate-experience-live-patch',
101
+ schemaVersion: '1.0.0',
102
+ protocolVersion: PROTOCOL_VERSION,
103
+ patchId: stableId('xpatch', { from: previous.viewHash, to: next.viewHash }),
104
+ scopeId: next.scopeId,
105
+ domainId: next.domainId,
106
+ domainVersion: next.domainVersion,
107
+ actorId: next.actorId,
108
+ fromEventHead: clone(previous.eventHead),
109
+ toEventHead: clone(next.eventHead),
110
+ fromViewHash: previous.viewHash,
111
+ toViewHash: next.viewHash,
112
+ operations,
113
+ createdAt,
114
+ };
63
115
  const patch = { ...base, patchHash: sha256Jcs(base) };
64
116
  assertOperateExperienceArtifactV2('operate-experience-live-patch', patch);
65
117
  return freeze(patch);
@@ -4,29 +4,51 @@
4
4
  * These assertions are needed by the protocol loader and the pipeline's origin reader, neither of
5
5
  * which should reach into the Operate runtime to get them. The Operate side imports them back.
6
6
  */
7
- import { PipelineError } from '../errors.mjs';
8
- import { assertOperateExperienceArtifactV2 } from '../contracts.mjs';
7
+
9
8
  import { sha256Jcs } from '../canonical-json.mjs';
9
+ import { assertOperateExperienceArtifactV2 } from '../contracts.mjs';
10
+ import { PipelineError } from '../errors.mjs';
10
11
 
11
12
  const PROTOCOL_VERSION = '2.0.0';
12
13
 
13
- const FORBIDDEN_KEY = /(?:hidden|chain[-_]?of[-_]?thought|reasoning|raw[-_]?prompt|credential|secret|token|private[-_]?path|rejected[-_]?advice)/iu;
14
- const FORBIDDEN_TEXT = /(?:\/Users\/|\/home\/|[A-Za-z]:\\|-----BEGIN [A-Z ]+PRIVATE KEY-----|\b(?:api[-_]?key|access[-_]?token|password)\b\s*[:=])/iu;
14
+ const FORBIDDEN_KEY =
15
+ /(?:hidden|chain[-_]?of[-_]?thought|reasoning|raw[-_]?prompt|credential|secret|token|private[-_]?path|rejected[-_]?advice)/iu;
16
+ const FORBIDDEN_TEXT =
17
+ /(?:\/Users\/|\/home\/|[A-Za-z]:\\|-----BEGIN [A-Z ]+PRIVATE KEY-----|\b(?:api[-_]?key|access[-_]?token|password)\b\s*[:=])/iu;
15
18
 
16
19
  function fail(code, message, context = {}) {
17
20
  throw new PipelineError(code, message, '', { retryable: false, context });
18
21
  }
19
22
 
20
- function without(value, field) { return Object.fromEntries(Object.entries(value).filter(([key]) => key !== field)); }
23
+ function without(value, field) {
24
+ return Object.fromEntries(Object.entries(value).filter(([key]) => key !== field));
25
+ }
21
26
 
22
- function sameScope(value, scope) { return Boolean(scope) && value?.scopeId === scope.scopeId && value?.domainId === scope.domainId && value?.domainVersion === scope.domainVersion; }
23
- function sameHead(left, right) { return left?.sequence === right?.sequence && left?.hash === right?.hash; }
27
+ function sameScope(value, scope) {
28
+ return (
29
+ Boolean(scope) &&
30
+ value?.scopeId === scope.scopeId &&
31
+ value?.domainId === scope.domainId &&
32
+ value?.domainVersion === scope.domainVersion
33
+ );
34
+ }
35
+ function sameHead(left, right) {
36
+ return left?.sequence === right?.sequence && left?.hash === right?.hash;
37
+ }
24
38
 
25
39
  function assertNoSensitiveContext(value, path = '$') {
26
- if (typeof value === 'string' && FORBIDDEN_TEXT.test(value)) fail('EVIDENCE_ACCESS_DENIED', `Access-safe planning context contains prohibited private material at ${path}.`);
40
+ if (typeof value === 'string' && FORBIDDEN_TEXT.test(value))
41
+ fail(
42
+ 'EVIDENCE_ACCESS_DENIED',
43
+ `Access-safe planning context contains prohibited private material at ${path}.`,
44
+ );
27
45
  if (!value || typeof value !== 'object') return;
28
46
  for (const [key, nested] of Object.entries(value)) {
29
- if (FORBIDDEN_KEY.test(key)) fail('EVIDENCE_ACCESS_DENIED', `Access-safe planning context contains prohibited field ${path}.${key}.`);
47
+ if (FORBIDDEN_KEY.test(key))
48
+ fail(
49
+ 'EVIDENCE_ACCESS_DENIED',
50
+ `Access-safe planning context contains prohibited field ${path}.${key}.`,
51
+ );
30
52
  assertNoSensitiveContext(nested, `${path}.${key}`);
31
53
  }
32
54
  }
@@ -34,80 +56,190 @@ function assertNoSensitiveContext(value, path = '$') {
34
56
  export function assertOperatingPlanningProposalV1(proposal) {
35
57
  assertOperateExperienceArtifactV2('operating-planning-proposal', proposal);
36
58
  assertNoSensitiveContext(proposal);
37
- if (proposal.proposalHash !== sha256Jcs(without(proposal, 'proposalHash'))) fail('E_OPERATE_BINDING_MISMATCH', 'Planning proposal hash does not equal its canonical content.');
59
+ if (proposal.proposalHash !== sha256Jcs(without(proposal, 'proposalHash')))
60
+ fail(
61
+ 'E_OPERATE_BINDING_MISMATCH',
62
+ 'Planning proposal hash does not equal its canonical content.',
63
+ );
38
64
  const route = proposal.deliveryRoute;
39
- if (!sameScope(route, proposal) || !sameHead(route.eventHead, proposal.eventHead)
40
- || route.action.actionId !== proposal.action.actionId || route.action.revision !== proposal.action.revision
41
- || route.action.actionHash !== proposal.action.actionHash || route.routeHash !== sha256Jcs(without(route, 'routeHash'))) {
42
- fail('E_OPERATE_BINDING_MISMATCH', 'Planning proposal delivery route does not bind its exact scope, Action, and Event head.');
65
+ if (
66
+ !sameScope(route, proposal) ||
67
+ !sameHead(route.eventHead, proposal.eventHead) ||
68
+ route.action.actionId !== proposal.action.actionId ||
69
+ route.action.revision !== proposal.action.revision ||
70
+ route.action.actionHash !== proposal.action.actionHash ||
71
+ route.routeHash !== sha256Jcs(without(route, 'routeHash'))
72
+ ) {
73
+ fail(
74
+ 'E_OPERATE_BINDING_MISMATCH',
75
+ 'Planning proposal delivery route does not bind its exact scope, Action, and Event head.',
76
+ );
43
77
  }
44
- const chair = proposal.acceptedPerspectiveSummaries.filter(({ roleKind }) => roleKind === 'chair');
45
- const challenger = proposal.acceptedPerspectiveSummaries.filter(({ roleKind }) => roleKind === 'challenger');
46
- const advisors = proposal.acceptedPerspectiveSummaries.filter(({ roleKind }) => roleKind === 'advisor');
47
- const normative = proposal.acceptedPerspectiveSummaries.filter(({ normative: isNormative }) => isNormative);
48
- if (chair.length !== 1 || challenger.length !== 1 || advisors.length < 1 || normative.length !== 1 || normative[0] !== chair[0]
49
- || chair[0].stance !== 'synthesis' || chair[0].artifactId !== proposal.decision.sourceArtifactId
50
- || proposal.action.sourceArtifactId !== proposal.decision.sourceArtifactId || chair[0].summary !== proposal.decision.rationale
51
- || proposal.acceptedPerspectiveSummaries.some((perspective) => perspective.roleVersion !== PROTOCOL_VERSION)) {
52
- fail('E_OPERATE_BINDING_MISMATCH', 'Planning proposal requires exact advisor/Challenger context and exactly one normative Chair synthesis equal to the Decision rationale.');
78
+ const chair = proposal.acceptedPerspectiveSummaries.filter(
79
+ ({ roleKind }) => roleKind === 'chair',
80
+ );
81
+ const challenger = proposal.acceptedPerspectiveSummaries.filter(
82
+ ({ roleKind }) => roleKind === 'challenger',
83
+ );
84
+ const advisors = proposal.acceptedPerspectiveSummaries.filter(
85
+ ({ roleKind }) => roleKind === 'advisor',
86
+ );
87
+ const normative = proposal.acceptedPerspectiveSummaries.filter(
88
+ ({ normative: isNormative }) => isNormative,
89
+ );
90
+ if (
91
+ chair.length !== 1 ||
92
+ challenger.length !== 1 ||
93
+ advisors.length < 1 ||
94
+ normative.length !== 1 ||
95
+ normative[0] !== chair[0] ||
96
+ chair[0].stance !== 'synthesis' ||
97
+ chair[0].artifactId !== proposal.decision.sourceArtifactId ||
98
+ proposal.action.sourceArtifactId !== proposal.decision.sourceArtifactId ||
99
+ chair[0].summary !== proposal.decision.rationale ||
100
+ proposal.acceptedPerspectiveSummaries.some(
101
+ (perspective) => perspective.roleVersion !== PROTOCOL_VERSION,
102
+ )
103
+ ) {
104
+ fail(
105
+ 'E_OPERATE_BINDING_MISMATCH',
106
+ 'Planning proposal requires exact advisor/Challenger context and exactly one normative Chair synthesis equal to the Decision rationale.',
107
+ );
53
108
  }
54
109
  const decisionEvidenceIds = [...proposal.decision.evidenceRefIds].sort();
55
110
  const projectedEvidenceIds = proposal.evidence.map(({ evidenceRefId }) => evidenceRefId).sort();
56
- if (new Set(projectedEvidenceIds).size !== projectedEvidenceIds.length || sha256Jcs(decisionEvidenceIds) !== sha256Jcs(projectedEvidenceIds)
57
- || proposal.evidence.some((entry) => entry.accessState === 'restricted' ? entry.summary !== null : typeof entry.summary !== 'string')) {
58
- fail('E_OPERATE_BINDING_MISMATCH', 'Planning proposal evidence does not equal the exact access-safe Decision evidence set.');
111
+ if (
112
+ new Set(projectedEvidenceIds).size !== projectedEvidenceIds.length ||
113
+ sha256Jcs(decisionEvidenceIds) !== sha256Jcs(projectedEvidenceIds) ||
114
+ proposal.evidence.some((entry) =>
115
+ entry.accessState === 'restricted'
116
+ ? entry.summary !== null
117
+ : typeof entry.summary !== 'string',
118
+ )
119
+ ) {
120
+ fail(
121
+ 'E_OPERATE_BINDING_MISMATCH',
122
+ 'Planning proposal evidence does not equal the exact access-safe Decision evidence set.',
123
+ );
59
124
  }
60
- if (proposal.metric.metricId !== proposal.action.metricId || proposal.verification.metricId !== proposal.metric.metricId
61
- || proposal.verification.metricHash !== proposal.metric.metricHash || proposal.verification.verificationPlanId !== proposal.action.verificationPlanId) fail('E_OPERATE_BINDING_MISMATCH', 'Planning proposal metric and verification identities are not exact.');
62
- if (proposal.preview.digest !== sha256Jcs({ proposalId: proposal.proposalId, correlationId: proposal.correlationId, eventHead: proposal.eventHead, framing: proposal.framing, actorId: proposal.actor.actorId })
63
- || proposal.preview.issuedAt !== proposal.createdAt || Date.parse(proposal.preview.expiresAt) <= Date.parse(proposal.preview.issuedAt)) {
64
- fail('E_OPERATE_BINDING_MISMATCH', 'Planning proposal preview digest, actor, or expiry is not exact.');
125
+ if (
126
+ proposal.metric.metricId !== proposal.action.metricId ||
127
+ proposal.verification.metricId !== proposal.metric.metricId ||
128
+ proposal.verification.metricHash !== proposal.metric.metricHash ||
129
+ proposal.verification.verificationPlanId !== proposal.action.verificationPlanId
130
+ )
131
+ fail(
132
+ 'E_OPERATE_BINDING_MISMATCH',
133
+ 'Planning proposal metric and verification identities are not exact.',
134
+ );
135
+ if (
136
+ proposal.preview.digest !==
137
+ sha256Jcs({
138
+ proposalId: proposal.proposalId,
139
+ correlationId: proposal.correlationId,
140
+ eventHead: proposal.eventHead,
141
+ framing: proposal.framing,
142
+ actorId: proposal.actor.actorId,
143
+ }) ||
144
+ proposal.preview.issuedAt !== proposal.createdAt ||
145
+ Date.parse(proposal.preview.expiresAt) <= Date.parse(proposal.preview.issuedAt)
146
+ ) {
147
+ fail(
148
+ 'E_OPERATE_BINDING_MISMATCH',
149
+ 'Planning proposal preview digest, actor, or expiry is not exact.',
150
+ );
65
151
  }
66
152
  if (proposal.state === 'approved') {
67
- const reviewBase = { ...without(proposal, 'proposalHash'), revision: 1, predecessorProposalHash: null, state: 'review-required', confirmation: null };
153
+ const reviewBase = {
154
+ ...without(proposal, 'proposalHash'),
155
+ revision: 1,
156
+ predecessorProposalHash: null,
157
+ state: 'review-required',
158
+ confirmation: null,
159
+ };
68
160
  const reviewHash = sha256Jcs(reviewBase);
69
161
  const confirmation = proposal.confirmation;
70
- if (proposal.revision !== 2 || proposal.predecessorProposalHash !== reviewHash || confirmation.reviewProposalHash !== reviewHash
71
- || confirmation.reviewProposalRevision !== 1 || !sameHead(confirmation.eventHead, proposal.eventHead)
72
- || confirmation.previewDigest !== proposal.preview.digest || confirmation.actorId !== proposal.actor.actorId
73
- || confirmation.previewExpiresAt !== proposal.preview.expiresAt || confirmation.confirmationHash !== sha256Jcs(without(confirmation, 'confirmationHash'))
74
- || Date.parse(confirmation.confirmedAt) < Date.parse(proposal.preview.issuedAt)
75
- || Date.parse(confirmation.confirmedAt) > Date.parse(confirmation.previewExpiresAt)) fail('E_OPERATE_BINDING_MISMATCH', 'Approved proposal lacks exact, timely human confirmation proof.');
162
+ if (
163
+ proposal.revision !== 2 ||
164
+ proposal.predecessorProposalHash !== reviewHash ||
165
+ confirmation.reviewProposalHash !== reviewHash ||
166
+ confirmation.reviewProposalRevision !== 1 ||
167
+ !sameHead(confirmation.eventHead, proposal.eventHead) ||
168
+ confirmation.previewDigest !== proposal.preview.digest ||
169
+ confirmation.actorId !== proposal.actor.actorId ||
170
+ confirmation.previewExpiresAt !== proposal.preview.expiresAt ||
171
+ confirmation.confirmationHash !== sha256Jcs(without(confirmation, 'confirmationHash')) ||
172
+ Date.parse(confirmation.confirmedAt) < Date.parse(proposal.preview.issuedAt) ||
173
+ Date.parse(confirmation.confirmedAt) > Date.parse(confirmation.previewExpiresAt)
174
+ )
175
+ fail(
176
+ 'E_OPERATE_BINDING_MISMATCH',
177
+ 'Approved proposal lacks exact, timely human confirmation proof.',
178
+ );
76
179
  }
77
180
  return proposal;
78
181
  }
79
182
 
80
183
  export function assertOperatingOriginV1(origin) {
81
- assertOperateExperienceArtifactV2('operating-origin', origin); assertNoSensitiveContext(origin);
82
- if (origin.originHash !== sha256Jcs(without(origin, 'originHash')) || origin.verification.metricId !== origin.metric.metricId || origin.verification.metricHash !== origin.metric.metricHash) fail('E_OPERATE_BINDING_MISMATCH', 'Operating origin hash or metric/verification binding is invalid.');
184
+ assertOperateExperienceArtifactV2('operating-origin', origin);
185
+ assertNoSensitiveContext(origin);
186
+ if (
187
+ origin.originHash !== sha256Jcs(without(origin, 'originHash')) ||
188
+ origin.verification.metricId !== origin.metric.metricId ||
189
+ origin.verification.metricHash !== origin.metric.metricHash
190
+ )
191
+ fail(
192
+ 'E_OPERATE_BINDING_MISMATCH',
193
+ 'Operating origin hash or metric/verification binding is invalid.',
194
+ );
83
195
  return origin;
84
196
  }
85
197
 
86
198
  export function assertOperatingDeliveryEvidenceV1(evidence) {
87
- assertOperateExperienceArtifactV2('operating-delivery-evidence', evidence); assertNoSensitiveContext(evidence);
199
+ assertOperateExperienceArtifactV2('operating-delivery-evidence', evidence);
200
+ assertNoSensitiveContext(evidence);
88
201
  assertDeliveryClassification(evidence.classification, evidence.artifacts);
89
- if (evidence.deliveryEvidenceHash !== sha256Jcs(without(evidence, 'deliveryEvidenceHash')) || evidence.outcomeStatus !== 'verification-required'
90
- || evidence.verification.metricId !== evidence.metric.metricId || evidence.verification.metricHash !== evidence.metric.metricHash
91
- || ((evidence.deliveryStatus === 'rolled-back') !== (evidence.rollback !== null))
92
- || (evidence.rollback !== null && (evidence.rollback.originalShipRunId !== evidence.shipRun.runId || evidence.rollback.status !== 'succeeded'))) fail('E_OPERATE_BINDING_MISMATCH', 'Delivery evidence is not exact or attempts to substitute verification, rollback custody, or claim Outcome closure.');
202
+ if (
203
+ evidence.deliveryEvidenceHash !== sha256Jcs(without(evidence, 'deliveryEvidenceHash')) ||
204
+ evidence.outcomeStatus !== 'verification-required' ||
205
+ evidence.verification.metricId !== evidence.metric.metricId ||
206
+ evidence.verification.metricHash !== evidence.metric.metricHash ||
207
+ (evidence.deliveryStatus === 'rolled-back') !== (evidence.rollback !== null) ||
208
+ (evidence.rollback !== null &&
209
+ (evidence.rollback.originalShipRunId !== evidence.shipRun.runId ||
210
+ evidence.rollback.status !== 'succeeded'))
211
+ )
212
+ fail(
213
+ 'E_OPERATE_BINDING_MISMATCH',
214
+ 'Delivery evidence is not exact or attempts to substitute verification, rollback custody, or claim Outcome closure.',
215
+ );
93
216
  return evidence;
94
217
  }
95
218
 
96
219
  function assertDeliveryClassification(classification, artifacts) {
97
220
  const rank = { public: 0, internal: 1, confidential: 2, restricted: 3 };
98
- if (!(classification in rank) || !Array.isArray(artifacts)
99
- || artifacts.some((artifact) => !(artifact.classification in rank) || rank[artifact.classification] > rank[classification])) {
100
- fail('E_OPERATE_BINDING_MISMATCH', 'Delivery classification cannot narrow accepted Artifact classification.');
221
+ if (
222
+ !(classification in rank) ||
223
+ !Array.isArray(artifacts) ||
224
+ artifacts.some(
225
+ (artifact) =>
226
+ !(artifact.classification in rank) || rank[artifact.classification] > rank[classification],
227
+ )
228
+ ) {
229
+ fail(
230
+ 'E_OPERATE_BINDING_MISMATCH',
231
+ 'Delivery classification cannot narrow accepted Artifact classification.',
232
+ );
101
233
  }
102
234
  }
103
235
 
104
236
  export {
105
- FORBIDDEN_KEY,
106
- FORBIDDEN_TEXT,
107
- PROTOCOL_VERSION,
108
237
  assertDeliveryClassification,
109
238
  assertNoSensitiveContext,
239
+ FORBIDDEN_KEY,
240
+ FORBIDDEN_TEXT,
110
241
  fail,
242
+ PROTOCOL_VERSION,
111
243
  sameHead,
112
244
  sameScope,
113
245
  without,
@@ -1,6 +1,17 @@
1
- export interface ResolvedProtocolSchema { kind: string; protocolVersion: string; path: string; schema: Record<string, unknown> }
2
- export interface ProtocolValidationError { path: string; rule: string; detail: string }
3
- export declare const PROTOCOL_SCHEMA_REGISTRY: Readonly<Record<string, Readonly<Record<string, string>>>>;
1
+ export interface ResolvedProtocolSchema {
2
+ kind: string;
3
+ protocolVersion: string;
4
+ path: string;
5
+ schema: Record<string, unknown>;
6
+ }
7
+ export interface ProtocolValidationError {
8
+ path: string;
9
+ rule: string;
10
+ detail: string;
11
+ }
12
+ export declare const PROTOCOL_SCHEMA_REGISTRY: Readonly<
13
+ Record<string, Readonly<Record<string, string>>>
14
+ >;
4
15
  export declare const OPERATE_EXPERIENCE_CONTRACT_KINDS_V2: readonly string[];
5
16
  export declare const OPERATING_DELIVERY_ROUTES_V1: readonly string[];
6
17
  export declare const OPERATE_ROLE_MANDATES_V2: readonly Readonly<Record<string, unknown>>[];
@@ -17,7 +28,7 @@ export declare const OPERATE_GOVERNED_PROVIDER_REGISTRATION_CONTRACT_KINDS_V2: r
17
28
  export declare const OPERATE_GOVERNED_EFFECT_CLASSES_V2: readonly string[];
18
29
  export declare const OPERATE_GOVERNED_POLICY_OUTCOMES_V2: readonly string[];
19
30
  export declare const OPERATE_GOVERNED_POLICY_TIERS_V2: readonly string[];
20
- export declare const OPERATE_GOVERNED_CORE_PROHIBITIONS_V2: readonly Readonly<Record<string, unknown>>[];
31
+ export declare const OPERATE_GOVERNED_CORE_PROHIBITIONS_V2: readonly string[];
21
32
  export declare const OPERATE_GOVERNED_RECOVERY_CLASSIFICATIONS_V2: readonly string[];
22
33
  export declare const OPERATE_GOVERNED_OPERATION_STATES_V2: readonly string[];
23
34
  export declare const OPERATE_GOVERNED_OPERATION_TERMINAL_STATES_V2: readonly string[];
@@ -26,17 +37,47 @@ export declare const OPERATE_HYPOTHESIS_VERIFICATION_STATUSES_V2: readonly strin
26
37
  export declare const OPERATE_GOVERNED_TOOL_OPERATIONS_V2: readonly string[];
27
38
  export declare const OPERATE_AUTHORITY_GUARD_IDS_V2: readonly string[];
28
39
  export declare const OPERATE_PUBLIC_DOMAIN_CONTRACT_BINDINGS_V2: Readonly<Record<string, unknown>>;
29
- export declare function findOperateCoreProhibitionV2(values: unknown): Readonly<Record<string, unknown>> | null;
40
+ /** The matching prohibition id, or null when the identifiers name none. */
41
+ export declare function findOperateCoreProhibitionV2(values: unknown): string | null;
30
42
  export declare function assertOperateIntelligencePlanContractV2<T>(value: T): T;
31
- export declare function loadOperateRoleMandateV2(roleId: string, options?: { roleVersion?: string }): Readonly<Record<string, unknown>>;
32
- export declare function assertOperateRoleOutputContractV2<T>(roleId: string, outputContract: T, options?: { roleVersion?: string }): T;
33
- export declare function listProtocolSchemas(): Array<{ kind: string; protocolVersion: string; path: string }>;
34
- export declare function resolveProtocolSchema(kind: string, options?: { protocolVersion?: string }): ResolvedProtocolSchema;
35
- export declare function resolveOperateExperienceSchemaV2(kind: string, options?: { protocolVersion?: string }): ResolvedProtocolSchema;
36
- export declare function validateProtocolArtifact(kind: string, value: unknown, options?: { protocolVersion?: string }): ProtocolValidationError[];
43
+ export declare function loadOperateRoleMandateV2(
44
+ roleId: string,
45
+ options?: { roleVersion?: string },
46
+ ): Readonly<Record<string, unknown>>;
47
+ /** The mandate's advertised output contract, with its shared schema path resolved. */
48
+ export declare function assertOperateRoleOutputContractV2(
49
+ roleId: string,
50
+ outputContract: unknown,
51
+ options?: { roleVersion?: string },
52
+ ): Record<string, unknown> & { path: string };
53
+ export declare function listProtocolSchemas(): Array<{
54
+ kind: string;
55
+ protocolVersion: string;
56
+ path: string;
57
+ }>;
58
+ export declare function resolveProtocolSchema(
59
+ kind: string,
60
+ options?: { protocolVersion?: string },
61
+ ): ResolvedProtocolSchema;
62
+ export declare function resolveOperateExperienceSchemaV2(
63
+ kind: string,
64
+ options?: { protocolVersion?: string },
65
+ ): ResolvedProtocolSchema;
66
+ export declare function validateProtocolArtifact(
67
+ kind: string,
68
+ value: unknown,
69
+ options?: { protocolVersion?: string },
70
+ ): ProtocolValidationError[];
37
71
  export declare function validateDashboardBootstrapV1(value: unknown): ProtocolValidationError[];
38
72
  export declare function assertDashboardBootstrapV1<T>(value: T): T;
39
- export declare function validateOperateExperienceArtifactV2(kind: string, value: unknown): ProtocolValidationError[];
73
+ export declare function validateOperateExperienceArtifactV2(
74
+ kind: string,
75
+ value: unknown,
76
+ ): ProtocolValidationError[];
40
77
  export declare function assertOperateExperienceArtifactV2<T>(kind: string, value: T): T;
41
- export declare function assertProtocolArtifact<T>(kind: string, value: T, options?: { protocolVersion?: string }): T;
78
+ export declare function assertProtocolArtifact<T>(
79
+ kind: string,
80
+ value: T,
81
+ options?: { protocolVersion?: string },
82
+ ): T;
42
83
  export declare function assertOperateGovernedExtensionRegistrationV2<T>(kind: string, value: T): T;