@elevasis/core 0.22.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.
- package/dist/index.d.ts +2330 -2391
- package/dist/index.js +2322 -1147
- package/dist/knowledge/index.d.ts +702 -1136
- package/dist/knowledge/index.js +9 -9
- package/dist/organization-model/index.d.ts +2330 -2391
- package/dist/organization-model/index.js +2322 -1147
- package/dist/test-utils/index.d.ts +703 -1106
- package/dist/test-utils/index.js +1735 -1089
- package/package.json +1 -1
- package/src/__tests__/template-core-compatibility.test.ts +11 -79
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +360 -98
- package/src/business/acquisition/api-schemas.test.ts +2 -2
- package/src/business/acquisition/api-schemas.ts +7 -9
- package/src/business/acquisition/build-templates.test.ts +4 -4
- package/src/business/acquisition/build-templates.ts +72 -30
- package/src/business/acquisition/crm-state-actions.test.ts +13 -11
- package/src/business/acquisition/types.ts +7 -3
- package/src/execution/engine/agent/core/types.ts +1 -1
- package/src/execution/engine/workflow/types.ts +2 -2
- package/src/knowledge/README.md +8 -7
- package/src/knowledge/__tests__/queries.test.ts +74 -73
- package/src/knowledge/format.ts +10 -9
- package/src/knowledge/index.ts +1 -1
- package/src/knowledge/published.ts +1 -1
- package/src/knowledge/queries.ts +26 -25
- package/src/organization-model/README.md +66 -26
- package/src/organization-model/__tests__/content-kinds-registry.test.ts +210 -0
- package/src/organization-model/__tests__/defaults.test.ts +72 -98
- package/src/organization-model/__tests__/domains/actions.test.ts +56 -0
- package/src/organization-model/__tests__/domains/customers.test.ts +299 -295
- package/src/organization-model/__tests__/domains/entities.test.ts +56 -0
- package/src/organization-model/__tests__/domains/goals.test.ts +493 -479
- package/src/organization-model/__tests__/domains/identity.test.ts +280 -279
- package/src/organization-model/__tests__/domains/navigation.test.ts +268 -212
- package/src/organization-model/__tests__/domains/offerings.test.ts +414 -419
- package/src/organization-model/__tests__/domains/policies.test.ts +323 -0
- package/src/organization-model/__tests__/domains/resource-mappings.test.ts +271 -271
- package/src/organization-model/__tests__/domains/resources.test.ts +159 -37
- package/src/organization-model/__tests__/domains/roles.test.ts +147 -86
- package/src/organization-model/__tests__/domains/statuses.test.ts +246 -243
- package/src/organization-model/__tests__/domains/systems.test.ts +67 -51
- package/src/organization-model/__tests__/flatten-additive-merge.test.ts +361 -0
- package/src/organization-model/__tests__/foundation.test.ts +74 -102
- package/src/organization-model/__tests__/get-resources-for-system.test.ts +144 -0
- package/src/organization-model/__tests__/graph.test.ts +899 -71
- package/src/organization-model/__tests__/knowledge.test.ts +173 -52
- package/src/organization-model/__tests__/lookup-helpers.test.ts +438 -0
- package/src/organization-model/__tests__/migration-helpers.test.ts +591 -0
- package/src/organization-model/__tests__/prospecting-ssot.test.ts +36 -27
- package/src/organization-model/__tests__/recursive-system-schema.test.ts +520 -0
- package/src/organization-model/__tests__/resolve.test.ts +174 -23
- package/src/organization-model/__tests__/schema.test.ts +291 -114
- package/src/organization-model/__tests__/surface-projection.test.ts +207 -97
- package/src/organization-model/catalogs/lead-gen.ts +144 -0
- package/src/organization-model/content-kinds/config.ts +36 -0
- package/src/organization-model/content-kinds/index.ts +74 -0
- package/src/organization-model/content-kinds/pipeline.ts +68 -0
- package/src/organization-model/content-kinds/registry.ts +44 -0
- package/src/organization-model/content-kinds/status.ts +71 -0
- package/src/organization-model/content-kinds/template.ts +83 -0
- package/src/organization-model/content-kinds/types.ts +117 -0
- package/src/organization-model/contracts.ts +13 -3
- package/src/organization-model/defaults.ts +488 -96
- package/src/organization-model/domains/actions.ts +239 -0
- package/src/organization-model/domains/customers.ts +78 -75
- package/src/organization-model/domains/entities.ts +144 -0
- package/src/organization-model/domains/goals.ts +83 -80
- package/src/organization-model/domains/knowledge.ts +74 -16
- package/src/organization-model/domains/navigation.ts +107 -384
- package/src/organization-model/domains/offerings.ts +71 -66
- package/src/organization-model/domains/policies.ts +102 -0
- package/src/organization-model/domains/projects.ts +14 -48
- package/src/organization-model/domains/prospecting.ts +62 -181
- package/src/organization-model/domains/resources.ts +81 -24
- package/src/organization-model/domains/roles.ts +13 -10
- package/src/organization-model/domains/sales.ts +10 -219
- package/src/organization-model/domains/shared.ts +57 -57
- package/src/organization-model/domains/statuses.ts +339 -130
- package/src/organization-model/domains/systems.ts +186 -29
- package/src/organization-model/foundation.ts +54 -67
- package/src/organization-model/graph/build.ts +682 -54
- package/src/organization-model/graph/link.ts +1 -1
- package/src/organization-model/graph/schema.ts +24 -9
- package/src/organization-model/graph/types.ts +20 -7
- package/src/organization-model/helpers.ts +231 -26
- package/src/organization-model/index.ts +116 -5
- package/src/organization-model/migration-helpers.ts +249 -0
- package/src/organization-model/organization-graph.mdx +16 -15
- package/src/organization-model/organization-model.mdx +89 -41
- package/src/organization-model/published.ts +120 -18
- package/src/organization-model/resolve.ts +117 -54
- package/src/organization-model/schema.ts +561 -140
- package/src/organization-model/surface-projection.ts +116 -122
- package/src/organization-model/types.ts +102 -21
- package/src/platform/constants/versions.ts +1 -1
- package/src/platform/registry/__tests__/command-view.test.ts +6 -8
- package/src/platform/registry/__tests__/resource-link.test.ts +13 -8
- package/src/platform/registry/__tests__/resource-registry.integration.test.ts +16 -31
- package/src/platform/registry/__tests__/resource-registry.nested-systems.test.ts +245 -0
- package/src/platform/registry/__tests__/resource-registry.test.ts +9 -7
- package/src/platform/registry/__tests__/validation.test.ts +15 -11
- package/src/platform/registry/resource-registry.ts +20 -8
- package/src/platform/registry/serialization.ts +7 -7
- package/src/platform/registry/types.ts +3 -3
- package/src/platform/registry/validation.ts +17 -15
- package/src/reference/_generated/contracts.md +362 -99
- package/src/reference/glossary.md +18 -18
- package/src/supabase/database.types.ts +60 -0
- package/src/test-utils/test-utils.test.ts +1 -6
- package/src/organization-model/__tests__/domains/operations.test.ts +0 -203
- package/src/organization-model/domains/features.ts +0 -31
- package/src/organization-model/domains/operations.ts +0 -85
|
@@ -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'
|
|
101
|
-
createMockWorkflow('support-workflow', 'dev'
|
|
90
|
+
createMockWorkflow('order-workflow', 'prod'),
|
|
91
|
+
createMockWorkflow('support-workflow', 'dev')
|
|
102
92
|
]
|
|
103
93
|
|
|
104
94
|
const agents = [
|
|
105
|
-
createMockAgent('order-agent', 'prod'
|
|
106
|
-
createMockAgent('support-agent', 'dev'
|
|
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
|
+
})
|
|
@@ -229,13 +229,15 @@ describe('ResourceRegistry', () => {
|
|
|
229
229
|
kind: 'operational',
|
|
230
230
|
governedByKnowledge: [],
|
|
231
231
|
drivesGoals: [],
|
|
232
|
-
|
|
232
|
+
lifecycle: 'active',
|
|
233
|
+
order: 10
|
|
233
234
|
}
|
|
234
235
|
const resource: ResourceEntry = {
|
|
235
236
|
id: 'workflow-1',
|
|
236
237
|
kind: 'workflow',
|
|
237
|
-
|
|
238
|
-
status: 'active'
|
|
238
|
+
systemPath: system.id,
|
|
239
|
+
status: 'active',
|
|
240
|
+
order: 10
|
|
239
241
|
}
|
|
240
242
|
const workflow = createMockWorkflow('workflow-1')
|
|
241
243
|
workflow.config.resource = resource
|
|
@@ -243,8 +245,8 @@ describe('ResourceRegistry', () => {
|
|
|
243
245
|
const registry = new ResourceRegistry({
|
|
244
246
|
'test-org': {
|
|
245
247
|
organizationModel: {
|
|
246
|
-
systems: {
|
|
247
|
-
resources: {
|
|
248
|
+
systems: { [system.id]: system },
|
|
249
|
+
resources: { [resource.id]: resource }
|
|
248
250
|
},
|
|
249
251
|
workflows: [workflow]
|
|
250
252
|
}
|
|
@@ -254,13 +256,13 @@ describe('ResourceRegistry', () => {
|
|
|
254
256
|
|
|
255
257
|
expect(result.workflows[0]).toMatchObject({
|
|
256
258
|
resourceId: 'workflow-1',
|
|
257
|
-
|
|
259
|
+
systemPath: 'sys.lead-gen',
|
|
258
260
|
governanceStatus: 'active',
|
|
259
261
|
system: {
|
|
260
262
|
id: 'sys.lead-gen',
|
|
261
263
|
title: 'Lead Generation',
|
|
262
264
|
kind: 'operational',
|
|
263
|
-
|
|
265
|
+
lifecycle: 'active'
|
|
264
266
|
}
|
|
265
267
|
})
|
|
266
268
|
})
|
|
@@ -289,7 +289,8 @@ describe('validateResourceGovernance', () => {
|
|
|
289
289
|
kind: 'operational' as const,
|
|
290
290
|
governedByKnowledge: [],
|
|
291
291
|
drivesGoals: [],
|
|
292
|
-
status: 'active' as const
|
|
292
|
+
status: 'active' as const,
|
|
293
|
+
order: 10
|
|
293
294
|
}
|
|
294
295
|
|
|
295
296
|
const systemB = {
|
|
@@ -299,23 +300,26 @@ describe('validateResourceGovernance', () => {
|
|
|
299
300
|
kind: 'operational' as const,
|
|
300
301
|
governedByKnowledge: [],
|
|
301
302
|
drivesGoals: [],
|
|
302
|
-
status: 'active' as const
|
|
303
|
+
status: 'active' as const,
|
|
304
|
+
order: 20
|
|
303
305
|
}
|
|
304
306
|
|
|
305
307
|
const workflowResource: ResourceEntry = {
|
|
306
308
|
id: 'lead-import',
|
|
307
309
|
kind: 'workflow',
|
|
308
|
-
|
|
309
|
-
status: 'active'
|
|
310
|
+
systemPath: 'sys.lead-gen',
|
|
311
|
+
status: 'active',
|
|
312
|
+
order: 10
|
|
310
313
|
}
|
|
311
314
|
|
|
312
315
|
const agentResource: ResourceEntry = {
|
|
313
316
|
id: 'lead-import',
|
|
314
317
|
kind: 'agent',
|
|
315
|
-
|
|
318
|
+
systemPath: 'sys.lead-gen',
|
|
316
319
|
status: 'active',
|
|
317
320
|
agentKind: 'specialist',
|
|
318
|
-
sessionCapable: false
|
|
321
|
+
sessionCapable: false,
|
|
322
|
+
order: 10
|
|
319
323
|
}
|
|
320
324
|
|
|
321
325
|
const createGovernedWorkflow = (
|
|
@@ -358,8 +362,8 @@ describe('validateResourceGovernance', () => {
|
|
|
358
362
|
})
|
|
359
363
|
|
|
360
364
|
const createModel = (resources: ResourceEntry[] = [workflowResource], systems = [systemA]) => ({
|
|
361
|
-
systems:
|
|
362
|
-
resources:
|
|
365
|
+
systems: Object.fromEntries(systems.map((s) => [s.id, s])),
|
|
366
|
+
resources: Object.fromEntries(resources.map((r) => [r.id, r]))
|
|
363
367
|
})
|
|
364
368
|
|
|
365
369
|
it('passes when code resources are descriptor-backed and match active OM Resources and Systems', () => {
|
|
@@ -483,7 +487,7 @@ describe('validateResourceGovernance', () => {
|
|
|
483
487
|
it('reports descriptor/OM system mismatches', () => {
|
|
484
488
|
const codeDescriptor: ResourceEntry = {
|
|
485
489
|
...workflowResource,
|
|
486
|
-
|
|
490
|
+
systemPath: 'sys.crm'
|
|
487
491
|
}
|
|
488
492
|
|
|
489
493
|
expect(() =>
|
|
@@ -502,7 +506,7 @@ describe('validateResourceGovernance', () => {
|
|
|
502
506
|
it('reports active OM resources that reference missing Systems', () => {
|
|
503
507
|
const resourceWithMissingSystem: ResourceEntry = {
|
|
504
508
|
...workflowResource,
|
|
505
|
-
|
|
509
|
+
systemPath: 'sys.missing'
|
|
506
510
|
}
|
|
507
511
|
|
|
508
512
|
expect(() =>
|
|
@@ -515,7 +519,7 @@ describe('validateResourceGovernance', () => {
|
|
|
515
519
|
createModel([resourceWithMissingSystem], [systemA]),
|
|
516
520
|
{ mode: 'strict' }
|
|
517
521
|
)
|
|
518
|
-
).toThrow("OM resource 'lead-import' references missing
|
|
522
|
+
).toThrow("OM resource 'lead-import' references missing system path 'sys.missing'.")
|
|
519
523
|
})
|
|
520
524
|
|
|
521
525
|
it('reports raw runtime resourceId authoring when a descriptor is required', () => {
|
|
@@ -11,9 +11,14 @@
|
|
|
11
11
|
|
|
12
12
|
import type { WorkflowDefinition } from '../../execution/engine/workflow/types'
|
|
13
13
|
import type { AgentDefinition } from '../../execution/engine/agent/core/types'
|
|
14
|
-
import type {
|
|
14
|
+
import type {
|
|
15
|
+
OrganizationModel,
|
|
16
|
+
OrganizationModelResources,
|
|
17
|
+
OrganizationModelSystems
|
|
18
|
+
} from '../../organization-model/types'
|
|
15
19
|
import type { ResourceEntry } from '../../organization-model/domains/resources'
|
|
16
20
|
import type { SystemEntry } from '../../organization-model/domains/systems'
|
|
21
|
+
import { listAllSystems } from '../../organization-model/helpers'
|
|
17
22
|
import type {
|
|
18
23
|
ResourceStatus,
|
|
19
24
|
ResourceDefinition,
|
|
@@ -52,10 +57,10 @@ function summarizeSystem(system: SystemEntry | undefined): ResourceDefinition['s
|
|
|
52
57
|
|
|
53
58
|
return {
|
|
54
59
|
id: system.id,
|
|
55
|
-
title: system.title,
|
|
60
|
+
title: system.label ?? system.title,
|
|
56
61
|
description: system.description,
|
|
57
62
|
kind: system.kind,
|
|
58
|
-
|
|
63
|
+
lifecycle: system.lifecycle
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
66
|
|
|
@@ -303,18 +308,25 @@ export class ResourceRegistry {
|
|
|
303
308
|
}
|
|
304
309
|
}
|
|
305
310
|
|
|
306
|
-
const resourcesById = new Map((orgResources.organizationModel?.resources
|
|
307
|
-
|
|
311
|
+
const resourcesById = new Map(Object.values(orgResources.organizationModel?.resources ?? {}).map((r) => [r.id, r]))
|
|
312
|
+
// Build a path-keyed map that includes nested systems (DFS via listAllSystems).
|
|
313
|
+
// resource.systemPath is the dot-separated system path used as the lookup key.
|
|
314
|
+
const omSystems = orgResources.organizationModel?.systems
|
|
315
|
+
const systemsByPath = new Map<string, SystemEntry>(
|
|
316
|
+
omSystems
|
|
317
|
+
? listAllSystems({ systems: omSystems } as OrganizationModel).map(({ path, system }) => [path, system])
|
|
318
|
+
: []
|
|
319
|
+
)
|
|
308
320
|
const getGovernanceMetadata = (
|
|
309
321
|
resourceId: string,
|
|
310
322
|
descriptor: ResourceEntry | undefined
|
|
311
|
-
): Pick<ResourceDefinition, '
|
|
323
|
+
): Pick<ResourceDefinition, 'systemPath' | 'system' | 'governanceStatus'> => {
|
|
312
324
|
const resource = descriptor ?? resourcesById.get(resourceId)
|
|
313
325
|
if (!resource) return {}
|
|
314
326
|
|
|
315
327
|
return {
|
|
316
|
-
|
|
317
|
-
system: summarizeSystem(
|
|
328
|
+
systemPath: resource.systemPath,
|
|
329
|
+
system: summarizeSystem(systemsByPath.get(resource.systemPath)),
|
|
318
330
|
governanceStatus: resource.status
|
|
319
331
|
}
|
|
320
332
|
}
|
|
@@ -24,27 +24,27 @@ function summarizeSystem(system: SystemEntry | undefined): ResourceDefinition['s
|
|
|
24
24
|
|
|
25
25
|
return {
|
|
26
26
|
id: system.id,
|
|
27
|
-
title: system.title,
|
|
27
|
+
title: system.label ?? system.title,
|
|
28
28
|
description: system.description,
|
|
29
29
|
kind: system.kind,
|
|
30
|
-
|
|
30
|
+
lifecycle: system.lifecycle
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function createGovernanceMetadataResolver(resources: DeploymentSpec) {
|
|
35
|
-
const resourcesById = new Map((resources.organizationModel?.resources
|
|
36
|
-
const systemsById = new Map((resources.organizationModel?.systems
|
|
35
|
+
const resourcesById = new Map(Object.values(resources.organizationModel?.resources ?? {}).map((r) => [r.id, r]))
|
|
36
|
+
const systemsById = new Map(Object.values(resources.organizationModel?.systems ?? {}).map((s) => [s.id, s]))
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
39
|
resourceId: string,
|
|
40
40
|
descriptor: ResourceEntry | undefined
|
|
41
|
-
): Pick<ResourceDefinition, '
|
|
41
|
+
): Pick<ResourceDefinition, 'systemPath' | 'system' | 'governanceStatus'> => {
|
|
42
42
|
const resource = descriptor ?? resourcesById.get(resourceId)
|
|
43
43
|
if (!resource) return {}
|
|
44
44
|
|
|
45
45
|
return {
|
|
46
|
-
|
|
47
|
-
system: summarizeSystem(systemsById.get(resource.
|
|
46
|
+
systemPath: resource.systemPath,
|
|
47
|
+
system: summarizeSystem(systemsById.get(resource.systemPath)),
|
|
48
48
|
governanceStatus: resource.status
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -28,7 +28,7 @@ export type ResourceType = 'agent' | 'workflow' | 'trigger' | 'integration' | 'e
|
|
|
28
28
|
*/
|
|
29
29
|
export type ExecutableResourceType = 'workflow' | 'agent'
|
|
30
30
|
|
|
31
|
-
export type ResourceSystemSummary = Pick<SystemEntry, 'id' | 'title' | 'description' | 'kind' | '
|
|
31
|
+
export type ResourceSystemSummary = Pick<SystemEntry, 'id' | 'title' | 'description' | 'kind' | 'lifecycle'>
|
|
32
32
|
|
|
33
33
|
// ============================================================================
|
|
34
34
|
// Base Resource Interface
|
|
@@ -69,8 +69,8 @@ export interface ResourceDefinition {
|
|
|
69
69
|
/** Whether the resource is local (monorepo) or remote (externally deployed) */
|
|
70
70
|
origin?: 'local' | 'remote'
|
|
71
71
|
|
|
72
|
-
/** OM System membership, when backed by a Resource descriptor */
|
|
73
|
-
|
|
72
|
+
/** OM System membership — dot-separated system path (e.g. "sys.lead-gen"), when backed by a Resource descriptor */
|
|
73
|
+
systemPath?: string
|
|
74
74
|
|
|
75
75
|
/** Display metadata for the owning OM System */
|
|
76
76
|
system?: ResourceSystemSummary
|