@elevasis/core 0.33.0 → 0.34.1
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/dist/test-utils/index.js +5 -5
- package/package.json +1 -1
- package/src/business/acquisition/ontology-validation.ts +1 -1
- package/src/organization-model/__tests__/schema.test.ts +428 -399
- package/src/platform/constants/versions.ts +1 -1
- package/src/platform/registry/__tests__/resource-registry.nested-systems.test.ts +257 -245
- package/src/platform/registry/resource-registry.ts +881 -888
- package/src/platform/registry/validation.ts +721 -712
- package/src/reference/_generated/contracts.md +25 -30
|
@@ -1,245 +1,257 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Regression tests for resource-registry nested-systems lookup (Wave 1 hotfix).
|
|
3
|
-
*
|
|
4
|
-
* Before the fix, `listResourcesForOrganization` built the systems map with
|
|
5
|
-
* `Object.values(org.systems)`, which only surfaced top-level entries. Systems
|
|
6
|
-
* declared as children under `system.subsystems` were invisible, so
|
|
7
|
-
* `summarizeSystem` always returned `undefined` for nested paths.
|
|
8
|
-
*
|
|
9
|
-
* After the fix, the map is built via `listAllSystems` (DFS), which walks the
|
|
10
|
-
* full tree and keys every entry by its dot-joined path.
|
|
11
|
-
*/
|
|
12
|
-
import { describe, it, expect } from 'vitest'
|
|
13
|
-
import { z } from 'zod'
|
|
14
|
-
import { ResourceRegistry } from '../resource-registry'
|
|
15
|
-
import type { SystemEntry } from '../../../organization-model/domains/systems'
|
|
16
|
-
import type { ResourceEntry } from '../../../organization-model/domains/resources'
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
'
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
kind: 'operational',
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
245
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Regression tests for resource-registry nested-systems lookup (Wave 1 hotfix).
|
|
3
|
+
*
|
|
4
|
+
* Before the fix, `listResourcesForOrganization` built the systems map with
|
|
5
|
+
* `Object.values(org.systems)`, which only surfaced top-level entries. Systems
|
|
6
|
+
* declared as children under `system.subsystems` were invisible, so
|
|
7
|
+
* `summarizeSystem` always returned `undefined` for nested paths.
|
|
8
|
+
*
|
|
9
|
+
* After the fix, the map is built via `listAllSystems` (DFS), which walks the
|
|
10
|
+
* full tree and keys every entry by its dot-joined path.
|
|
11
|
+
*/
|
|
12
|
+
import { describe, it, expect } from 'vitest'
|
|
13
|
+
import { z } from 'zod'
|
|
14
|
+
import { ResourceRegistry } from '../resource-registry'
|
|
15
|
+
import type { SystemEntry } from '../../../organization-model/domains/systems'
|
|
16
|
+
import type { ResourceEntry } from '../../../organization-model/domains/resources'
|
|
17
|
+
import { OrganizationModelSchema } from '../../../organization-model/schema'
|
|
18
|
+
import type { OrganizationModel } from '../../../organization-model/types'
|
|
19
|
+
import type { WorkflowDefinition } from '../../../execution/engine/workflow/types'
|
|
20
|
+
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Minimal fixture helpers
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
function makeWorkflow(resourceId: string, resource?: ResourceEntry): WorkflowDefinition {
|
|
26
|
+
return {
|
|
27
|
+
config: {
|
|
28
|
+
resourceId,
|
|
29
|
+
name: `Workflow ${resourceId}`,
|
|
30
|
+
description: `Test workflow ${resourceId}`,
|
|
31
|
+
version: '1.0.0',
|
|
32
|
+
type: 'workflow',
|
|
33
|
+
status: 'prod',
|
|
34
|
+
resource
|
|
35
|
+
},
|
|
36
|
+
contract: {
|
|
37
|
+
inputSchema: z.object({ input: z.string() }),
|
|
38
|
+
outputSchema: z.object({ output: z.string() })
|
|
39
|
+
},
|
|
40
|
+
steps: {
|
|
41
|
+
step1: {
|
|
42
|
+
id: 'step1',
|
|
43
|
+
name: 'Step 1',
|
|
44
|
+
description: 'Only step',
|
|
45
|
+
handler: async () => ({ output: 'ok' }),
|
|
46
|
+
inputSchema: z.object({ input: z.string() }),
|
|
47
|
+
outputSchema: z.object({ output: z.string() }),
|
|
48
|
+
next: null
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
entryPoint: 'step1'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function makeOrganizationModel(
|
|
56
|
+
systems: Record<string, SystemEntry>,
|
|
57
|
+
resources: Record<string, ResourceEntry>
|
|
58
|
+
): OrganizationModel {
|
|
59
|
+
return OrganizationModelSchema.parse({
|
|
60
|
+
systems,
|
|
61
|
+
resources
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// Fixture: two-level system tree
|
|
67
|
+
//
|
|
68
|
+
// systems
|
|
69
|
+
// └── acquisition (top-level, id: 'acquisition')
|
|
70
|
+
// └── subsystems
|
|
71
|
+
// └── outbound (nested, id: 'outbound') ← formerly invisible
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
const topLevelSystem: SystemEntry = {
|
|
75
|
+
id: 'acquisition',
|
|
76
|
+
label: 'Acquisition',
|
|
77
|
+
description: 'Top-level acquisition system.',
|
|
78
|
+
kind: 'operational',
|
|
79
|
+
governedByKnowledge: [],
|
|
80
|
+
drivesGoals: [],
|
|
81
|
+
lifecycle: 'active',
|
|
82
|
+
order: 10
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const nestedSystem: SystemEntry = {
|
|
86
|
+
id: 'outbound',
|
|
87
|
+
label: 'Outbound',
|
|
88
|
+
description: 'Outbound automation sub-system.',
|
|
89
|
+
kind: 'operational',
|
|
90
|
+
governedByKnowledge: [],
|
|
91
|
+
drivesGoals: [],
|
|
92
|
+
lifecycle: 'active',
|
|
93
|
+
order: 10
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Dot-joined path for the nested system as it appears in resource.systemPath */
|
|
97
|
+
const NESTED_SYSTEM_PATH = 'acquisition.outbound'
|
|
98
|
+
|
|
99
|
+
const topLevelSystemWithChildren: SystemEntry = {
|
|
100
|
+
...topLevelSystem,
|
|
101
|
+
subsystems: {
|
|
102
|
+
outbound: nestedSystem
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const nestedSystemResource: ResourceEntry = {
|
|
107
|
+
id: 'cold-outreach-workflow',
|
|
108
|
+
kind: 'workflow',
|
|
109
|
+
systemPath: NESTED_SYSTEM_PATH,
|
|
110
|
+
status: 'active',
|
|
111
|
+
order: 10
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
// Tests
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
describe('ResourceRegistry — nested-systems lookup regression', () => {
|
|
119
|
+
it('resolves system metadata for a TOP-LEVEL system path', () => {
|
|
120
|
+
const topResource: ResourceEntry = {
|
|
121
|
+
id: 'top-workflow',
|
|
122
|
+
kind: 'workflow',
|
|
123
|
+
systemPath: 'acquisition',
|
|
124
|
+
status: 'active',
|
|
125
|
+
order: 10
|
|
126
|
+
}
|
|
127
|
+
const workflow = makeWorkflow('top-workflow', topResource)
|
|
128
|
+
|
|
129
|
+
const registry = new ResourceRegistry({
|
|
130
|
+
'test-org': {
|
|
131
|
+
version: '1.0.0',
|
|
132
|
+
organizationModel: makeOrganizationModel(
|
|
133
|
+
{ acquisition: topLevelSystemWithChildren },
|
|
134
|
+
{ 'top-workflow': topResource }
|
|
135
|
+
),
|
|
136
|
+
workflows: [workflow]
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
const result = registry.listResourcesForOrganization('test-org')
|
|
141
|
+
|
|
142
|
+
expect(result.workflows).toHaveLength(1)
|
|
143
|
+
expect(result.workflows[0].system).toBeDefined()
|
|
144
|
+
expect(result.workflows[0].system).toMatchObject({
|
|
145
|
+
id: 'acquisition',
|
|
146
|
+
title: 'Acquisition',
|
|
147
|
+
kind: 'operational',
|
|
148
|
+
lifecycle: 'active'
|
|
149
|
+
})
|
|
150
|
+
expect(result.workflows[0].systemPath).toBe('acquisition')
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
it('resolves system metadata for a NESTED system path (the regression case)', () => {
|
|
154
|
+
const workflow = makeWorkflow('cold-outreach-workflow', nestedSystemResource)
|
|
155
|
+
|
|
156
|
+
const registry = new ResourceRegistry({
|
|
157
|
+
'test-org': {
|
|
158
|
+
version: '1.0.0',
|
|
159
|
+
organizationModel: makeOrganizationModel(
|
|
160
|
+
// The nested system lives under acquisition.subsystems, NOT as a top-level key.
|
|
161
|
+
// Before the fix, Object.values(systems) missed this entirely.
|
|
162
|
+
{ acquisition: topLevelSystemWithChildren },
|
|
163
|
+
{ 'cold-outreach-workflow': nestedSystemResource }
|
|
164
|
+
),
|
|
165
|
+
workflows: [workflow]
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
const result = registry.listResourcesForOrganization('test-org')
|
|
170
|
+
|
|
171
|
+
expect(result.workflows).toHaveLength(1)
|
|
172
|
+
// Before the fix this was undefined; it must now be defined.
|
|
173
|
+
expect(result.workflows[0].system).toBeDefined()
|
|
174
|
+
expect(result.workflows[0].system).toMatchObject({
|
|
175
|
+
id: 'outbound',
|
|
176
|
+
title: 'Outbound',
|
|
177
|
+
kind: 'operational',
|
|
178
|
+
lifecycle: 'active'
|
|
179
|
+
})
|
|
180
|
+
expect(result.workflows[0].systemPath).toBe(NESTED_SYSTEM_PATH)
|
|
181
|
+
expect(result.workflows[0].governanceStatus).toBe('active')
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('resolves system metadata for a THREE-level nested path', () => {
|
|
185
|
+
const deepSystem: SystemEntry = {
|
|
186
|
+
id: 'sequences',
|
|
187
|
+
label: 'Sequences',
|
|
188
|
+
description: 'Email sequence sub-sub-system.',
|
|
189
|
+
kind: 'operational',
|
|
190
|
+
governedByKnowledge: [],
|
|
191
|
+
drivesGoals: [],
|
|
192
|
+
lifecycle: 'active',
|
|
193
|
+
order: 10
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const outboundWithChildren: SystemEntry = {
|
|
197
|
+
...nestedSystem,
|
|
198
|
+
subsystems: { sequences: deepSystem }
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const topWithDeepNesting: SystemEntry = {
|
|
202
|
+
...topLevelSystem,
|
|
203
|
+
subsystems: { outbound: outboundWithChildren }
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const deepResource: ResourceEntry = {
|
|
207
|
+
id: 'sequence-enroller',
|
|
208
|
+
kind: 'workflow',
|
|
209
|
+
systemPath: 'acquisition.outbound.sequences',
|
|
210
|
+
status: 'active',
|
|
211
|
+
order: 10
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const workflow = makeWorkflow('sequence-enroller', deepResource)
|
|
215
|
+
|
|
216
|
+
const registry = new ResourceRegistry({
|
|
217
|
+
'test-org': {
|
|
218
|
+
version: '1.0.0',
|
|
219
|
+
organizationModel: makeOrganizationModel(
|
|
220
|
+
{ acquisition: topWithDeepNesting },
|
|
221
|
+
{ 'sequence-enroller': deepResource }
|
|
222
|
+
),
|
|
223
|
+
workflows: [workflow]
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
const result = registry.listResourcesForOrganization('test-org')
|
|
228
|
+
|
|
229
|
+
expect(result.workflows).toHaveLength(1)
|
|
230
|
+
expect(result.workflows[0].system).toBeDefined()
|
|
231
|
+
expect(result.workflows[0].system).toMatchObject({
|
|
232
|
+
id: 'sequences',
|
|
233
|
+
title: 'Sequences',
|
|
234
|
+
lifecycle: 'active'
|
|
235
|
+
})
|
|
236
|
+
expect(result.workflows[0].systemPath).toBe('acquisition.outbound.sequences')
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
it('returns undefined system when the workflow has no resource descriptor and no OM entry', () => {
|
|
240
|
+
// A workflow with no OM resource descriptor and no organizationModel at all
|
|
241
|
+
// should leave system undefined (no governance metadata attached).
|
|
242
|
+
const workflow = makeWorkflow('bare-workflow')
|
|
243
|
+
|
|
244
|
+
const registry = new ResourceRegistry({
|
|
245
|
+
'test-org': {
|
|
246
|
+
version: '1.0.0',
|
|
247
|
+
workflows: [workflow]
|
|
248
|
+
}
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
const result = registry.listResourcesForOrganization('test-org')
|
|
252
|
+
|
|
253
|
+
expect(result.workflows).toHaveLength(1)
|
|
254
|
+
expect(result.workflows[0].system).toBeUndefined()
|
|
255
|
+
expect(result.workflows[0].systemPath).toBeUndefined()
|
|
256
|
+
})
|
|
257
|
+
})
|