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