@openplanr/protocol 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dashboard/closed-json-contract.mjs +99 -109
- package/lib/dashboard/operate-experience-audit-display-contract.d.mts +128 -153
- package/lib/dashboard/operate-experience-audit-display-contract.mjs +530 -585
- package/lib/dashboard/operate-experience-display-contract.d.mts +415 -437
- package/lib/dashboard/operate-experience-display-contract.mjs +768 -831
- package/lib/dashboard/operate-experience-surface-contract.d.mts +143 -148
- package/lib/dashboard/operate-experience-surface-contract.mjs +72 -73
- package/lib/dashboard/operate-review-contract.d.mts +7 -14
- package/lib/dashboard/operate-review-contract.mjs +46 -42
- package/lib/dashboard/operate-review-display-workspace-contract.d.mts +2 -5
- package/lib/dashboard/operate-review-display-workspace-contract.mjs +158 -104
- package/lib/dashboard/operate-review-payload-safety.mjs +4 -2
- package/lib/dashboard/operate-review-workspace-projection-v2.d.mts +47 -33
- package/lib/protocol/index.d.ts +2647 -543
- package/package.json +1 -1
- package/registries/commands.json +3 -3
- package/registries/skills.json +5 -5
- package/src/browser-contracts.d.mts +4 -1
- package/src/browser-contracts.mjs +16 -5
- package/src/canonical-json.d.mts +3 -1
- package/src/canonical-json.mjs +57 -20
- package/src/compat/live-evidence-v2.mjs +1604 -485
- package/src/compat/operate-experience-live-patch.mjs +67 -15
- package/src/compat/operating-planning-contracts.mjs +183 -51
- package/src/contracts.d.mts +54 -13
- package/src/contracts.mjs +625 -335
- package/src/design-contracts.mjs +58 -21
- package/src/design-handoff-contracts.d.mts +67 -11
- package/src/design-handoff-contracts.mjs +243 -98
- package/src/design-publication-contracts.mjs +98 -33
- package/src/diagram-authoring-contracts.d.mts +422 -78
- package/src/diagram-authoring-contracts.mjs +1697 -326
- package/src/diagram-contracts.d.mts +4 -1
- package/src/diagram-contracts.mjs +16 -4
- package/src/enterprise-contracts.d.mts +211 -46
- package/src/enterprise-contracts.mjs +727 -175
- package/src/errors.mjs +4 -0
- package/src/generated/canonical-registries.mjs +8 -8
- package/src/index.d.mts +8 -8
- package/src/index.mjs +36 -20
- package/src/json-schema.d.mts +21 -6
- package/src/json-schema.mjs +66 -18
- package/src/planning-contracts.d.mts +8 -2
- package/src/planning-contracts.mjs +33 -7
- package/src/registries.d.mts +11 -3
- package/src/registries.mjs +369 -87
- package/src/review-experience-contracts.d.mts +7 -2
- package/src/review-experience-contracts.mjs +198 -49
- package/src/semver.mjs +5 -1
- package/src/skill-source-contracts.d.mts +36 -16
- package/src/skill-source-contracts.mjs +25 -6
- package/src/task-contracts.d.mts +13 -3
- package/src/task-contracts.mjs +181 -40
- package/src/workspace-contracts.d.mts +38 -10
- package/src/workspace-contracts.mjs +147 -33
|
@@ -1,1007 +1,944 @@
|
|
|
1
1
|
import { validateJson } from '../../src/json-schema.mjs';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from
|
|
3
|
+
contentHash,
|
|
4
|
+
deepFreeze,
|
|
5
|
+
exactEventHead,
|
|
6
|
+
exactJson,
|
|
7
|
+
jcsHash,
|
|
8
|
+
safeDataClone,
|
|
9
|
+
withoutContentHash,
|
|
10
|
+
} from './closed-json-contract.mjs';
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} from
|
|
32
|
-
import { assertOperateExperienceSurfaceV1 } from
|
|
33
|
-
|
|
34
|
-
const DISPLAY_SURFACE_DOMAIN =
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
"openplanr:operate-executive-board-display-surface:1.0.0";
|
|
40
|
-
export const ACTION_WORKSPACE_DOMAIN =
|
|
41
|
-
"openplanr:operate-action-display-workspace:1.0.0";
|
|
42
|
-
export const RECOVERY_DISPLAY_DOMAIN =
|
|
43
|
-
"openplanr:operate-recovery-display-surface:1.0.0";
|
|
12
|
+
OPERATE_ACTION_DISPLAY_WORKSPACE_SCHEMA as actionDisplayWorkspaceSchema,
|
|
13
|
+
OPERATE_ALLOWED_ACTION_SCHEMA as allowedActionSchema,
|
|
14
|
+
OPERATE_API_ENVELOPE_SCHEMA as apiEnvelopeSchema,
|
|
15
|
+
OPERATE_CYCLE_DISPLAY_WORKSPACE_SCHEMA as cycleDisplayWorkspaceSchema,
|
|
16
|
+
OPERATING_DELIVERY_ROUTE_SCHEMA as deliveryRouteSchema,
|
|
17
|
+
OPERATE_EXPERIENCE_DISPLAY_SURFACE_SCHEMA as displaySurfaceSchema,
|
|
18
|
+
OPERATING_EVIDENCE_RESOLUTION_SCHEMA as evidenceResolutionSchema,
|
|
19
|
+
OPERATING_EXECUTION_RESULT_SCHEMA as executionResultSchema,
|
|
20
|
+
OPERATE_EXECUTIVE_BOARD_DISPLAY_SURFACE_SCHEMA as executiveBoardDisplaySurfaceSchema,
|
|
21
|
+
OPERATE_EXPERIENCE_PREVIEW_SCHEMA as experiencePreviewSchema,
|
|
22
|
+
OPERATE_EXPERIENCE_VIEW_SCHEMA as experienceViewSchema,
|
|
23
|
+
OPERATING_FINDING_SCHEMA as findingSchema,
|
|
24
|
+
OPERATING_GOVERNED_OPERATION_SCHEMA as governedOperationSchema,
|
|
25
|
+
OPERATE_RECOVERY_DISPLAY_SURFACE_SCHEMA as recoveryDisplaySurfaceSchema,
|
|
26
|
+
OPERATING_REVIEW_SCHEMA as reviewSchema,
|
|
27
|
+
OPERATE_REVIEW_DISPLAY_WORKSPACE_SCHEMA as reviewWorkspaceSchema,
|
|
28
|
+
OPERATE_EXPERIENCE_SURFACE_SCHEMA as surfaceSchema,
|
|
29
|
+
OPERATING_TRACE_MATRIX_SCHEMA as traceMatrixSchema,
|
|
30
|
+
OPERATING_WORK_LEDGER_SCHEMA as workLedgerSchema,
|
|
31
|
+
} from './generated/operate-experience-surface-schema-data.mjs';
|
|
32
|
+
import { assertOperateExperienceSurfaceV1 } from './operate-experience-surface-contract.mjs';
|
|
33
|
+
|
|
34
|
+
const DISPLAY_SURFACE_DOMAIN = 'openplanr:operate-experience-display-surface:1.0.0';
|
|
35
|
+
const CYCLE_WORKSPACE_DOMAIN = 'openplanr:operate-cycle-display-workspace:1.0.0';
|
|
36
|
+
const EXECUTIVE_BOARD_DISPLAY_DOMAIN = 'openplanr:operate-executive-board-display-surface:1.0.0';
|
|
37
|
+
export const ACTION_WORKSPACE_DOMAIN = 'openplanr:operate-action-display-workspace:1.0.0';
|
|
38
|
+
export const RECOVERY_DISPLAY_DOMAIN = 'openplanr:operate-recovery-display-surface:1.0.0';
|
|
44
39
|
const ACTION_WORKSPACE_BOUNDARIES = Object.freeze({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
approvalExecution:
|
|
41
|
+
'Named approval satisfies only its exact version-bound requirement. Execution receives a fresh authority check.',
|
|
42
|
+
verification:
|
|
43
|
+
'Outcome verification remains separate. No success claim appears before accepted evidence.',
|
|
44
|
+
retry:
|
|
45
|
+
'An effect may have occurred. Only Inspect, Reconcile, custody restoration, or an explicit runtime recovery route is legal.',
|
|
51
46
|
});
|
|
52
|
-
const DISPLAY_SURFACES = new Set([
|
|
47
|
+
const DISPLAY_SURFACES = new Set(['today', 'inbox', 'cycles', 'cycle', 'actions']);
|
|
53
48
|
const STAGE_ORDER = Object.freeze([
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
'observe',
|
|
50
|
+
'understand',
|
|
51
|
+
'decide',
|
|
52
|
+
'govern',
|
|
53
|
+
'act',
|
|
54
|
+
'verify',
|
|
55
|
+
'learn',
|
|
61
56
|
]);
|
|
62
57
|
const ACTIVE_CYCLE_STAGE = Object.freeze({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
created: 0,
|
|
59
|
+
observing: 0,
|
|
60
|
+
advising: 1,
|
|
61
|
+
challenging: 1,
|
|
62
|
+
synthesizing: 1,
|
|
63
|
+
awaiting_review: 2,
|
|
64
|
+
approved: 3,
|
|
65
|
+
executing: 4,
|
|
66
|
+
verifying: 5,
|
|
67
|
+
closed: 6,
|
|
68
|
+
blocked: 0,
|
|
69
|
+
failed: 0,
|
|
70
|
+
cancelled: 0,
|
|
76
71
|
});
|
|
77
72
|
const CYCLE_STATES = new Set([
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
]);
|
|
84
|
-
const CYCLE_HEALTH = new Set(["normal", "quiet", "partial", "blocked"]);
|
|
85
|
-
const PERSISTENT_RELATIONS = Object.freeze([
|
|
86
|
-
"source",
|
|
87
|
-
"touched",
|
|
88
|
-
"carried-forward",
|
|
73
|
+
...Object.keys(ACTIVE_CYCLE_STAGE),
|
|
74
|
+
'closed',
|
|
75
|
+
'blocked',
|
|
76
|
+
'failed',
|
|
77
|
+
'cancelled',
|
|
89
78
|
]);
|
|
79
|
+
const CYCLE_HEALTH = new Set(['normal', 'quiet', 'partial', 'blocked']);
|
|
80
|
+
const PERSISTENT_RELATIONS = Object.freeze(['source', 'touched', 'carried-forward']);
|
|
90
81
|
const PERSISTENT_ID = Object.freeze({
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
finding: /^fnd_[A-Za-z0-9][A-Za-z0-9._-]{7,127}$/u,
|
|
83
|
+
decision: /^dec_[A-Za-z0-9][A-Za-z0-9._-]{7,127}$/u,
|
|
84
|
+
action: /^act_[A-Za-z0-9][A-Za-z0-9._-]{7,127}$/u,
|
|
94
85
|
});
|
|
95
86
|
const PERSISTENT_STATE = Object.freeze({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
"superseded",
|
|
110
|
-
]),
|
|
111
|
-
action: new Set([
|
|
112
|
-
"proposed",
|
|
113
|
-
"approved",
|
|
114
|
-
"queued",
|
|
115
|
-
"in_progress",
|
|
116
|
-
"completed",
|
|
117
|
-
"blocked",
|
|
118
|
-
"rejected",
|
|
119
|
-
"deferred",
|
|
120
|
-
"cancelled",
|
|
121
|
-
]),
|
|
87
|
+
finding: new Set(['open', 'accepted', 'resolved', 'rejected', 'deferred', 'superseded']),
|
|
88
|
+
decision: new Set(['proposed', 'approved', 'rejected', 'deferred', 'superseded']),
|
|
89
|
+
action: new Set([
|
|
90
|
+
'proposed',
|
|
91
|
+
'approved',
|
|
92
|
+
'queued',
|
|
93
|
+
'in_progress',
|
|
94
|
+
'completed',
|
|
95
|
+
'blocked',
|
|
96
|
+
'rejected',
|
|
97
|
+
'deferred',
|
|
98
|
+
'cancelled',
|
|
99
|
+
]),
|
|
122
100
|
});
|
|
123
101
|
|
|
124
102
|
const schemas = new Map([
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
103
|
+
['operate-experience-display-surface.schema.json', displaySurfaceSchema],
|
|
104
|
+
['operate-action-display-workspace.schema.json', actionDisplayWorkspaceSchema],
|
|
105
|
+
['operate-cycle-display-workspace.schema.json', cycleDisplayWorkspaceSchema],
|
|
106
|
+
['operate-executive-board-display-surface.schema.json', executiveBoardDisplaySurfaceSchema],
|
|
107
|
+
['operate-recovery-display-surface.schema.json', recoveryDisplaySurfaceSchema],
|
|
108
|
+
['operate-experience-surface.schema.json', surfaceSchema],
|
|
109
|
+
['operate-experience-view.schema.json', experienceViewSchema],
|
|
110
|
+
['operate-review-display-workspace.schema.json', reviewWorkspaceSchema],
|
|
111
|
+
['operating-finding.schema.json', findingSchema],
|
|
112
|
+
['operate-experience-preview.schema.json', experiencePreviewSchema],
|
|
113
|
+
['operate-api-envelope.schema.json', apiEnvelopeSchema],
|
|
114
|
+
['operate-allowed-action.schema.json', allowedActionSchema],
|
|
115
|
+
['operating-work-ledger.schema.json', workLedgerSchema],
|
|
116
|
+
['operating-delivery-route.schema.json', deliveryRouteSchema],
|
|
117
|
+
['operating-evidence-resolution.schema.json', evidenceResolutionSchema],
|
|
118
|
+
['operating-execution-result.schema.json', executionResultSchema],
|
|
119
|
+
['operating-governed-operation.schema.json', governedOperationSchema],
|
|
120
|
+
['operating-review.schema.json', reviewSchema],
|
|
121
|
+
['operating-trace-matrix.schema.json', traceMatrixSchema],
|
|
144
122
|
]);
|
|
145
123
|
|
|
146
124
|
function jsonPointer(root, fragment) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
125
|
+
if (!fragment || fragment === '#') return root;
|
|
126
|
+
if (!fragment.startsWith('#/')) return null;
|
|
127
|
+
return fragment
|
|
128
|
+
.slice(2)
|
|
129
|
+
.split('/')
|
|
130
|
+
.map((part) => part.replaceAll('~1', '/').replaceAll('~0', '~'))
|
|
131
|
+
.reduce((value, part) => value?.[part], root);
|
|
154
132
|
}
|
|
155
133
|
|
|
156
134
|
function resolveSchemaRef(reference) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
135
|
+
const [path, pointer = ''] = reference.split('#');
|
|
136
|
+
const filename = path.split('/').at(-1);
|
|
137
|
+
const rootSchema = schemas.get(filename);
|
|
138
|
+
if (!rootSchema) return null;
|
|
139
|
+
return {
|
|
140
|
+
schema: jsonPointer(rootSchema, pointer ? `#${pointer}` : '#'),
|
|
141
|
+
rootSchema,
|
|
142
|
+
base: filename,
|
|
143
|
+
};
|
|
166
144
|
}
|
|
167
145
|
|
|
168
146
|
function validationFailure() {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
147
|
+
return [
|
|
148
|
+
{
|
|
149
|
+
path: '$',
|
|
150
|
+
rule: 'closedContract',
|
|
151
|
+
detail: 'does not satisfy the closed display contract',
|
|
152
|
+
},
|
|
153
|
+
];
|
|
176
154
|
}
|
|
177
155
|
|
|
178
156
|
function exactKeys(value, keys) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return actual.length === keys.length && keys.every((key) => actual.includes(key));
|
|
157
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) return false;
|
|
158
|
+
const actual = Object.keys(value);
|
|
159
|
+
return actual.length === keys.length && keys.every((key) => actual.includes(key));
|
|
183
160
|
}
|
|
184
161
|
|
|
185
162
|
function exactExpectedBinding(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
163
|
+
payload,
|
|
164
|
+
expected,
|
|
165
|
+
{ workspace = false, executiveBoard = false, action = false, recovery = false } = {},
|
|
189
166
|
) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return (
|
|
245
|
-
expected.cycleId === payload.data.cycle.cycleId &&
|
|
246
|
-
expected.subjectId === payload.data.cycle.cycleId
|
|
247
|
-
);
|
|
167
|
+
if (!expected) return true;
|
|
168
|
+
if (
|
|
169
|
+
payload.actorId !== expected.actorId ||
|
|
170
|
+
payload.scopeId !== expected.scopeId ||
|
|
171
|
+
payload.domainId !== expected.domainId ||
|
|
172
|
+
payload.domainVersion !== expected.domainVersion ||
|
|
173
|
+
payload.generatedAt !== expected.generatedAt ||
|
|
174
|
+
payload.viewHash !== expected.viewHash ||
|
|
175
|
+
!exactEventHead(payload.eventHead, expected.eventHead)
|
|
176
|
+
)
|
|
177
|
+
return false;
|
|
178
|
+
if (!workspace) {
|
|
179
|
+
if (expected.surface !== undefined && payload.surface !== expected.surface) return false;
|
|
180
|
+
if (payload.surface === 'inbox' || payload.surface === 'actions') {
|
|
181
|
+
return (
|
|
182
|
+
expected.surface === payload.surface &&
|
|
183
|
+
typeof expected.projectId === 'string' &&
|
|
184
|
+
Number.isSafeInteger(expected.generation) &&
|
|
185
|
+
payload.data.requestBinding.projectId === expected.projectId &&
|
|
186
|
+
payload.data.requestBinding.generation === expected.generation &&
|
|
187
|
+
(payload.surface !== 'inbox' ||
|
|
188
|
+
payload.data.requestBinding.subjectId === expected.subjectId) &&
|
|
189
|
+
(payload.surface !== 'actions' ||
|
|
190
|
+
(expected.subjectId === null &&
|
|
191
|
+
typeof expected.cycleId === 'string' &&
|
|
192
|
+
expected.cycleId.length > 0))
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
if (payload.surface === 'cycle') {
|
|
196
|
+
const committedCycleId = payload.data.cycle.cycleId;
|
|
197
|
+
if (
|
|
198
|
+
typeof expected.subjectId !== 'string' ||
|
|
199
|
+
typeof expected.cycleId !== 'string' ||
|
|
200
|
+
expected.subjectId !== committedCycleId ||
|
|
201
|
+
expected.cycleId !== committedCycleId
|
|
202
|
+
)
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
if (executiveBoard) {
|
|
208
|
+
return expected.cycleId === payload.data.cycleId && expected.subjectId === payload.data.cycleId;
|
|
209
|
+
}
|
|
210
|
+
if (action) {
|
|
211
|
+
return (
|
|
212
|
+
expected.subjectId === payload.data.action.actionId &&
|
|
213
|
+
expected.actionId === payload.data.action.actionId
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
if (recovery) return true;
|
|
217
|
+
return (
|
|
218
|
+
expected.cycleId === payload.data.cycle.cycleId &&
|
|
219
|
+
expected.subjectId === payload.data.cycle.cycleId
|
|
220
|
+
);
|
|
248
221
|
}
|
|
249
222
|
|
|
250
223
|
function validCycleLifecycle(cycle) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
224
|
+
if (
|
|
225
|
+
!cycle ||
|
|
226
|
+
typeof cycle !== 'object' ||
|
|
227
|
+
!CYCLE_STATES.has(cycle.state) ||
|
|
228
|
+
!CYCLE_HEALTH.has(cycle.health) ||
|
|
229
|
+
!Array.isArray(cycle.stages) ||
|
|
230
|
+
cycle.stages.length !== STAGE_ORDER.length ||
|
|
231
|
+
!cycle.stages.every((stage, index) => stage.id === STAGE_ORDER[index])
|
|
232
|
+
)
|
|
233
|
+
return false;
|
|
234
|
+
const current = ACTIVE_CYCLE_STAGE[cycle.state];
|
|
235
|
+
return cycle.stages.every((stage, index) => {
|
|
236
|
+
let expected = index < current ? 'complete' : index === current ? 'current' : 'waiting';
|
|
237
|
+
if (cycle.state === 'closed') expected = 'complete';
|
|
238
|
+
if (index === current && ['blocked', 'failed'].includes(cycle.state)) {
|
|
239
|
+
expected = cycle.state;
|
|
240
|
+
}
|
|
241
|
+
if (index === current && cycle.state === 'cancelled') expected = 'skipped';
|
|
242
|
+
const reason = ['blocked', 'failed', 'skipped'].includes(expected)
|
|
243
|
+
? `Cycle is ${cycle.state}.`
|
|
244
|
+
: null;
|
|
245
|
+
return stage.state === expected && stage.reason === reason;
|
|
246
|
+
});
|
|
274
247
|
}
|
|
275
248
|
|
|
276
249
|
function validDisplaySurfaceSemantics(value, expected) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
);
|
|
250
|
+
const payload = value.payload;
|
|
251
|
+
if (
|
|
252
|
+
!DISPLAY_SURFACES.has(payload.surface) ||
|
|
253
|
+
value.integrity.sourceViewHash !== payload.viewHash ||
|
|
254
|
+
payload.truthSummary.sourceViewHash !== payload.viewHash ||
|
|
255
|
+
!exactEventHead(payload.truthSummary.sourceEventHead, payload.eventHead) ||
|
|
256
|
+
!exactExpectedBinding(payload, expected)
|
|
257
|
+
)
|
|
258
|
+
return false;
|
|
259
|
+
if (payload.surface === 'inbox') {
|
|
260
|
+
const items = payload.data.inbox;
|
|
261
|
+
const subjectId = payload.data.requestBinding.subjectId;
|
|
262
|
+
return (
|
|
263
|
+
Array.isArray(items) &&
|
|
264
|
+
new Set(items.map((item) => item.itemId)).size === items.length &&
|
|
265
|
+
(subjectId === null || (items.length === 1 && items[0].itemId === subjectId)) &&
|
|
266
|
+
items.every(
|
|
267
|
+
(item, index) =>
|
|
268
|
+
index === 0 ||
|
|
269
|
+
Number(items[index - 1].blocking) > Number(item.blocking) ||
|
|
270
|
+
(Number(items[index - 1].blocking) === Number(item.blocking) &&
|
|
271
|
+
items[index - 1].itemId.localeCompare(item.itemId) < 0),
|
|
272
|
+
)
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
if (payload.surface === 'actions') {
|
|
276
|
+
const items = payload.data.actions;
|
|
277
|
+
return (
|
|
278
|
+
Array.isArray(items) && new Set(items.map((item) => item.actionId)).size === items.length
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
const cycles =
|
|
282
|
+
payload.surface === 'today'
|
|
283
|
+
? payload.data.activeCycle === null
|
|
284
|
+
? []
|
|
285
|
+
: [payload.data.activeCycle]
|
|
286
|
+
: payload.surface === 'cycles'
|
|
287
|
+
? payload.data.cycles
|
|
288
|
+
: [payload.data.cycle];
|
|
289
|
+
return (
|
|
290
|
+
new Set(cycles.map((cycle) => cycle.cycleId)).size === cycles.length &&
|
|
291
|
+
cycles.every(validCycleLifecycle)
|
|
292
|
+
);
|
|
321
293
|
}
|
|
322
294
|
|
|
323
295
|
function validPersistentItem(value, kind) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
296
|
+
return (
|
|
297
|
+
exactKeys(value, ['kind', 'subjectId', 'state', 'relations']) &&
|
|
298
|
+
value.kind === kind &&
|
|
299
|
+
typeof value.subjectId === 'string' &&
|
|
300
|
+
PERSISTENT_ID[kind].test(value.subjectId) &&
|
|
301
|
+
typeof value.state === 'string' &&
|
|
302
|
+
PERSISTENT_STATE[kind].has(value.state) &&
|
|
303
|
+
Array.isArray(value.relations) &&
|
|
304
|
+
value.relations.length >= 1 &&
|
|
305
|
+
value.relations.length <= PERSISTENT_RELATIONS.length &&
|
|
306
|
+
value.relations.every((relation) => PERSISTENT_RELATIONS.includes(relation)) &&
|
|
307
|
+
new Set(value.relations).size === value.relations.length
|
|
308
|
+
);
|
|
337
309
|
}
|
|
338
310
|
|
|
339
311
|
function validCycleLink(value) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
312
|
+
return (
|
|
313
|
+
exactKeys(value, ['entityKind', 'entityId', 'cycleId', 'relation']) &&
|
|
314
|
+
PERSISTENT_ID[value.entityKind]?.test(value.entityId) === true &&
|
|
315
|
+
typeof value.cycleId === 'string' &&
|
|
316
|
+
PERSISTENT_RELATIONS.includes(value.relation)
|
|
317
|
+
);
|
|
346
318
|
}
|
|
347
319
|
|
|
348
320
|
function validPersistentGraph(persistent, cycleId) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
exactJson(
|
|
373
|
-
item.relations,
|
|
374
|
-
persistent.cycleLinks
|
|
375
|
-
.filter(
|
|
376
|
-
(link) =>
|
|
377
|
-
link.entityKind === item.kind && link.entityId === item.subjectId,
|
|
378
|
-
)
|
|
379
|
-
.map((link) => link.relation),
|
|
380
|
-
),
|
|
381
|
-
);
|
|
321
|
+
const items = [...persistent.findings, ...persistent.decisions, ...persistent.actions];
|
|
322
|
+
const itemKeys = items.map((item) => `${item.kind}:${item.subjectId}`);
|
|
323
|
+
const linkKeys = persistent.cycleLinks.map(
|
|
324
|
+
(link) => `${link.entityKind}:${link.entityId}:${link.cycleId}:${link.relation}`,
|
|
325
|
+
);
|
|
326
|
+
if (
|
|
327
|
+
new Set(itemKeys).size !== itemKeys.length ||
|
|
328
|
+
new Set(linkKeys).size !== linkKeys.length ||
|
|
329
|
+
persistent.cycleLinks.some(
|
|
330
|
+
(link) =>
|
|
331
|
+
link.cycleId !== cycleId ||
|
|
332
|
+
!items.some((item) => item.kind === link.entityKind && item.subjectId === link.entityId),
|
|
333
|
+
)
|
|
334
|
+
)
|
|
335
|
+
return false;
|
|
336
|
+
return items.every((item) =>
|
|
337
|
+
exactJson(
|
|
338
|
+
item.relations,
|
|
339
|
+
persistent.cycleLinks
|
|
340
|
+
.filter((link) => link.entityKind === item.kind && link.entityId === item.subjectId)
|
|
341
|
+
.map((link) => link.relation),
|
|
342
|
+
),
|
|
343
|
+
);
|
|
382
344
|
}
|
|
383
345
|
|
|
384
346
|
function validAllowedAction(value, cycleId) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
347
|
+
return (
|
|
348
|
+
exactKeys(value, ['tool', 'arguments', 'label', 'effect']) &&
|
|
349
|
+
value.tool === 'operate.cycle.get' &&
|
|
350
|
+
exactKeys(value.arguments, ['cycleId']) &&
|
|
351
|
+
value.arguments.cycleId === cycleId &&
|
|
352
|
+
typeof value.label === 'string' &&
|
|
353
|
+
value.label.length > 0 &&
|
|
354
|
+
value.label.length <= 256 &&
|
|
355
|
+
!/(?:<[^>]+>|\{\{[^}]+\}\})/u.test(value.label) &&
|
|
356
|
+
value.effect === 'read-only'
|
|
357
|
+
);
|
|
396
358
|
}
|
|
397
359
|
|
|
398
360
|
function outcomeCarriesAffirmativeProof(outcome) {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
361
|
+
const verification = outcome.verification;
|
|
362
|
+
const metric = outcome.metric;
|
|
363
|
+
return (
|
|
364
|
+
['succeeded', 'failed'].includes(outcome.status) &&
|
|
365
|
+
outcome.accessReason === null &&
|
|
366
|
+
outcome.observationIds.length > 0 &&
|
|
367
|
+
outcome.evidenceRefIds.length > 0 &&
|
|
368
|
+
metric !== null &&
|
|
369
|
+
metric.observed !== null &&
|
|
370
|
+
metric.freshness === 'current' &&
|
|
371
|
+
verification !== null &&
|
|
372
|
+
verification.accessReason === null &&
|
|
373
|
+
outcome.verificationPlanId === verification.verificationPlanId &&
|
|
374
|
+
metric.metricId === verification.metricId &&
|
|
375
|
+
metric.metricHash === verification.metricHash
|
|
376
|
+
);
|
|
415
377
|
}
|
|
416
378
|
|
|
417
379
|
function validOutcomeLearningGraph(persistent, cycle, verification, truthSummary) {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
verification.status === expected &&
|
|
442
|
-
exactJson(verification.reasonCodes, reasonCodes)
|
|
443
|
-
);
|
|
380
|
+
const actionIds = persistent.actions.map((action) => action.subjectId);
|
|
381
|
+
const outcomeIds = persistent.outcomes.map((outcome) => outcome.outcomeId);
|
|
382
|
+
const learningIds = persistent.learnings.map((learning) => learning.learningId);
|
|
383
|
+
if (
|
|
384
|
+
new Set(outcomeIds).size !== outcomeIds.length ||
|
|
385
|
+
new Set(learningIds).size !== learningIds.length ||
|
|
386
|
+
persistent.outcomes.some((outcome) => !actionIds.includes(outcome.actionId)) ||
|
|
387
|
+
persistent.learnings.some((learning) => !outcomeIds.includes(learning.outcomeId))
|
|
388
|
+
)
|
|
389
|
+
return false;
|
|
390
|
+
const expected =
|
|
391
|
+
truthSummary.proof.status === 'verified'
|
|
392
|
+
? 'verified'
|
|
393
|
+
: truthSummary.proof.status === 'not-required'
|
|
394
|
+
? 'not-required'
|
|
395
|
+
: 'unverified';
|
|
396
|
+
const reasonCodes =
|
|
397
|
+
expected === 'unverified'
|
|
398
|
+
? truthSummary.proof.reasonCodes.length > 0
|
|
399
|
+
? truthSummary.proof.reasonCodes
|
|
400
|
+
: ['OPERATE_VERIFICATION_EVIDENCE_MISSING']
|
|
401
|
+
: [];
|
|
402
|
+
return verification.status === expected && exactJson(verification.reasonCodes, reasonCodes);
|
|
444
403
|
}
|
|
445
404
|
|
|
446
405
|
function workspaceSurface(payload, surface, data) {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
406
|
+
return {
|
|
407
|
+
ok: true,
|
|
408
|
+
kind: 'operate-experience-surface',
|
|
409
|
+
schemaVersion: '1.0.0',
|
|
410
|
+
protocolVersion: payload.protocolVersion,
|
|
411
|
+
surface,
|
|
412
|
+
readOnly: true,
|
|
413
|
+
mutationEnabled: payload.status === 'ready',
|
|
414
|
+
scopeId: payload.scopeId,
|
|
415
|
+
domainId: payload.domainId,
|
|
416
|
+
domainVersion: payload.domainVersion,
|
|
417
|
+
actorId: payload.actorId,
|
|
418
|
+
accessLevel: payload.accessLevel,
|
|
419
|
+
generatedAt: payload.generatedAt,
|
|
420
|
+
eventHead: payload.eventHead,
|
|
421
|
+
viewHash: payload.viewHash,
|
|
422
|
+
truthSummary: payload.truthSummary,
|
|
423
|
+
status: payload.status,
|
|
424
|
+
reasonCodes: payload.reasonCodes,
|
|
425
|
+
data,
|
|
426
|
+
};
|
|
468
427
|
}
|
|
469
428
|
|
|
470
429
|
function validWorkspacePayload(payload) {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
validOutcomeLearningGraph(
|
|
558
|
-
data.persistentWork,
|
|
559
|
-
cycle,
|
|
560
|
-
data.verification,
|
|
561
|
-
payload.truthSummary,
|
|
562
|
-
) &&
|
|
563
|
-
validAllowedAction(data.allowedActions[0], cycle.cycleId)
|
|
564
|
-
);
|
|
565
|
-
} catch {
|
|
566
|
-
return false;
|
|
567
|
-
}
|
|
430
|
+
const data = payload.data;
|
|
431
|
+
if (
|
|
432
|
+
!exactKeys(data.ownerCycle, [
|
|
433
|
+
'cycleId',
|
|
434
|
+
'scopeId',
|
|
435
|
+
'domainId',
|
|
436
|
+
'domainVersion',
|
|
437
|
+
'state',
|
|
438
|
+
'health',
|
|
439
|
+
'focus',
|
|
440
|
+
'createdAt',
|
|
441
|
+
'updatedAt',
|
|
442
|
+
]) ||
|
|
443
|
+
!Array.isArray(data.persistentWork.findings) ||
|
|
444
|
+
!data.persistentWork.findings.every((item) => validPersistentItem(item, 'finding')) ||
|
|
445
|
+
!Array.isArray(data.persistentWork.decisions) ||
|
|
446
|
+
!data.persistentWork.decisions.every((item) => validPersistentItem(item, 'decision')) ||
|
|
447
|
+
!Array.isArray(data.persistentWork.actions) ||
|
|
448
|
+
!data.persistentWork.actions.every((item) => validPersistentItem(item, 'action')) ||
|
|
449
|
+
!Array.isArray(data.persistentWork.cycleLinks) ||
|
|
450
|
+
!data.persistentWork.cycleLinks.every(validCycleLink) ||
|
|
451
|
+
!Array.isArray(data.persistentWork.outcomes) ||
|
|
452
|
+
!Array.isArray(data.persistentWork.learnings) ||
|
|
453
|
+
data.allowedActions.length !== 1
|
|
454
|
+
)
|
|
455
|
+
return false;
|
|
456
|
+
try {
|
|
457
|
+
const cycle = data.cycle;
|
|
458
|
+
const schemaCycle = {
|
|
459
|
+
...cycle,
|
|
460
|
+
assignments: cycle.assignments.map((assignment) =>
|
|
461
|
+
assignment.deepLink === null ? { ...assignment, deepLink: cycle.deepLink } : assignment,
|
|
462
|
+
),
|
|
463
|
+
};
|
|
464
|
+
const schemaOutcomes = data.persistentWork.outcomes.map((outcome) =>
|
|
465
|
+
outcome.deepLink === null
|
|
466
|
+
? {
|
|
467
|
+
...outcome,
|
|
468
|
+
deepLink: `#/operate/outcomes/${encodeURIComponent(outcome.outcomeId)}`,
|
|
469
|
+
}
|
|
470
|
+
: outcome,
|
|
471
|
+
);
|
|
472
|
+
assertOperateExperienceSurfaceV1(workspaceSurface(payload, 'cycle', { cycle: schemaCycle }));
|
|
473
|
+
assertOperateExperienceSurfaceV1(
|
|
474
|
+
workspaceSurface(payload, 'outcomes', {
|
|
475
|
+
domainMetrics: [],
|
|
476
|
+
outcomes: schemaOutcomes,
|
|
477
|
+
learnings: data.persistentWork.learnings,
|
|
478
|
+
}),
|
|
479
|
+
);
|
|
480
|
+
assertOperateExperienceSurfaceV1(
|
|
481
|
+
workspaceSurface(payload, 'history', {
|
|
482
|
+
history: [],
|
|
483
|
+
replay: data.replay,
|
|
484
|
+
}),
|
|
485
|
+
);
|
|
486
|
+
const sourceActionIds = data.persistentWork.actions
|
|
487
|
+
.filter((action) => action.relations.includes('source'))
|
|
488
|
+
.map((action) => action.subjectId);
|
|
489
|
+
return (
|
|
490
|
+
validCycleLifecycle(cycle) &&
|
|
491
|
+
data.ownerCycle.cycleId === cycle.cycleId &&
|
|
492
|
+
data.ownerCycle.scopeId === payload.scopeId &&
|
|
493
|
+
data.ownerCycle.domainId === payload.domainId &&
|
|
494
|
+
data.ownerCycle.domainVersion === payload.domainVersion &&
|
|
495
|
+
data.ownerCycle.state === cycle.state &&
|
|
496
|
+
data.ownerCycle.health === cycle.health &&
|
|
497
|
+
exactJson(data.ownerCycle.focus, cycle.focus) &&
|
|
498
|
+
data.ownerCycle.createdAt === cycle.createdAt &&
|
|
499
|
+
data.ownerCycle.updatedAt === cycle.updatedAt &&
|
|
500
|
+
cycle.deepLink === `#/operate/cycles/${encodeURIComponent(cycle.cycleId)}` &&
|
|
501
|
+
exactEventHead(data.replay.finalHead, payload.eventHead) &&
|
|
502
|
+
exactJson(cycle.replayCheckpoint, data.replay.checkpoint) &&
|
|
503
|
+
exactJson(cycle.persistentActionIds, sourceActionIds) &&
|
|
504
|
+
validPersistentGraph(data.persistentWork, cycle.cycleId) &&
|
|
505
|
+
validOutcomeLearningGraph(
|
|
506
|
+
data.persistentWork,
|
|
507
|
+
cycle,
|
|
508
|
+
data.verification,
|
|
509
|
+
payload.truthSummary,
|
|
510
|
+
) &&
|
|
511
|
+
validAllowedAction(data.allowedActions[0], cycle.cycleId)
|
|
512
|
+
);
|
|
513
|
+
} catch {
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
568
516
|
}
|
|
569
517
|
|
|
570
518
|
function validWorkspaceSemantics(value, expected) {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
519
|
+
return (
|
|
520
|
+
value.integrity.sourceViewHash === value.payload.viewHash &&
|
|
521
|
+
value.payload.truthSummary.sourceViewHash === value.payload.viewHash &&
|
|
522
|
+
exactEventHead(value.payload.truthSummary.sourceEventHead, value.payload.eventHead) &&
|
|
523
|
+
exactExpectedBinding(value.payload, expected, { workspace: true }) &&
|
|
524
|
+
validWorkspacePayload(value.payload)
|
|
525
|
+
);
|
|
578
526
|
}
|
|
579
527
|
|
|
580
528
|
function validateDisplay(value, schema, base, semantics, expected) {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
return clone.integrity.contentHash === expectedHash
|
|
594
|
-
? []
|
|
595
|
-
: validationFailure();
|
|
596
|
-
} catch {
|
|
597
|
-
return validationFailure();
|
|
598
|
-
}
|
|
529
|
+
try {
|
|
530
|
+
const clone = safeDataClone(value);
|
|
531
|
+
const errors = validateJson(clone, schema, {
|
|
532
|
+
base,
|
|
533
|
+
resolveRef: resolveSchemaRef,
|
|
534
|
+
});
|
|
535
|
+
if (errors.length > 0 || !semantics(clone, expected)) return validationFailure();
|
|
536
|
+
const expectedHash = contentHash(withoutContentHash(clone), clone.integrity.domain);
|
|
537
|
+
return clone.integrity.contentHash === expectedHash ? [] : validationFailure();
|
|
538
|
+
} catch {
|
|
539
|
+
return validationFailure();
|
|
540
|
+
}
|
|
599
541
|
}
|
|
600
542
|
|
|
601
543
|
export function validateOperateExperienceDisplaySurfaceV1(value, expected) {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
544
|
+
return validateDisplay(
|
|
545
|
+
value,
|
|
546
|
+
displaySurfaceSchema,
|
|
547
|
+
'schemas/v1.2.0/operate-experience-display-surface.schema.json',
|
|
548
|
+
validDisplaySurfaceSemantics,
|
|
549
|
+
expected,
|
|
550
|
+
);
|
|
609
551
|
}
|
|
610
552
|
|
|
611
553
|
export function assertOperateExperienceDisplaySurfaceV1(value, expected) {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
554
|
+
if (validateOperateExperienceDisplaySurfaceV1(value, expected).length > 0) {
|
|
555
|
+
const error = new TypeError(
|
|
556
|
+
'The Operate display surface does not satisfy its closed integrity contract.',
|
|
557
|
+
);
|
|
558
|
+
error.code = 'E_OPERATE_EXPERIENCE_DISPLAY_INVALID';
|
|
559
|
+
throw error;
|
|
560
|
+
}
|
|
561
|
+
return value;
|
|
620
562
|
}
|
|
621
563
|
|
|
622
564
|
function exactExpectedPreview(value, expected) {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
565
|
+
if (!expected) return true;
|
|
566
|
+
return (
|
|
567
|
+
value.actorId === expected.actorId &&
|
|
568
|
+
value.scopeId === expected.scopeId &&
|
|
569
|
+
value.domainId === expected.domainId &&
|
|
570
|
+
value.domainVersion === expected.domainVersion &&
|
|
571
|
+
exactEventHead(value.eventHead, expected.eventHead) &&
|
|
572
|
+
value.sourceViewHash === expected.sourceViewHash &&
|
|
573
|
+
value.subject.id === expected.subjectId &&
|
|
574
|
+
value.actionDigest === expected.actionDigest
|
|
575
|
+
);
|
|
634
576
|
}
|
|
635
577
|
|
|
636
578
|
function validPreviewTransition(transition) {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
579
|
+
if (
|
|
580
|
+
new Set(transition.targets.map((target) => `${target.kind}:${target.id}`)).size !==
|
|
581
|
+
transition.targets.length
|
|
582
|
+
)
|
|
583
|
+
return false;
|
|
584
|
+
if (transition.kind !== 'approval') return transition.threshold === null;
|
|
585
|
+
const threshold = transition.threshold;
|
|
586
|
+
if (
|
|
587
|
+
threshold === null ||
|
|
588
|
+
threshold.recorded > threshold.required ||
|
|
589
|
+
threshold.remaining !== threshold.required - threshold.recorded
|
|
590
|
+
)
|
|
591
|
+
return false;
|
|
592
|
+
return threshold.remaining === 0
|
|
593
|
+
? transition.nextState === 'threshold-satisfied'
|
|
594
|
+
: transition.nextState === 'recorded-parties-remain';
|
|
651
595
|
}
|
|
652
596
|
|
|
653
597
|
export function validateOperateExperiencePreviewV1(value, expected) {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}
|
|
598
|
+
try {
|
|
599
|
+
const clone = safeDataClone(value);
|
|
600
|
+
const errors = validateJson(clone, experiencePreviewSchema, {
|
|
601
|
+
base: 'schemas/v2.0.0/operate-experience-preview.schema.json',
|
|
602
|
+
resolveRef: resolveSchemaRef,
|
|
603
|
+
});
|
|
604
|
+
if (
|
|
605
|
+
errors.length > 0 ||
|
|
606
|
+
!exactExpectedPreview(clone, expected) ||
|
|
607
|
+
!validPreviewTransition(clone.transition)
|
|
608
|
+
)
|
|
609
|
+
return errors.length > 0 ? errors : validationFailure();
|
|
610
|
+
const base = safeDataClone(clone);
|
|
611
|
+
delete base.previewHash;
|
|
612
|
+
if (clone.actionDigest !== jcsHash(clone.allowedAction) || clone.previewHash !== jcsHash(base))
|
|
613
|
+
return validationFailure();
|
|
614
|
+
return [];
|
|
615
|
+
} catch {
|
|
616
|
+
return validationFailure();
|
|
617
|
+
}
|
|
675
618
|
}
|
|
676
619
|
|
|
677
620
|
export function assertOperateExperiencePreviewV1(value, expected) {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
621
|
+
if (validateOperateExperiencePreviewV1(value, expected).length > 0) {
|
|
622
|
+
const error = new TypeError(
|
|
623
|
+
'The Operate preview does not satisfy its closed integrity contract.',
|
|
624
|
+
);
|
|
625
|
+
error.code = 'E_OPERATE_EXPERIENCE_PREVIEW_INVALID';
|
|
626
|
+
throw error;
|
|
627
|
+
}
|
|
628
|
+
return deepFreeze(safeDataClone(value));
|
|
686
629
|
}
|
|
687
630
|
|
|
688
631
|
export function validateOperateCycleDisplayWorkspaceV1(value, expected) {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
632
|
+
return validateDisplay(
|
|
633
|
+
value,
|
|
634
|
+
cycleDisplayWorkspaceSchema,
|
|
635
|
+
'schemas/v1.2.0/operate-cycle-display-workspace.schema.json',
|
|
636
|
+
validWorkspaceSemantics,
|
|
637
|
+
expected,
|
|
638
|
+
);
|
|
696
639
|
}
|
|
697
640
|
|
|
698
641
|
export function assertOperateCycleDisplayWorkspaceV1(value, expected) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
642
|
+
if (validateOperateCycleDisplayWorkspaceV1(value, expected).length > 0) {
|
|
643
|
+
const error = new TypeError(
|
|
644
|
+
'The Cycle display workspace does not satisfy its closed integrity contract.',
|
|
645
|
+
);
|
|
646
|
+
error.code = 'E_OPERATE_CYCLE_DISPLAY_INVALID';
|
|
647
|
+
throw error;
|
|
648
|
+
}
|
|
649
|
+
return value;
|
|
707
650
|
}
|
|
708
651
|
|
|
709
652
|
function issueDisplay(kind, domain, payload, assertIssued) {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
653
|
+
const base = {
|
|
654
|
+
kind,
|
|
655
|
+
schemaVersion: '1.0.0',
|
|
656
|
+
protocolVersion: '2.0.0',
|
|
657
|
+
payload: safeDataClone(payload),
|
|
658
|
+
integrity: {
|
|
659
|
+
algorithm: 'sha-256-jcs',
|
|
660
|
+
domain,
|
|
661
|
+
sourceViewHash: payload.viewHash,
|
|
662
|
+
},
|
|
663
|
+
};
|
|
664
|
+
const issued = {
|
|
665
|
+
...base,
|
|
666
|
+
integrity: {
|
|
667
|
+
...base.integrity,
|
|
668
|
+
contentHash: contentHash(base, domain),
|
|
669
|
+
},
|
|
670
|
+
};
|
|
671
|
+
assertIssued(issued);
|
|
672
|
+
return deepFreeze(issued);
|
|
730
673
|
}
|
|
731
674
|
|
|
732
675
|
export function issueOperateExperienceDisplaySurfaceV1(payload) {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
676
|
+
return issueDisplay(
|
|
677
|
+
'operate-experience-display-surface',
|
|
678
|
+
DISPLAY_SURFACE_DOMAIN,
|
|
679
|
+
payload,
|
|
680
|
+
assertOperateExperienceDisplaySurfaceV1,
|
|
681
|
+
);
|
|
739
682
|
}
|
|
740
683
|
|
|
741
684
|
export function issueOperateCycleDisplayWorkspaceV1(payload) {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
685
|
+
return issueDisplay(
|
|
686
|
+
'operate-cycle-display-workspace',
|
|
687
|
+
CYCLE_WORKSPACE_DOMAIN,
|
|
688
|
+
payload,
|
|
689
|
+
assertOperateCycleDisplayWorkspaceV1,
|
|
690
|
+
);
|
|
748
691
|
}
|
|
749
692
|
|
|
750
693
|
function validExecutiveBoardSeatAbsence(absence) {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
694
|
+
if (absence === null) return true;
|
|
695
|
+
if (typeof absence !== 'object' || Array.isArray(absence)) return false;
|
|
696
|
+
if (absence.kind === 'omitted') {
|
|
697
|
+
return typeof absence.reason === 'string' && absence.reason.length > 0;
|
|
698
|
+
}
|
|
699
|
+
if (absence.kind === 'lens') {
|
|
700
|
+
return (
|
|
701
|
+
typeof absence.roleId === 'string' &&
|
|
702
|
+
typeof absence.roleKind === 'string' &&
|
|
703
|
+
typeof absence.absenceCode === 'string' &&
|
|
704
|
+
typeof absence.reason === 'string'
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
if (absence.kind === 'terminal') {
|
|
708
|
+
return (
|
|
709
|
+
(absence.outcome === 'abandoned' || absence.outcome === 'failed') &&
|
|
710
|
+
typeof absence.code === 'string' &&
|
|
711
|
+
typeof absence.reason === 'string' &&
|
|
712
|
+
typeof absence.recoveryDisposition === 'string'
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
return false;
|
|
773
716
|
}
|
|
774
717
|
|
|
775
718
|
function validExecutiveBoardSeat(seat) {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
719
|
+
return (
|
|
720
|
+
typeof seat?.roleId === 'string' &&
|
|
721
|
+
typeof seat?.label === 'string' &&
|
|
722
|
+
seat.roleId !== seat.label &&
|
|
723
|
+
typeof seat?.roleKind === 'string' &&
|
|
724
|
+
typeof seat?.roleVersion === 'string' &&
|
|
725
|
+
validExecutiveBoardSeatAbsence(seat?.absence ?? null)
|
|
726
|
+
);
|
|
784
727
|
}
|
|
785
728
|
|
|
786
729
|
function validExecutiveBoardPayload(payload) {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
730
|
+
const board = payload?.data?.executiveBoard;
|
|
731
|
+
if (!board || !Array.isArray(board.seats)) return false;
|
|
732
|
+
return board.seats.every(validExecutiveBoardSeat);
|
|
790
733
|
}
|
|
791
734
|
|
|
792
735
|
function validExecutiveBoardSemantics(value, expected) {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
736
|
+
return (
|
|
737
|
+
value.integrity.sourceViewHash === value.payload.viewHash &&
|
|
738
|
+
exactExpectedBinding(value.payload, expected, { executiveBoard: true }) &&
|
|
739
|
+
validExecutiveBoardPayload(value.payload)
|
|
740
|
+
);
|
|
798
741
|
}
|
|
799
742
|
|
|
800
743
|
export function validateOperateExecutiveBoardDisplaySurfaceV1(value, expected) {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
744
|
+
return validateDisplay(
|
|
745
|
+
value,
|
|
746
|
+
executiveBoardDisplaySurfaceSchema,
|
|
747
|
+
'schemas/v1.2.0/operate-executive-board-display-surface.schema.json',
|
|
748
|
+
validExecutiveBoardSemantics,
|
|
749
|
+
expected,
|
|
750
|
+
);
|
|
808
751
|
}
|
|
809
752
|
|
|
810
753
|
export function assertOperateExecutiveBoardDisplaySurfaceV1(value, expected) {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
754
|
+
if (validateOperateExecutiveBoardDisplaySurfaceV1(value, expected).length > 0) {
|
|
755
|
+
const error = new TypeError(
|
|
756
|
+
'The executive board display surface does not satisfy its closed integrity contract.',
|
|
757
|
+
);
|
|
758
|
+
error.code = 'E_OPERATE_EXECUTIVE_BOARD_DISPLAY_INVALID';
|
|
759
|
+
throw error;
|
|
760
|
+
}
|
|
761
|
+
return value;
|
|
819
762
|
}
|
|
820
763
|
|
|
821
764
|
export function issueOperateExecutiveBoardDisplaySurfaceV1(payload) {
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
765
|
+
return issueDisplay(
|
|
766
|
+
'operate-executive-board-display-surface',
|
|
767
|
+
EXECUTIVE_BOARD_DISPLAY_DOMAIN,
|
|
768
|
+
payload,
|
|
769
|
+
assertOperateExecutiveBoardDisplaySurfaceV1,
|
|
770
|
+
);
|
|
828
771
|
}
|
|
829
772
|
|
|
830
773
|
function actionDeepLink(actionId) {
|
|
831
|
-
|
|
774
|
+
return `#/operate/actions/${encodeURIComponent(actionId)}`;
|
|
832
775
|
}
|
|
833
776
|
|
|
834
777
|
function verificationFromOutcome(outcome) {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
status: "unverified",
|
|
858
|
-
reasonCodes: Object.freeze(["OPERATE_VERIFICATION_EVIDENCE_MISSING"]),
|
|
859
|
-
});
|
|
778
|
+
if (outcome === null) {
|
|
779
|
+
return Object.freeze({
|
|
780
|
+
status: 'not-required',
|
|
781
|
+
reasonCodes: Object.freeze([]),
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
if (outcome.status === 'insufficient-evidence') {
|
|
785
|
+
return Object.freeze({
|
|
786
|
+
status: 'unverified',
|
|
787
|
+
reasonCodes: Object.freeze(['OPERATE_VERIFICATION_EVIDENCE_MISSING']),
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
if (['succeeded', 'failed'].includes(outcome.status) && outcomeCarriesAffirmativeProof(outcome)) {
|
|
791
|
+
return Object.freeze({
|
|
792
|
+
status: 'verified',
|
|
793
|
+
reasonCodes: Object.freeze([]),
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
return Object.freeze({
|
|
797
|
+
status: 'unverified',
|
|
798
|
+
reasonCodes: Object.freeze(['OPERATE_VERIFICATION_EVIDENCE_MISSING']),
|
|
799
|
+
});
|
|
860
800
|
}
|
|
861
801
|
|
|
862
802
|
function recoveryStateFromInspection(inspection) {
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
803
|
+
const status = inspection?.status;
|
|
804
|
+
if (status === 'healthy' || status === 'empty') return 'restored';
|
|
805
|
+
if (status === 'corrupt') return 'corrupt';
|
|
806
|
+
if (status === 'incompatible') return 'incompatible';
|
|
807
|
+
if (status === 'locked') return 'blocked';
|
|
808
|
+
if (status === 'repairable') {
|
|
809
|
+
if (inspection.allowedRecovery === 'clear-stale-lock') return 'blocked';
|
|
810
|
+
if (inspection.allowedRecovery === 'restore-generation') return 'uncertain';
|
|
811
|
+
return 'uncertain';
|
|
812
|
+
}
|
|
813
|
+
return 'blocked';
|
|
874
814
|
}
|
|
875
815
|
|
|
876
816
|
function validActionWorkspacePayload(payload) {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
)
|
|
901
|
-
return false;
|
|
902
|
-
return true;
|
|
817
|
+
const data = payload.data;
|
|
818
|
+
const action = data.action;
|
|
819
|
+
const expectedDeepLink = actionDeepLink(action.actionId);
|
|
820
|
+
const allowedActions = data.allowedActions;
|
|
821
|
+
const outcome = data.outcome;
|
|
822
|
+
const verification = verificationFromOutcome(outcome);
|
|
823
|
+
const commandable = allowedActions.some((entry) => entry.action.effect !== 'read-only');
|
|
824
|
+
if (
|
|
825
|
+
payload.readOnly === payload.mutationEnabled ||
|
|
826
|
+
(payload.mutationEnabled && (payload.status !== 'ready' || !commandable)) ||
|
|
827
|
+
action.deepLink !== expectedDeepLink ||
|
|
828
|
+
!exactJson(data.boundaries, ACTION_WORKSPACE_BOUNDARIES) ||
|
|
829
|
+
!exactJson(data.verification, verification) ||
|
|
830
|
+
!exactJson(data.replay.finalHead, payload.eventHead) ||
|
|
831
|
+
allowedActions.some((entry) => entry.subjectId !== action.actionId) ||
|
|
832
|
+
data.inbox.some((item) => item.subjectId !== action.actionId) ||
|
|
833
|
+
data.learnings.some(
|
|
834
|
+
(learning) => outcome === null || learning.outcomeId !== outcome.outcomeId,
|
|
835
|
+
) ||
|
|
836
|
+
(outcome !== null && outcome.actionId !== action.actionId)
|
|
837
|
+
)
|
|
838
|
+
return false;
|
|
839
|
+
return true;
|
|
903
840
|
}
|
|
904
841
|
|
|
905
842
|
function validActionWorkspaceSemantics(value, expected) {
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
843
|
+
return (
|
|
844
|
+
value.integrity.sourceViewHash === value.payload.viewHash &&
|
|
845
|
+
exactExpectedBinding(value.payload, expected, { workspace: true, action: true }) &&
|
|
846
|
+
validActionWorkspacePayload(value.payload)
|
|
847
|
+
);
|
|
911
848
|
}
|
|
912
849
|
|
|
913
850
|
export function validateOperateActionDisplayWorkspaceV1(value, expected) {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
851
|
+
return validateDisplay(
|
|
852
|
+
value,
|
|
853
|
+
actionDisplayWorkspaceSchema,
|
|
854
|
+
'schemas/v1.2.0/operate-action-display-workspace.schema.json',
|
|
855
|
+
validActionWorkspaceSemantics,
|
|
856
|
+
expected,
|
|
857
|
+
);
|
|
921
858
|
}
|
|
922
859
|
|
|
923
860
|
export function assertOperateActionDisplayWorkspaceV1(value, expected) {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
861
|
+
if (validateOperateActionDisplayWorkspaceV1(value, expected).length > 0) {
|
|
862
|
+
const error = new TypeError(
|
|
863
|
+
'The Action display workspace does not satisfy its closed integrity contract.',
|
|
864
|
+
);
|
|
865
|
+
error.code = 'E_OPERATE_ACTION_DISPLAY_INVALID';
|
|
866
|
+
throw error;
|
|
867
|
+
}
|
|
868
|
+
return value;
|
|
932
869
|
}
|
|
933
870
|
|
|
934
871
|
export function issueOperateActionDisplayWorkspaceV1(payload) {
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
872
|
+
return issueDisplay(
|
|
873
|
+
'operate-action-display-workspace',
|
|
874
|
+
ACTION_WORKSPACE_DOMAIN,
|
|
875
|
+
payload,
|
|
876
|
+
assertOperateActionDisplayWorkspaceV1,
|
|
877
|
+
);
|
|
941
878
|
}
|
|
942
879
|
|
|
943
880
|
function validRecoveryDisplayPayload(payload) {
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
881
|
+
const data = payload.data;
|
|
882
|
+
if (
|
|
883
|
+
'integrityBoundary' in data.inspection ||
|
|
884
|
+
data.recoveryState !== recoveryStateFromInspection(data.inspection)
|
|
885
|
+
)
|
|
886
|
+
return false;
|
|
887
|
+
return true;
|
|
951
888
|
}
|
|
952
889
|
|
|
953
890
|
function validRecoveryDisplaySemantics(value, expected) {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
891
|
+
return (
|
|
892
|
+
value.integrity.sourceViewHash === value.payload.viewHash &&
|
|
893
|
+
exactExpectedBinding(value.payload, expected, { workspace: true, recovery: true }) &&
|
|
894
|
+
validRecoveryDisplayPayload(value.payload)
|
|
895
|
+
);
|
|
959
896
|
}
|
|
960
897
|
|
|
961
898
|
export function validateOperateRecoveryDisplaySurfaceV1(value, expected) {
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
899
|
+
return validateDisplay(
|
|
900
|
+
value,
|
|
901
|
+
recoveryDisplaySurfaceSchema,
|
|
902
|
+
'schemas/v1.2.0/operate-recovery-display-surface.schema.json',
|
|
903
|
+
validRecoveryDisplaySemantics,
|
|
904
|
+
expected,
|
|
905
|
+
);
|
|
969
906
|
}
|
|
970
907
|
|
|
971
908
|
export function assertOperateRecoveryDisplaySurfaceV1(value, expected) {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
909
|
+
if (validateOperateRecoveryDisplaySurfaceV1(value, expected).length > 0) {
|
|
910
|
+
const error = new TypeError(
|
|
911
|
+
'The recovery display surface does not satisfy its closed integrity contract.',
|
|
912
|
+
);
|
|
913
|
+
error.code = 'E_OPERATE_RECOVERY_DISPLAY_INVALID';
|
|
914
|
+
throw error;
|
|
915
|
+
}
|
|
916
|
+
return value;
|
|
980
917
|
}
|
|
981
918
|
|
|
982
919
|
export function issueOperateRecoveryDisplaySurfaceV1(payload) {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
920
|
+
return issueDisplay(
|
|
921
|
+
'operate-recovery-display-surface',
|
|
922
|
+
RECOVERY_DISPLAY_DOMAIN,
|
|
923
|
+
payload,
|
|
924
|
+
assertOperateRecoveryDisplaySurfaceV1,
|
|
925
|
+
);
|
|
989
926
|
}
|
|
990
927
|
|
|
991
928
|
export const OPERATE_ACTION_DISPLAY_WORKSPACE_SCHEMA_V1 = Object.freeze(
|
|
992
|
-
|
|
929
|
+
structuredClone(actionDisplayWorkspaceSchema),
|
|
993
930
|
);
|
|
994
931
|
export const OPERATE_RECOVERY_DISPLAY_SURFACE_SCHEMA_V1 = Object.freeze(
|
|
995
|
-
|
|
932
|
+
structuredClone(recoveryDisplaySurfaceSchema),
|
|
996
933
|
);
|
|
997
934
|
|
|
998
935
|
export const OPERATE_EXECUTIVE_BOARD_DISPLAY_SURFACE_SCHEMA_V1 = Object.freeze(
|
|
999
|
-
|
|
936
|
+
structuredClone(executiveBoardDisplaySurfaceSchema),
|
|
1000
937
|
);
|
|
1001
938
|
|
|
1002
939
|
export const OPERATE_EXPERIENCE_DISPLAY_SURFACE_SCHEMA_V1 = Object.freeze(
|
|
1003
|
-
|
|
940
|
+
structuredClone(displaySurfaceSchema),
|
|
1004
941
|
);
|
|
1005
942
|
export const OPERATE_CYCLE_DISPLAY_WORKSPACE_SCHEMA_V1 = Object.freeze(
|
|
1006
|
-
|
|
943
|
+
structuredClone(cycleDisplayWorkspaceSchema),
|
|
1007
944
|
);
|