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