@elevasis/core 0.21.0 → 0.23.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.
Files changed (132) hide show
  1. package/dist/index.d.ts +2518 -2169
  2. package/dist/index.js +2495 -1095
  3. package/dist/knowledge/index.d.ts +706 -1044
  4. package/dist/knowledge/index.js +9 -9
  5. package/dist/organization-model/index.d.ts +2518 -2169
  6. package/dist/organization-model/index.js +2495 -1095
  7. package/dist/test-utils/index.d.ts +826 -1014
  8. package/dist/test-utils/index.js +1894 -1032
  9. package/package.json +3 -3
  10. package/src/__tests__/template-core-compatibility.test.ts +11 -79
  11. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +852 -397
  12. package/src/auth/multi-tenancy/permissions.ts +20 -8
  13. package/src/business/README.md +2 -2
  14. package/src/business/acquisition/api-schemas.test.ts +175 -2
  15. package/src/business/acquisition/api-schemas.ts +132 -16
  16. package/src/business/acquisition/build-templates.test.ts +4 -4
  17. package/src/business/acquisition/build-templates.ts +72 -30
  18. package/src/business/acquisition/crm-state-actions.test.ts +13 -11
  19. package/src/business/acquisition/index.ts +12 -0
  20. package/src/business/acquisition/types.ts +7 -3
  21. package/src/business/clients/api-schemas.test.ts +115 -0
  22. package/src/business/clients/api-schemas.ts +158 -0
  23. package/src/business/clients/index.ts +1 -0
  24. package/src/business/deals/api-schemas.ts +8 -0
  25. package/src/business/index.ts +5 -2
  26. package/src/business/projects/types.ts +19 -0
  27. package/src/execution/engine/__tests__/fixtures/test-agents.ts +10 -8
  28. package/src/execution/engine/agent/core/__tests__/agent.test.ts +16 -12
  29. package/src/execution/engine/agent/core/__tests__/error-passthrough.test.ts +4 -3
  30. package/src/execution/engine/agent/core/types.ts +25 -15
  31. package/src/execution/engine/agent/index.ts +6 -4
  32. package/src/execution/engine/agent/reasoning/__tests__/request-builder.test.ts +24 -18
  33. package/src/execution/engine/index.ts +3 -0
  34. package/src/execution/engine/workflow/types.ts +9 -2
  35. package/src/knowledge/README.md +8 -7
  36. package/src/knowledge/__tests__/queries.test.ts +74 -73
  37. package/src/knowledge/format.ts +10 -9
  38. package/src/knowledge/index.ts +1 -1
  39. package/src/knowledge/published.ts +1 -1
  40. package/src/knowledge/queries.ts +26 -25
  41. package/src/organization-model/README.md +73 -26
  42. package/src/organization-model/__tests__/content-kinds-registry.test.ts +210 -0
  43. package/src/organization-model/__tests__/defaults.test.ts +76 -96
  44. package/src/organization-model/__tests__/domains/actions.test.ts +56 -0
  45. package/src/organization-model/__tests__/domains/customers.test.ts +299 -295
  46. package/src/organization-model/__tests__/domains/entities.test.ts +56 -0
  47. package/src/organization-model/__tests__/domains/goals.test.ts +493 -479
  48. package/src/organization-model/__tests__/domains/identity.test.ts +280 -279
  49. package/src/organization-model/__tests__/domains/navigation.test.ts +268 -212
  50. package/src/organization-model/__tests__/domains/offerings.test.ts +414 -419
  51. package/src/organization-model/__tests__/domains/policies.test.ts +323 -0
  52. package/src/organization-model/__tests__/domains/resource-mappings.test.ts +271 -271
  53. package/src/organization-model/__tests__/domains/resources.test.ts +310 -0
  54. package/src/organization-model/__tests__/domains/roles.test.ts +463 -347
  55. package/src/organization-model/__tests__/domains/statuses.test.ts +246 -243
  56. package/src/organization-model/__tests__/domains/systems.test.ts +209 -0
  57. package/src/organization-model/__tests__/flatten-additive-merge.test.ts +361 -0
  58. package/src/organization-model/__tests__/foundation.test.ts +74 -102
  59. package/src/organization-model/__tests__/get-resources-for-system.test.ts +144 -0
  60. package/src/organization-model/__tests__/graph.test.ts +899 -71
  61. package/src/organization-model/__tests__/knowledge.test.ts +209 -49
  62. package/src/organization-model/__tests__/lookup-helpers.test.ts +438 -0
  63. package/src/organization-model/__tests__/migration-helpers.test.ts +591 -0
  64. package/src/organization-model/__tests__/prospecting-ssot.test.ts +36 -27
  65. package/src/organization-model/__tests__/recursive-system-schema.test.ts +520 -0
  66. package/src/organization-model/__tests__/resolve.test.ts +174 -23
  67. package/src/organization-model/__tests__/schema.test.ts +291 -114
  68. package/src/organization-model/__tests__/surface-projection.test.ts +207 -97
  69. package/src/organization-model/catalogs/lead-gen.ts +144 -0
  70. package/src/organization-model/content-kinds/config.ts +36 -0
  71. package/src/organization-model/content-kinds/index.ts +74 -0
  72. package/src/organization-model/content-kinds/pipeline.ts +68 -0
  73. package/src/organization-model/content-kinds/registry.ts +44 -0
  74. package/src/organization-model/content-kinds/status.ts +71 -0
  75. package/src/organization-model/content-kinds/template.ts +83 -0
  76. package/src/organization-model/content-kinds/types.ts +117 -0
  77. package/src/organization-model/contracts.ts +13 -3
  78. package/src/organization-model/defaults.ts +499 -86
  79. package/src/organization-model/domains/actions.ts +239 -0
  80. package/src/organization-model/domains/customers.ts +78 -75
  81. package/src/organization-model/domains/entities.ts +144 -0
  82. package/src/organization-model/domains/goals.ts +83 -80
  83. package/src/organization-model/domains/knowledge.ts +76 -17
  84. package/src/organization-model/domains/navigation.ts +107 -384
  85. package/src/organization-model/domains/offerings.ts +71 -66
  86. package/src/organization-model/domains/policies.ts +102 -0
  87. package/src/organization-model/domains/projects.ts +14 -48
  88. package/src/organization-model/domains/prospecting.ts +62 -181
  89. package/src/organization-model/domains/resources.ts +145 -0
  90. package/src/organization-model/domains/roles.ts +96 -55
  91. package/src/organization-model/domains/sales.ts +10 -219
  92. package/src/organization-model/domains/shared.ts +57 -57
  93. package/src/organization-model/domains/statuses.ts +339 -130
  94. package/src/organization-model/domains/systems.ts +203 -0
  95. package/src/organization-model/foundation.ts +54 -67
  96. package/src/organization-model/graph/build.ts +682 -54
  97. package/src/organization-model/graph/link.ts +1 -1
  98. package/src/organization-model/graph/schema.ts +24 -9
  99. package/src/organization-model/graph/types.ts +20 -7
  100. package/src/organization-model/helpers.ts +231 -26
  101. package/src/organization-model/icons.ts +1 -0
  102. package/src/organization-model/index.ts +118 -5
  103. package/src/organization-model/migration-helpers.ts +249 -0
  104. package/src/organization-model/organization-graph.mdx +16 -15
  105. package/src/organization-model/organization-model.mdx +111 -44
  106. package/src/organization-model/published.ts +172 -19
  107. package/src/organization-model/resolve.ts +117 -54
  108. package/src/organization-model/schema.ts +654 -112
  109. package/src/organization-model/surface-projection.ts +116 -122
  110. package/src/organization-model/types.ts +146 -20
  111. package/src/platform/api/types.ts +38 -35
  112. package/src/platform/constants/versions.ts +1 -1
  113. package/src/platform/registry/__tests__/command-view.test.ts +6 -8
  114. package/src/platform/registry/__tests__/resource-link.test.ts +13 -8
  115. package/src/platform/registry/__tests__/resource-registry.integration.test.ts +16 -31
  116. package/src/platform/registry/__tests__/resource-registry.nested-systems.test.ts +245 -0
  117. package/src/platform/registry/__tests__/resource-registry.test.ts +2053 -2005
  118. package/src/platform/registry/__tests__/validation.test.ts +1347 -1086
  119. package/src/platform/registry/index.ts +14 -0
  120. package/src/platform/registry/resource-registry.ts +52 -2
  121. package/src/platform/registry/serialization.ts +241 -202
  122. package/src/platform/registry/serialized-types.ts +1 -0
  123. package/src/platform/registry/types.ts +411 -361
  124. package/src/platform/registry/validation.ts +745 -513
  125. package/src/projects/api-schemas.ts +290 -267
  126. package/src/reference/_generated/contracts.md +853 -397
  127. package/src/reference/glossary.md +23 -18
  128. package/src/supabase/database.types.ts +181 -0
  129. package/src/test-utils/test-utils.test.ts +1 -6
  130. package/src/organization-model/__tests__/domains/operations.test.ts +0 -203
  131. package/src/organization-model/domains/features.ts +0 -31
  132. package/src/organization-model/domains/operations.ts +0 -85
@@ -4,27 +4,32 @@ import type { OrganizationGraph } from '../../../organization-model/graph/types'
4
4
 
5
5
  describe('resource-link', () => {
6
6
  it('parses resource links and categories', () => {
7
- expect(ResourceLinkSchema.parse({ nodeId: 'feature:sales.crm', kind: 'operates-on' })).toEqual({
8
- nodeId: 'feature:sales.crm',
9
- kind: 'operates-on'
7
+ expect(ResourceLinkSchema.parse({ nodeId: 'system:sales.crm', kind: 'references' })).toEqual({
8
+ nodeId: 'system:sales.crm',
9
+ kind: 'references'
10
10
  })
11
11
  expect(ResourceCategorySchema.parse('diagnostic')).toBe('diagnostic')
12
12
  })
13
13
 
14
14
  it('rejects node ids without a kind prefix', () => {
15
- expect(() => ResourceLinkSchema.parse({ nodeId: 'sales.crm', kind: 'operates-on' })).toThrow()
15
+ expect(() => ResourceLinkSchema.parse({ nodeId: 'sales.crm', kind: 'references' })).toThrow()
16
+ })
17
+
18
+ it('rejects retired ad hoc resource-operation links', () => {
19
+ const retiredKind = ['operates', 'on'].join('-')
20
+ expect(() => ResourceLinkSchema.parse({ nodeId: 'system:sales.crm', kind: retiredKind })).toThrow()
16
21
  })
17
22
 
18
23
  it('builds and validates graph node ids', () => {
19
24
  const graph: OrganizationGraph = {
20
25
  version: 1,
21
26
  organizationModelVersion: 1,
22
- nodes: [{ id: 'feature:sales.crm', kind: 'feature', label: 'CRM', sourceId: 'sales.crm' }],
27
+ nodes: [{ id: 'system:sales.crm', kind: 'system', label: 'CRM', sourceId: 'sales.crm' }],
23
28
  edges: []
24
29
  }
25
30
 
26
- expect(kindPrefix('feature', 'sales.crm')).toBe('feature:sales.crm')
27
- expect(() => validateNodeId('feature:sales.crm', graph)).not.toThrow()
28
- expect(() => validateNodeId('feature:missing', graph)).toThrow(/Unknown organization graph node/)
31
+ expect(kindPrefix('system', 'sales.crm')).toBe('system:sales.crm')
32
+ expect(() => validateNodeId('system:sales.crm', graph)).not.toThrow()
33
+ expect(() => validateNodeId('system:missing', graph)).toThrow(/Unknown organization graph node/)
29
34
  })
30
35
  })
@@ -32,19 +32,14 @@ describe('ResourceRegistry Integration', () => {
32
32
  // Mock Data Helpers
33
33
  // ============================================================================
34
34
 
35
- const createMockWorkflow = (
36
- resourceId: string,
37
- status: 'dev' | 'prod' = 'dev',
38
- links?: Array<{ nodeId: string; kind: 'operates-on' }>
39
- ): WorkflowDefinition => ({
35
+ const createMockWorkflow = (resourceId: string, status: 'dev' | 'prod' = 'dev'): WorkflowDefinition => ({
40
36
  config: {
41
37
  resourceId,
42
38
  name: `Workflow ${resourceId}`,
43
39
  description: `Test workflow ${resourceId}`,
44
40
  version: '1.0.0',
45
41
  type: 'workflow',
46
- status,
47
- links
42
+ status
48
43
  },
49
44
  contract: {
50
45
  inputSchema: z.object({ data: z.string() }),
@@ -64,11 +59,7 @@ describe('ResourceRegistry Integration', () => {
64
59
  entryPoint: 'step1'
65
60
  })
66
61
 
67
- const createMockAgent = (
68
- resourceId: string,
69
- status: 'dev' | 'prod' = 'dev',
70
- links?: Array<{ nodeId: string; kind: 'operates-on' }>
71
- ): AgentDefinition => ({
62
+ const createMockAgent = (resourceId: string, status: 'dev' | 'prod' = 'dev'): AgentDefinition => ({
72
63
  config: {
73
64
  resourceId,
74
65
  name: `Agent ${resourceId}`,
@@ -76,8 +67,7 @@ describe('ResourceRegistry Integration', () => {
76
67
  version: '1.0.0',
77
68
  type: 'agent',
78
69
  status,
79
- systemPrompt: 'You are a test agent',
80
- links
70
+ systemPrompt: 'You are a test agent'
81
71
  },
82
72
  contract: {
83
73
  inputSchema: z.object({ query: z.string() }),
@@ -97,13 +87,13 @@ describe('ResourceRegistry Integration', () => {
97
87
  */
98
88
  const createTestOrganization = (): DeploymentSpec => {
99
89
  const workflows = [
100
- createMockWorkflow('order-workflow', 'prod', ['sales']),
101
- createMockWorkflow('support-workflow', 'dev', ['support'])
90
+ createMockWorkflow('order-workflow', 'prod'),
91
+ createMockWorkflow('support-workflow', 'dev')
102
92
  ]
103
93
 
104
94
  const agents = [
105
- createMockAgent('order-agent', 'prod', ['sales']),
106
- createMockAgent('support-agent', 'dev', ['support'])
95
+ createMockAgent('order-agent', 'prod'),
96
+ createMockAgent('support-agent', 'dev')
107
97
  ]
108
98
 
109
99
  const triggers: TriggerDefinition[] = [
@@ -115,8 +105,7 @@ describe('ResourceRegistry Integration', () => {
115
105
  name: 'Order Webhook',
116
106
  description: 'Webhook from Shopify on new orders',
117
107
  status: 'prod',
118
- webhookPath: '/webhooks/shopify/orders',
119
- links: [{ nodeId: 'feature:sales.crm', kind: 'operates-on' }]
108
+ webhookPath: '/webhooks/shopify/orders'
120
109
  },
121
110
  {
122
111
  resourceId: 'trigger-schedule-support',
@@ -125,9 +114,8 @@ describe('ResourceRegistry Integration', () => {
125
114
  version: '1.0.0',
126
115
  name: 'Support Ticket Check',
127
116
  description: 'Check for new support tickets every hour',
128
- status: 'dev',
129
- schedule: '0 * * * *',
130
- links: [{ nodeId: 'feature:monitoring.submitted-requests', kind: 'operates-on' }]
117
+ status: 'dev',
118
+ schedule: '0 * * * *'
131
119
  },
132
120
  {
133
121
  resourceId: 'trigger-manual-test',
@@ -148,9 +136,8 @@ describe('ResourceRegistry Integration', () => {
148
136
  status: 'prod',
149
137
  provider: 'shopify',
150
138
  credentialName: 'shopify-prod',
151
- name: 'Shopify Production',
152
- description: 'E-commerce platform',
153
- links: [{ nodeId: 'feature:sales.crm', kind: 'operates-on' }]
139
+ name: 'Shopify Production',
140
+ description: 'E-commerce platform'
154
141
  },
155
142
  {
156
143
  resourceId: 'integration-zendesk',
@@ -159,9 +146,8 @@ describe('ResourceRegistry Integration', () => {
159
146
  status: 'dev',
160
147
  provider: 'zendesk',
161
148
  credentialName: 'zendesk-dev',
162
- name: 'Zendesk Support',
163
- description: 'Support ticket system',
164
- links: [{ nodeId: 'feature:monitoring.submitted-requests', kind: 'operates-on' }]
149
+ name: 'Zendesk Support',
150
+ description: 'Support ticket system'
165
151
  }
166
152
  ]
167
153
 
@@ -201,8 +187,7 @@ describe('ResourceRegistry Integration', () => {
201
187
  description: 'Approve orders over $10,000',
202
188
  status: 'prod',
203
189
  requestedBy: { agents: ['order-agent'] },
204
- routesTo: { workflows: ['order-workflow'] },
205
- links: [{ nodeId: 'feature:sales.crm', kind: 'operates-on' }]
190
+ routesTo: { workflows: ['order-workflow'] }
206
191
  },
207
192
  {
208
193
  resourceId: 'approval-escalation',
@@ -0,0 +1,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 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
+ })