@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
@@ -1,25 +1,22 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
  import { DEFAULT_ORGANIZATION_MODEL } from '../defaults'
3
- import { DEFAULT_ORGANIZATION_MODEL_BRANDING } from '../domains/branding'
4
- import { OrganizationModelBrandingSchema } from '../domains/branding'
5
- import { DEFAULT_ORGANIZATION_MODEL_SALES } from '../domains/sales'
6
- import { OrganizationModelSalesSchema } from '../domains/sales'
7
- import { DEFAULT_ORGANIZATION_MODEL_PROJECTS } from '../domains/projects'
8
- import { OrganizationModelProjectsSchema } from '../domains/projects'
9
- import { DEFAULT_ORGANIZATION_MODEL_PROSPECTING } from '../domains/prospecting'
10
- import { OrganizationModelProspectingSchema } from '../domains/prospecting'
11
- import { DEFAULT_ORGANIZATION_MODEL_NAVIGATION } from '../domains/navigation'
12
- import { OrganizationModelNavigationSchema } from '../domains/navigation'
13
- import { DEFAULT_ORGANIZATION_MODEL_OPERATIONS } from '../domains/operations'
14
- import { OperationsDomainSchema } from '../domains/operations'
15
- import { DEFAULT_ORGANIZATION_MODEL_STATUSES } from '../domains/statuses'
16
- import { StatusesDomainSchema } from '../domains/statuses'
3
+ import { DEFAULT_ORGANIZATION_MODEL_BRANDING, OrganizationModelBrandingSchema } from '../domains/branding'
4
+ import { DEFAULT_ORGANIZATION_MODEL_ENTITIES, EntitiesDomainSchema } from '../domains/entities'
5
+ import { DEFAULT_ORGANIZATION_MODEL_STATUSES, StatusesDomainSchema } from '../domains/statuses'
6
+ import { DEFAULT_ORGANIZATION_MODEL_SYSTEMS, SystemsDomainSchema } from '../domains/systems'
17
7
  import { resolveOrganizationModel } from '../resolve'
18
8
  import { OrganizationModelSchema } from '../schema'
9
+ import { DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE } from '../defaults'
19
10
 
20
- // All DEFAULT_ORGANIZATION_MODEL* constants and the schemas used to validate them.
21
- // The composite constant lives in defaults.ts; domain sub-constants live in their
22
- // respective domain files. All are covered here for roundtrip integrity.
11
+ // Phase 4 (D8): sales, prospecting, projects, navigation top-level OM fields removed.
12
+ // DEFAULT_ORGANIZATION_MODEL_SALES / OrganizationModelSalesSchema,
13
+ // DEFAULT_ORGANIZATION_MODEL_PROJECTS / OrganizationModelProjectsSchema,
14
+ // DEFAULT_ORGANIZATION_MODEL_PROSPECTING / OrganizationModelProspectingSchema,
15
+ // DEFAULT_ORGANIZATION_MODEL_NAVIGATION / OrganizationModelNavigationSchema
16
+ // are no longer exported from their respective domain files.
17
+ // Tests that depended on these exports are skipped with explicit reason comments.
18
+
19
+ // Only the domain constants and schemas that still exist are covered here.
23
20
  const domainCases = [
24
21
  {
25
22
  name: 'DEFAULT_ORGANIZATION_MODEL_BRANDING',
@@ -27,24 +24,9 @@ const domainCases = [
27
24
  schema: OrganizationModelBrandingSchema
28
25
  },
29
26
  {
30
- name: 'DEFAULT_ORGANIZATION_MODEL_SALES',
31
- constant: DEFAULT_ORGANIZATION_MODEL_SALES,
32
- schema: OrganizationModelSalesSchema
33
- },
34
- {
35
- name: 'DEFAULT_ORGANIZATION_MODEL_PROJECTS',
36
- constant: DEFAULT_ORGANIZATION_MODEL_PROJECTS,
37
- schema: OrganizationModelProjectsSchema
38
- },
39
- {
40
- name: 'DEFAULT_ORGANIZATION_MODEL_PROSPECTING',
41
- constant: DEFAULT_ORGANIZATION_MODEL_PROSPECTING,
42
- schema: OrganizationModelProspectingSchema
43
- },
44
- {
45
- name: 'DEFAULT_ORGANIZATION_MODEL_NAVIGATION',
46
- constant: DEFAULT_ORGANIZATION_MODEL_NAVIGATION,
47
- schema: OrganizationModelNavigationSchema
27
+ name: 'DEFAULT_ORGANIZATION_MODEL_ENTITIES',
28
+ constant: DEFAULT_ORGANIZATION_MODEL_ENTITIES,
29
+ schema: EntitiesDomainSchema
48
30
  },
49
31
  {
50
32
  name: 'DEFAULT_ORGANIZATION_MODEL_STATUSES',
@@ -52,9 +34,9 @@ const domainCases = [
52
34
  schema: StatusesDomainSchema
53
35
  },
54
36
  {
55
- name: 'DEFAULT_ORGANIZATION_MODEL_OPERATIONS',
56
- constant: DEFAULT_ORGANIZATION_MODEL_OPERATIONS,
57
- schema: OperationsDomainSchema
37
+ name: 'DEFAULT_ORGANIZATION_MODEL_SYSTEMS',
38
+ constant: DEFAULT_ORGANIZATION_MODEL_SYSTEMS,
39
+ schema: SystemsDomainSchema
58
40
  }
59
41
  ] as const
60
42
 
@@ -75,17 +57,14 @@ describe('organization-model defaults', () => {
75
57
  expect(fromDefault).toEqual(fromUndefined)
76
58
  })
77
59
 
78
- it('keeps Command View enabled but development-only in the default Knowledge navigation', () => {
79
- const result = resolveOrganizationModel(undefined)
80
- const commandViewFeature = result.features.find((feature) => feature.id === 'knowledge.command-view')
81
- const commandViewSurface = DEFAULT_ORGANIZATION_MODEL_NAVIGATION.surfaces.find(
82
- (surface) => surface.id === 'knowledge.command-view'
83
- )
84
-
85
- expect(commandViewFeature?.enabled).toBe(true)
86
- expect(commandViewFeature?.devOnly).toBe(true)
87
- expect(commandViewSurface?.enabled).toBe(true)
88
- expect(commandViewSurface?.devOnly).toBe(true)
60
+ // Phase 4 (D8): model.navigation removed. The knowledge.command-view surface tracking
61
+ // previously used DEFAULT_ORGANIZATION_MODEL_NAVIGATION.surfaces — skipped since that
62
+ // constant is deleted. The system itself still exists; only the navigation surface
63
+ // reference is gone from the top-level schema.
64
+ it.skip('keeps Command View enabled but development-only in the default Knowledge navigation (deferred — Phase 4: navigation domain removed)', () => {
65
+ // Previously checked DEFAULT_ORGANIZATION_MODEL_NAVIGATION.surfaces.
66
+ // The command-view system still exists in DEFAULT_ORGANIZATION_MODEL.systems.
67
+ // Re-enable with a top-level surfaces Record fixture if that assertion is needed.
89
68
  })
90
69
  })
91
70
 
@@ -95,84 +74,71 @@ describe('organization-model defaults', () => {
95
74
  })
96
75
  })
97
76
 
98
- describe('DEFAULT_ORGANIZATION_MODEL_BRANDING via resolveOrganizationModel', () => {
99
- it('resolving with branding override produces a schema-valid model', () => {
100
- const result = resolveOrganizationModel({ branding: DEFAULT_ORGANIZATION_MODEL_BRANDING })
101
- expect(() => OrganizationModelSchema.parse(result)).not.toThrow()
102
- })
103
- })
104
-
105
- describe('DEFAULT_ORGANIZATION_MODEL_SALES via resolveOrganizationModel', () => {
77
+ // Phase 4 (D8): OrganizationModelSalesSchema, DEFAULT_ORGANIZATION_MODEL_SALES removed.
78
+ describe.skip('DEFAULT_ORGANIZATION_MODEL_SALES via resolveOrganizationModel (deferred Phase 4: sales domain removed)', () => {
106
79
  it('resolving with sales override produces a schema-valid model', () => {
107
- const result = resolveOrganizationModel({ sales: DEFAULT_ORGANIZATION_MODEL_SALES })
108
- expect(() => OrganizationModelSchema.parse(result)).not.toThrow()
80
+ // Previously: resolveOrganizationModel({ sales: DEFAULT_ORGANIZATION_MODEL_SALES })
81
+ // Sales data now lives in system.content. Use getAllPipelines(model) from migration-helpers.
109
82
  })
110
83
  })
111
84
 
112
- describe('DEFAULT_ORGANIZATION_MODEL_PROJECTS via resolveOrganizationModel', () => {
85
+ // Phase 4 (D8): OrganizationModelProjectsSchema, DEFAULT_ORGANIZATION_MODEL_PROJECTS removed.
86
+ describe.skip('DEFAULT_ORGANIZATION_MODEL_PROJECTS via resolveOrganizationModel (deferred — Phase 4: projects domain removed)', () => {
113
87
  it('resolving with projects override produces a schema-valid model', () => {
114
- const result = resolveOrganizationModel({ projects: DEFAULT_ORGANIZATION_MODEL_PROJECTS })
115
- expect(() => OrganizationModelSchema.parse(result)).not.toThrow()
88
+ // Previously: resolveOrganizationModel({ projects: DEFAULT_ORGANIZATION_MODEL_PROJECTS })
89
+ // Project statuses now live in system.content. Use getAllProjectStatuses(model) from migration-helpers.
116
90
  })
117
91
  })
118
92
 
119
- describe('DEFAULT_ORGANIZATION_MODEL_PROSPECTING via resolveOrganizationModel', () => {
93
+ // Phase 4 (D8): OrganizationModelProspectingSchema, DEFAULT_ORGANIZATION_MODEL_PROSPECTING removed.
94
+ describe.skip('DEFAULT_ORGANIZATION_MODEL_PROSPECTING via resolveOrganizationModel (deferred — Phase 4: prospecting domain removed)', () => {
120
95
  it('resolving with prospecting override produces a schema-valid model', () => {
121
- const result = resolveOrganizationModel({ prospecting: DEFAULT_ORGANIZATION_MODEL_PROSPECTING })
122
- expect(() => OrganizationModelSchema.parse(result)).not.toThrow()
96
+ // Previously: resolveOrganizationModel({ prospecting: DEFAULT_ORGANIZATION_MODEL_PROSPECTING })
97
+ // Prospecting stages/templates now live in system.content. Use getAllProspectingStages() / getAllBuildTemplates().
123
98
  })
124
99
  })
125
100
 
126
- describe('DEFAULT_ORGANIZATION_MODEL_NAVIGATION via resolveOrganizationModel', () => {
101
+ // Phase 4 (D8): OrganizationModelNavigationSchema, DEFAULT_ORGANIZATION_MODEL_NAVIGATION removed.
102
+ describe.skip('DEFAULT_ORGANIZATION_MODEL_NAVIGATION via resolveOrganizationModel (deferred — Phase 4: navigation domain removed)', () => {
127
103
  it('resolving with navigation override produces a schema-valid model', () => {
128
- const result = resolveOrganizationModel({ navigation: DEFAULT_ORGANIZATION_MODEL_NAVIGATION })
129
- expect(() => OrganizationModelSchema.parse(result)).not.toThrow()
104
+ // Previously: resolveOrganizationModel({ navigation: DEFAULT_ORGANIZATION_MODEL_NAVIGATION })
105
+ // Surfaces and navigation groups are now top-level Records on OrganizationModelSchemaBase.
130
106
  })
131
107
  })
132
108
 
133
- describe('DEFAULT_ORGANIZATION_MODEL_OPERATIONS via resolveOrganizationModel', () => {
134
- it('resolving with operations override produces a schema-valid model', () => {
135
- const result = resolveOrganizationModel({ operations: DEFAULT_ORGANIZATION_MODEL_OPERATIONS })
109
+ describe('DEFAULT_ORGANIZATION_MODEL_BRANDING via resolveOrganizationModel', () => {
110
+ it('resolving with branding override produces a schema-valid model', () => {
111
+ const result = resolveOrganizationModel({ branding: DEFAULT_ORGANIZATION_MODEL_BRANDING })
136
112
  expect(() => OrganizationModelSchema.parse(result)).not.toThrow()
137
113
  })
138
-
139
- it('default operations seed covers all 5 entity categories', () => {
140
- expect(DEFAULT_ORGANIZATION_MODEL_OPERATIONS.entries).toHaveLength(5)
141
- })
142
-
143
- it('every entry has a non-empty id, label, and semanticClass', () => {
144
- for (const entry of DEFAULT_ORGANIZATION_MODEL_OPERATIONS.entries) {
145
- expect(entry.id.length).toBeGreaterThan(0)
146
- expect(entry.label.length).toBeGreaterThan(0)
147
- expect(entry.semanticClass.length).toBeGreaterThan(0)
148
- }
149
- })
150
-
151
- it('all entry ids are unique', () => {
152
- const ids = DEFAULT_ORGANIZATION_MODEL_OPERATIONS.entries.map((e) => e.id)
153
- const uniqueIds = new Set(ids)
154
- expect(uniqueIds.size).toBe(ids.length)
155
- })
156
114
  })
157
115
 
158
116
  describe('DEFAULT_ORGANIZATION_MODEL_STATUSES via resolveOrganizationModel', () => {
159
- it('resolving with statuses override produces a schema-valid model', () => {
160
- const result = resolveOrganizationModel({ statuses: DEFAULT_ORGANIZATION_MODEL_STATUSES })
161
- expect(() => OrganizationModelSchema.parse(result)).not.toThrow()
117
+ // Phase 4 (D1): statuses top-level field removed from OM schema.
118
+ // DEFAULT_ORGANIZATION_MODEL_STATUSES is still exported from domains/statuses.ts
119
+ // (it's used by the UI statuses domain as a semantic registry, not OM-schema-level data).
120
+ // The resolveOrganizationModel override with { statuses: ... } was silently accepted
121
+ // before Phase 4 because statuses was an extra field; now statuses is gone from OM entirely.
122
+ // We keep the data-integrity checks below; the resolveOrganizationModel override test is skipped.
123
+ it.skip('resolving with statuses override produces a schema-valid model (deferred — Phase 4: statuses field removed from OM schema)', () => {
124
+ // Previously: resolveOrganizationModel({ statuses: DEFAULT_ORGANIZATION_MODEL_STATUSES })
125
+ // Status data now lives in system.content via (schema:status-flow) + (schema:status) content nodes.
162
126
  })
163
127
 
164
128
  it('default statuses seed covers all 9 delivery.task values', () => {
165
- const taskEntries = DEFAULT_ORGANIZATION_MODEL_STATUSES.entries.filter((e) => e.semanticClass === 'delivery.task')
129
+ const taskEntries = Object.values(DEFAULT_ORGANIZATION_MODEL_STATUSES).filter(
130
+ (e) => e.semanticClass === 'delivery.task'
131
+ )
166
132
  expect(taskEntries).toHaveLength(9)
167
133
  })
168
134
 
169
135
  it('default statuses seed covers all 5 queue values', () => {
170
- const queueEntries = DEFAULT_ORGANIZATION_MODEL_STATUSES.entries.filter((e) => e.semanticClass === 'queue')
136
+ const queueEntries = Object.values(DEFAULT_ORGANIZATION_MODEL_STATUSES).filter((e) => e.semanticClass === 'queue')
171
137
  expect(queueEntries).toHaveLength(5)
172
138
  })
173
139
 
174
140
  it('every entry has a non-empty id, label, and semanticClass', () => {
175
- for (const entry of DEFAULT_ORGANIZATION_MODEL_STATUSES.entries) {
141
+ for (const entry of Object.values(DEFAULT_ORGANIZATION_MODEL_STATUSES)) {
176
142
  expect(entry.id.length).toBeGreaterThan(0)
177
143
  expect(entry.label.length).toBeGreaterThan(0)
178
144
  expect(entry.semanticClass.length).toBeGreaterThan(0)
@@ -180,9 +146,23 @@ describe('organization-model defaults', () => {
180
146
  })
181
147
 
182
148
  it('all entry ids are unique', () => {
183
- const ids = DEFAULT_ORGANIZATION_MODEL_STATUSES.entries.map((e) => e.id)
149
+ const ids = Object.values(DEFAULT_ORGANIZATION_MODEL_STATUSES).map((e) => e.id)
184
150
  const uniqueIds = new Set(ids)
185
151
  expect(uniqueIds.size).toBe(ids.length)
186
152
  })
187
153
  })
154
+
155
+ describe('DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE — flat Record (Phase 4 D3)', () => {
156
+ it('is an empty object (no pre-seeded nodes in generic base)', () => {
157
+ expect(DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE).toEqual({})
158
+ })
159
+
160
+ it('does not have a .nodes array (old wrapper shape removed)', () => {
161
+ expect(DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE).not.toHaveProperty('nodes')
162
+ })
163
+
164
+ it('does not have a .version field (moved to domainMetadata.knowledge)', () => {
165
+ expect(DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE).not.toHaveProperty('version')
166
+ })
167
+ })
188
168
  })
@@ -0,0 +1,56 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { ActionsDomainSchema, ActionInvocationSchema, DEFAULT_ORGANIZATION_MODEL_ACTIONS } from '../../domains/actions'
3
+
4
+ describe('actions domain', () => {
5
+ it('defaults lead-gen action entries with invocation contracts', () => {
6
+ const domain = ActionsDomainSchema.parse(DEFAULT_ORGANIZATION_MODEL_ACTIONS)
7
+
8
+ expect(Object.keys(domain)).toHaveLength(13)
9
+ expect(domain['lead-gen.company.source']).toMatchObject({
10
+ id: 'lead-gen.company.source',
11
+ scope: { domain: 'sales' },
12
+ lifecycle: 'active'
13
+ })
14
+ expect(Object.values(domain).every((action) => action.invocations.length > 0)).toBe(true)
15
+ })
16
+
17
+ it('accepts entity references in affects', () => {
18
+ expect(() =>
19
+ ActionsDomainSchema.parse({
20
+ 'crm.deal.update': {
21
+ id: 'crm.deal.update',
22
+ order: 10,
23
+ label: 'Update deal',
24
+ affects: ['crm.deal']
25
+ }
26
+ })
27
+ ).not.toThrow()
28
+ })
29
+
30
+ it('accepts every invocation kind', () => {
31
+ expect(() =>
32
+ ActionInvocationSchema.parse({
33
+ kind: 'slash-command',
34
+ command: '/lead-gen source',
35
+ toolFactory: 'lead-gen-source'
36
+ })
37
+ ).not.toThrow()
38
+ expect(() => ActionInvocationSchema.parse({ kind: 'mcp-tool', server: 'lead-gen', name: 'source' })).not.toThrow()
39
+ expect(() =>
40
+ ActionInvocationSchema.parse({
41
+ kind: 'api-endpoint',
42
+ method: 'POST',
43
+ path: '/api/prospecting/source',
44
+ requestSchema: 'source-request',
45
+ responseSchema: 'source-response'
46
+ })
47
+ ).not.toThrow()
48
+ expect(() =>
49
+ ActionInvocationSchema.parse({ kind: 'script-execution', resourceId: 'scripts.lead-gen-source' })
50
+ ).not.toThrow()
51
+ })
52
+
53
+ it('rejects malformed slash commands', () => {
54
+ expect(() => ActionInvocationSchema.parse({ kind: 'slash-command', command: 'lead-gen source' })).toThrow()
55
+ })
56
+ })