@elevasis/core 0.25.0 → 0.26.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 (66) hide show
  1. package/dist/index.d.ts +166 -85
  2. package/dist/index.js +146 -1346
  3. package/dist/knowledge/index.d.ts +27 -38
  4. package/dist/knowledge/index.js +1 -1
  5. package/dist/organization-model/index.d.ts +166 -85
  6. package/dist/organization-model/index.js +146 -1346
  7. package/dist/test-utils/index.d.ts +23 -31
  8. package/dist/test-utils/index.js +75 -1238
  9. package/package.json +1 -1
  10. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +14 -2
  11. package/src/business/acquisition/api-schemas.test.ts +70 -77
  12. package/src/business/acquisition/api-schemas.ts +21 -42
  13. package/src/business/acquisition/derive-actions.test.ts +11 -21
  14. package/src/business/acquisition/derive-actions.ts +61 -14
  15. package/src/business/acquisition/ontology-validation.ts +4 -4
  16. package/src/business/acquisition/types.ts +7 -8
  17. package/src/knowledge/queries.ts +0 -1
  18. package/src/organization-model/__tests__/content-kinds-registry.test.ts +35 -210
  19. package/src/organization-model/__tests__/defaults.test.ts +4 -4
  20. package/src/organization-model/__tests__/domains/actions.test.ts +12 -36
  21. package/src/organization-model/__tests__/domains/offerings.test.ts +13 -6
  22. package/src/organization-model/__tests__/domains/resources.test.ts +497 -350
  23. package/src/organization-model/__tests__/domains/systems.test.ts +6 -7
  24. package/src/organization-model/__tests__/flatten-additive-merge.test.ts +68 -80
  25. package/src/organization-model/__tests__/foundation.test.ts +81 -14
  26. package/src/organization-model/__tests__/graph.test.ts +662 -694
  27. package/src/organization-model/__tests__/knowledge.test.ts +31 -17
  28. package/src/organization-model/__tests__/lookup-helpers.test.ts +128 -438
  29. package/src/organization-model/__tests__/migration-helpers.test.ts +362 -591
  30. package/src/organization-model/__tests__/prospecting-ssot.test.ts +68 -103
  31. package/src/organization-model/__tests__/published-zero-leak.test.ts +17 -0
  32. package/src/organization-model/__tests__/recursive-system-schema.test.ts +159 -532
  33. package/src/organization-model/__tests__/resolve.test.ts +79 -42
  34. package/src/organization-model/__tests__/schema.test.ts +65 -56
  35. package/src/organization-model/catalogs/lead-gen.ts +0 -103
  36. package/src/organization-model/defaults.ts +17 -702
  37. package/src/organization-model/domains/actions.ts +116 -333
  38. package/src/organization-model/domains/knowledge.ts +15 -7
  39. package/src/organization-model/domains/projects.ts +4 -4
  40. package/src/organization-model/domains/prospecting.ts +405 -395
  41. package/src/organization-model/domains/resources.ts +206 -135
  42. package/src/organization-model/domains/sales.ts +5 -5
  43. package/src/organization-model/domains/systems.ts +8 -23
  44. package/src/organization-model/graph/build.ts +223 -294
  45. package/src/organization-model/graph/schema.ts +2 -3
  46. package/src/organization-model/graph/types.ts +12 -14
  47. package/src/organization-model/helpers.ts +130 -218
  48. package/src/organization-model/index.ts +104 -124
  49. package/src/organization-model/migration-helpers.ts +211 -249
  50. package/src/organization-model/ontology.ts +0 -60
  51. package/src/organization-model/organization-graph.mdx +4 -5
  52. package/src/organization-model/organization-model.mdx +1 -1
  53. package/src/organization-model/published.ts +236 -226
  54. package/src/organization-model/resolve.ts +4 -5
  55. package/src/organization-model/schema.ts +610 -704
  56. package/src/organization-model/types.ts +167 -161
  57. package/src/platform/registry/__tests__/validation.test.ts +23 -0
  58. package/src/platform/registry/validation.ts +13 -2
  59. package/src/reference/_generated/contracts.md +14 -2
  60. package/src/organization-model/content-kinds/config.ts +0 -36
  61. package/src/organization-model/content-kinds/index.ts +0 -78
  62. package/src/organization-model/content-kinds/pipeline.ts +0 -68
  63. package/src/organization-model/content-kinds/registry.ts +0 -44
  64. package/src/organization-model/content-kinds/status.ts +0 -71
  65. package/src/organization-model/content-kinds/template.ts +0 -83
  66. package/src/organization-model/content-kinds/types.ts +0 -117
@@ -3,54 +3,109 @@ import { DescriptionSchema, LabelSchema, ModelIdSchema } from './shared'
3
3
  import { SystemPathSchema, SystemLifecycleSchema } from './systems'
4
4
  import { ActionInvocationSchema } from './actions'
5
5
  import { OntologyIdSchema } from '../ontology'
6
-
7
- // ---------------------------------------------------------------------------
8
- // Resources domain
9
- // ---------------------------------------------------------------------------
10
- //
11
- // Resources are governance-only OM descriptors. Runtime code imports these
12
- // descriptors and attaches executable behavior; it does not re-author identity.
13
-
14
- export const ResourceKindSchema = z
15
- .enum(['workflow', 'agent', 'integration', 'script'])
16
- .meta({ label: 'Resource kind', color: 'orange' })
17
- export const ResourceGovernanceStatusSchema = z
18
- .enum(['active', 'deprecated', 'archived'])
19
- .meta({ label: 'Governance status', color: 'teal' })
20
- export const AgentKindSchema = z
21
- .enum(['orchestrator', 'specialist', 'utility', 'platform'])
22
- .meta({ label: 'Agent kind', color: 'violet' })
23
- export const ScriptResourceLanguageSchema = z.enum(['shell', 'sql', 'typescript', 'python']).meta({ label: 'Language' })
24
- export const CodeReferenceRoleSchema = z
25
- .enum(['entrypoint', 'handler', 'schema', 'test', 'docs', 'config'])
26
- .meta({ label: 'Code reference role', color: 'blue' })
27
-
28
- export const ResourceIdSchema = z
29
- .string()
30
- .trim()
31
- .min(1)
32
- .max(255)
33
- .regex(/^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*$/, 'Resource IDs must use letters, numbers, -, _, or . separators')
34
-
35
- export const EventIdSchema = z
36
- .string()
37
- .trim()
38
- .min(1)
39
- .max(300)
40
- .regex(
41
- /^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*:[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
42
- 'Event IDs must use <owner-id>:<event-key>'
43
- )
44
-
45
- export const EventKeySchema = ModelIdSchema
46
-
47
- export const EventEmissionDescriptorSchema = z.object({
48
- eventKey: EventKeySchema,
49
- label: z.string().trim().min(1).max(120),
50
- payloadSchema: ModelIdSchema.optional(),
51
- lifecycle: SystemLifecycleSchema.optional()
52
- })
53
-
6
+
7
+ // ---------------------------------------------------------------------------
8
+ // ContractRef — portable, browser-safe ref string for workflow I/O contracts
9
+ // ---------------------------------------------------------------------------
10
+ //
11
+ // Format: `package/subpath#ExportName`
12
+ // Examples:
13
+ // `@repo/elevasis-core/contracts/apollo-import#inputSchema`
14
+ // `@repo/elevasis-core/contracts/dtc-subscription-score#outputSchema`
15
+ //
16
+ // Tier-1 validation (schema.ts superRefine): ref-string SHAPE only no import
17
+ // Tier-2 validation (om:verify): intra-@repo/elevasis-core typed-map resolution
18
+
19
+ /** Portable `package/subpath#ExportName` contract reference string. Browser-safe; no imports. */
20
+ export const ContractRefSchema = z
21
+ .string()
22
+ .trim()
23
+ .min(1)
24
+ .max(500)
25
+ .regex(
26
+ /^[A-Za-z0-9@](?:[A-Za-z0-9_./@-]*[A-Za-z0-9_])?\/?[A-Za-z0-9_./@-]*#[A-Za-z_$][A-Za-z0-9_$]*$/,
27
+ 'ContractRef must be in the format package/subpath#ExportName (e.g. @repo/elevasis-core/contracts/apollo-import#inputSchema)'
28
+ )
29
+
30
+ export type ContractRef = z.infer<typeof ContractRefSchema>
31
+
32
+ /** Parsed representation of a ContractRef string. */
33
+ export interface ParsedContractRef {
34
+ /** The full package + subpath portion before `#`. */
35
+ moduleSpecifier: string
36
+ /** The export name after `#`. */
37
+ exportName: string
38
+ }
39
+
40
+ /**
41
+ * Parse a `package/subpath#ExportName` contract ref string.
42
+ * Browser-safe no module system interaction.
43
+ *
44
+ * @throws {Error} if the ref string does not match the expected format.
45
+ */
46
+ export function parseContractRef(ref: string): ParsedContractRef {
47
+ const hashIndex = ref.lastIndexOf('#')
48
+ if (hashIndex === -1) {
49
+ throw new Error(`ContractRef "${ref}" is missing the required "#ExportName" suffix`)
50
+ }
51
+ const moduleSpecifier = ref.slice(0, hashIndex)
52
+ const exportName = ref.slice(hashIndex + 1)
53
+ if (!moduleSpecifier) {
54
+ throw new Error(`ContractRef "${ref}" has an empty module specifier before "#"`)
55
+ }
56
+ if (!exportName) {
57
+ throw new Error(`ContractRef "${ref}" has an empty export name after "#"`)
58
+ }
59
+ return { moduleSpecifier, exportName }
60
+ }
61
+
62
+ // ---------------------------------------------------------------------------
63
+ // Resources domain
64
+ // ---------------------------------------------------------------------------
65
+ //
66
+ // Resources are governance-only OM descriptors. Runtime code imports these
67
+ // descriptors and attaches executable behavior; it does not re-author identity.
68
+
69
+ export const ResourceKindSchema = z
70
+ .enum(['workflow', 'agent', 'integration', 'script'])
71
+ .meta({ label: 'Resource kind', color: 'orange' })
72
+ export const ResourceGovernanceStatusSchema = z
73
+ .enum(['active', 'deprecated', 'archived'])
74
+ .meta({ label: 'Governance status', color: 'teal' })
75
+ export const AgentKindSchema = z
76
+ .enum(['orchestrator', 'specialist', 'utility', 'platform'])
77
+ .meta({ label: 'Agent kind', color: 'violet' })
78
+ export const ScriptResourceLanguageSchema = z.enum(['shell', 'sql', 'typescript', 'python']).meta({ label: 'Language' })
79
+ export const CodeReferenceRoleSchema = z
80
+ .enum(['entrypoint', 'handler', 'schema', 'test', 'docs', 'config'])
81
+ .meta({ label: 'Code reference role', color: 'blue' })
82
+
83
+ export const ResourceIdSchema = z
84
+ .string()
85
+ .trim()
86
+ .min(1)
87
+ .max(255)
88
+ .regex(/^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*$/, 'Resource IDs must use letters, numbers, -, _, or . separators')
89
+
90
+ export const EventIdSchema = z
91
+ .string()
92
+ .trim()
93
+ .min(1)
94
+ .max(300)
95
+ .regex(
96
+ /^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*:[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
97
+ 'Event IDs must use <owner-id>:<event-key>'
98
+ )
99
+
100
+ export const EventKeySchema = ModelIdSchema
101
+
102
+ export const EventEmissionDescriptorSchema = z.object({
103
+ eventKey: EventKeySchema,
104
+ label: z.string().trim().min(1).max(120),
105
+ payloadSchema: ModelIdSchema.optional(),
106
+ lifecycle: SystemLifecycleSchema.optional()
107
+ })
108
+
54
109
  export const EventDescriptorSchema = EventEmissionDescriptorSchema.extend({
55
110
  id: EventIdSchema,
56
111
  ownerId: z.union([ResourceIdSchema, ModelIdSchema]),
@@ -64,7 +119,22 @@ export const ResourceOntologyBindingSchema = z
64
119
  reads: z.array(OntologyIdSchema).optional(),
65
120
  writes: z.array(OntologyIdSchema).optional(),
66
121
  usesCatalogs: z.array(OntologyIdSchema).optional(),
67
- emits: z.array(OntologyIdSchema).optional()
122
+ emits: z.array(OntologyIdSchema).optional(),
123
+ /**
124
+ * Optional typed contract binding for this resource's workflow I/O.
125
+ * Each ref is a `package/subpath#ExportName` string that resolves to a
126
+ * Zod schema in `@repo/elevasis-core` (or the consumer's equivalent package).
127
+ *
128
+ * Absence of this field preserves all existing behavior — it is additive + optional.
129
+ * Tier-1 validation (schema.ts): ref-string shape only (browser-safe, no imports).
130
+ * Tier-2 validation (om:verify): intra-package typed-map resolution asserts ZodType.
131
+ */
132
+ contract: z
133
+ .object({
134
+ input: ContractRefSchema.optional(),
135
+ output: ContractRefSchema.optional()
136
+ })
137
+ .optional()
68
138
  })
69
139
  .superRefine((binding, ctx) => {
70
140
  if (binding.primaryAction === undefined) return
@@ -89,29 +159,29 @@ type ResourceOntologyBindingInput = {
89
159
 
90
160
  export const CodeReferenceSchema = z.object({
91
161
  path: z
92
- .string()
93
- .trim()
94
- .min(1)
95
- .max(500)
96
- .regex(/^[A-Za-z0-9_./$@()[\] -]+$/, 'Code reference paths must be repo-relative paths'),
97
- role: CodeReferenceRoleSchema,
98
- symbol: z.string().trim().min(1).max(200).optional(),
99
- description: z.string().trim().min(1).max(300).optional()
100
- })
101
-
102
- const ResourceEntryBaseSchema = z.object({
103
- /** Canonical resource id; runtime resourceId derives from this value. */
104
- id: ResourceIdSchema,
105
- /** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
106
- order: z.number().default(0),
107
- /** Required single System membership — value is a dot-separated system path (e.g. "sales.lead-gen"). */
162
+ .string()
163
+ .trim()
164
+ .min(1)
165
+ .max(500)
166
+ .regex(/^[A-Za-z0-9_./$@()[\] -]+$/, 'Code reference paths must be repo-relative paths'),
167
+ role: CodeReferenceRoleSchema,
168
+ symbol: z.string().trim().min(1).max(200).optional(),
169
+ description: z.string().trim().min(1).max(300).optional()
170
+ })
171
+
172
+ const ResourceEntryBaseSchema = z.object({
173
+ /** Canonical resource id; runtime resourceId derives from this value. */
174
+ id: ResourceIdSchema,
175
+ /** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
176
+ order: z.number().default(0),
177
+ /** Required single System membership — value is a dot-separated system path (e.g. "sales.lead-gen"). */
108
178
  systemPath: SystemPathSchema.meta({ ref: 'system' }),
109
179
  /** Executable display title owned by the OM Resource descriptor. */
110
180
  title: LabelSchema.optional(),
111
181
  /** Executable display description owned by the OM Resource descriptor. */
112
182
  description: DescriptionSchema.optional(),
113
- /** Optional role responsible for maintaining this resource. */
114
- ownerRoleId: ModelIdSchema.meta({ ref: 'role' }).optional(),
183
+ /** Optional role responsible for maintaining this resource. */
184
+ ownerRoleId: ModelIdSchema.meta({ ref: 'role' }).optional(),
115
185
  status: ResourceGovernanceStatusSchema,
116
186
  /**
117
187
  * Ontology contract bindings for the semantic work this resource performs.
@@ -122,68 +192,68 @@ const ResourceEntryBaseSchema = z.object({
122
192
  /** Repo-relative implementation breadcrumbs for agents and operators. */
123
193
  codeRefs: z.array(CodeReferenceSchema).default([])
124
194
  })
125
-
195
+
126
196
  export const WorkflowResourceEntrySchema = ResourceEntryBaseSchema.extend({
127
197
  kind: z.literal('workflow'),
128
198
  emits: z.array(EventEmissionDescriptorSchema).optional()
129
199
  })
130
-
131
- export const AgentResourceEntrySchema = ResourceEntryBaseSchema.extend({
132
- kind: z.literal('agent'),
133
- /** Mirrors code-side AgentConfig.kind. */
134
- agentKind: AgentKindSchema,
135
- /** Role this agent embodies, if any. */
136
- actsAsRoleId: ModelIdSchema.meta({ ref: 'role' }).optional(),
137
- /** Mirrors AgentConfig.sessionCapable. */
138
- sessionCapable: z.boolean(),
139
- /** Broad/composite callable entry points orchestrated by this agent. */
140
- invocations: z.array(ActionInvocationSchema).default([]),
141
- emits: z.array(EventEmissionDescriptorSchema).optional()
142
- })
143
-
144
- export const IntegrationResourceEntrySchema = ResourceEntryBaseSchema.extend({
145
- kind: z.literal('integration'),
146
- provider: z.string().trim().min(1).max(100)
147
- })
148
-
149
- export const ScriptResourceSourceSchema = z.union([
150
- z.string().trim().min(1).max(50_000),
151
- z.object({
152
- file: z.string().trim().min(1).max(500)
153
- })
154
- ])
155
-
156
- export const ScriptResourceEntrySchema = ResourceEntryBaseSchema.extend({
157
- kind: z.literal('script'),
158
- language: ScriptResourceLanguageSchema,
159
- source: ScriptResourceSourceSchema
160
- })
161
-
162
- export const ResourceEntrySchema = z.discriminatedUnion('kind', [
163
- WorkflowResourceEntrySchema,
164
- AgentResourceEntrySchema,
165
- IntegrationResourceEntrySchema,
166
- ScriptResourceEntrySchema
167
- ])
168
-
169
- export const ResourcesDomainSchema = z
170
- .record(z.string(), ResourceEntrySchema)
171
- .refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
172
- message: 'Each resource entry id must match its map key'
173
- })
174
- .default({})
175
-
176
- export const DEFAULT_ORGANIZATION_MODEL_RESOURCES: z.infer<typeof ResourcesDomainSchema> = {}
177
-
178
- export function defineResource<const TResource extends ResourceEntry>(resource: TResource): TResource {
179
- return ResourceEntrySchema.parse(resource) as TResource
180
- }
181
-
200
+
201
+ export const AgentResourceEntrySchema = ResourceEntryBaseSchema.extend({
202
+ kind: z.literal('agent'),
203
+ /** Mirrors code-side AgentConfig.kind. */
204
+ agentKind: AgentKindSchema,
205
+ /** Role this agent embodies, if any. */
206
+ actsAsRoleId: ModelIdSchema.meta({ ref: 'role' }).optional(),
207
+ /** Mirrors AgentConfig.sessionCapable. */
208
+ sessionCapable: z.boolean(),
209
+ /** Broad/composite callable entry points orchestrated by this agent. */
210
+ invocations: z.array(ActionInvocationSchema).default([]),
211
+ emits: z.array(EventEmissionDescriptorSchema).optional()
212
+ })
213
+
214
+ export const IntegrationResourceEntrySchema = ResourceEntryBaseSchema.extend({
215
+ kind: z.literal('integration'),
216
+ provider: z.string().trim().min(1).max(100)
217
+ })
218
+
219
+ export const ScriptResourceSourceSchema = z.union([
220
+ z.string().trim().min(1).max(50_000),
221
+ z.object({
222
+ file: z.string().trim().min(1).max(500)
223
+ })
224
+ ])
225
+
226
+ export const ScriptResourceEntrySchema = ResourceEntryBaseSchema.extend({
227
+ kind: z.literal('script'),
228
+ language: ScriptResourceLanguageSchema,
229
+ source: ScriptResourceSourceSchema
230
+ })
231
+
232
+ export const ResourceEntrySchema = z.discriminatedUnion('kind', [
233
+ WorkflowResourceEntrySchema,
234
+ AgentResourceEntrySchema,
235
+ IntegrationResourceEntrySchema,
236
+ ScriptResourceEntrySchema
237
+ ])
238
+
239
+ export const ResourcesDomainSchema = z
240
+ .record(z.string(), ResourceEntrySchema)
241
+ .refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
242
+ message: 'Each resource entry id must match its map key'
243
+ })
244
+ .default({})
245
+
246
+ export const DEFAULT_ORGANIZATION_MODEL_RESOURCES: z.infer<typeof ResourcesDomainSchema> = {}
247
+
248
+ export function defineResource<const TResource extends ResourceEntry>(resource: TResource): TResource {
249
+ return ResourceEntrySchema.parse(resource) as TResource
250
+ }
251
+
182
252
  export function defineResources<const TResources extends Record<string, ResourceEntry>>(
183
253
  resources: TResources
184
254
  ): TResources {
185
- return Object.fromEntries(
186
- Object.entries(resources).map(([key, resource]) => [key, ResourceEntrySchema.parse(resource)])
255
+ return Object.fromEntries(
256
+ Object.entries(resources).map(([key, resource]) => [key, ResourceEntrySchema.parse(resource)])
187
257
  ) as TResources
188
258
  }
189
259
 
@@ -205,19 +275,20 @@ export function defineResourceOntology(input: ResourceOntologyBindingInput): Res
205
275
  emits: ontologyIdArrayFrom(input.emits)
206
276
  })
207
277
  }
208
-
209
- export type ResourceId = z.infer<typeof ResourceIdSchema>
210
- export type ResourceKind = z.infer<typeof ResourceKindSchema>
211
- export type ResourceGovernanceStatus = z.infer<typeof ResourceGovernanceStatusSchema>
212
- export type ResourceAgentKind = z.infer<typeof AgentKindSchema>
278
+
279
+ export type ResourceId = z.infer<typeof ResourceIdSchema>
280
+ export type ResourceKind = z.infer<typeof ResourceKindSchema>
281
+ export type ResourceGovernanceStatus = z.infer<typeof ResourceGovernanceStatusSchema>
282
+ export type ResourceAgentKind = z.infer<typeof AgentKindSchema>
213
283
  export type CodeReferenceRole = z.infer<typeof CodeReferenceRoleSchema>
214
284
  export type ResourceOntologyBinding = z.infer<typeof ResourceOntologyBindingSchema>
285
+ export type ResourceOntologyBindingContract = NonNullable<ResourceOntologyBinding['contract']>
215
286
  export type CodeReference = z.infer<typeof CodeReferenceSchema>
216
- export type ScriptResourceLanguage = z.infer<typeof ScriptResourceLanguageSchema>
217
- export type ScriptResourceSource = z.infer<typeof ScriptResourceSourceSchema>
218
- export type WorkflowResourceEntry = z.infer<typeof WorkflowResourceEntrySchema>
219
- export type AgentResourceEntry = z.infer<typeof AgentResourceEntrySchema>
220
- export type IntegrationResourceEntry = z.infer<typeof IntegrationResourceEntrySchema>
221
- export type ScriptResourceEntry = z.infer<typeof ScriptResourceEntrySchema>
222
- export type ResourceEntry = z.infer<typeof ResourceEntrySchema>
223
- export type ResourcesDomain = z.infer<typeof ResourcesDomainSchema>
287
+ export type ScriptResourceLanguage = z.infer<typeof ScriptResourceLanguageSchema>
288
+ export type ScriptResourceSource = z.infer<typeof ScriptResourceSourceSchema>
289
+ export type WorkflowResourceEntry = z.infer<typeof WorkflowResourceEntrySchema>
290
+ export type AgentResourceEntry = z.infer<typeof AgentResourceEntrySchema>
291
+ export type IntegrationResourceEntry = z.infer<typeof IntegrationResourceEntrySchema>
292
+ export type ScriptResourceEntry = z.infer<typeof ScriptResourceEntrySchema>
293
+ export type ResourceEntry = z.infer<typeof ResourceEntrySchema>
294
+ export type ResourcesDomain = z.infer<typeof ResourcesDomainSchema>
@@ -1,12 +1,12 @@
1
1
  import { z } from 'zod'
2
2
  import { DescriptionSchema, DisplayMetadataSchema, ModelIdSchema, ReferenceIdsSchema } from './shared'
3
3
 
4
- export { LEAD_GEN_STAGE_CATALOG, type LeadGenStageCatalogEntry } from '../catalogs/lead-gen'
4
+ export type { LeadGenStageCatalogEntry } from '../catalogs/lead-gen'
5
5
 
6
- // Phase 4 cut: OrganizationModelSalesSchema and DEFAULT_ORGANIZATION_MODEL_SALES removed.
7
- // Pipeline/stage data moved into system.content as (schema:pipeline) and (schema:stage)
8
- // content nodes on the owning system (e.g. sales.crm). Use getAllPipelines() /
9
- // getStagesInPipeline() from migration-helpers to read pipeline data portably.
6
+ // OrganizationModelSalesSchema and DEFAULT_ORGANIZATION_MODEL_SALES are retired.
7
+ // Pipeline/stage data lives in System.ontology.catalogTypes on the owning system
8
+ // (e.g. sales.crm). Use getAllPipelines() / getStagesInPipeline() from
9
+ // migration-helpers to read pipeline data portably.
10
10
  //
11
11
  // SalesStageSemanticClassSchema, SalesStageSchema, SalesPipelineSchema are retained
12
12
  // below as TypeScript types used by CRM business logic and the Stateful pipeline definitions.
@@ -9,7 +9,6 @@ import {
9
9
  PathSchema,
10
10
  ReferenceIdsSchema
11
11
  } from './shared'
12
- import { ContentNodeSchema } from '../content-kinds/types'
13
12
  import { OntologyScopeSchema, type OntologyScope } from '../ontology'
14
13
 
15
14
  // ---------------------------------------------------------------------------
@@ -48,12 +47,11 @@ export const NodeIdStringSchema = z
48
47
  .trim()
49
48
  .min(1)
50
49
  .max(200)
51
- // D4: kind prefix allows hyphens (e.g. 'content-node'); id allows colons for
52
- // qualified content-node references ('content-node:sales.crm:default-pipeline').
50
+ // Kind prefix allows hyphens; id allows scoped references such as ontology targets.
53
51
  .regex(
54
52
  /^[a-z][a-z-]*:([a-z0-9-]+)(\.[a-z0-9-]+)*(:[a-z0-9.-]+)*$/,
55
- 'Node references must use kind:dotted-path (e.g. system:sales.crm or content-node:sales.crm:pipeline-id)'
56
- )
53
+ 'Node references must use kind:dotted-path (e.g. system:sales.crm or resource:lead-gen.company.qualify)'
54
+ )
57
55
 
58
56
  export const SystemUiSchema = z.object({
59
57
  path: PathSchema,
@@ -72,8 +70,6 @@ export const SystemUiSchema = z.object({
72
70
  // the declared interface instead of trying to infer through the cycle.
73
71
  // ---------------------------------------------------------------------------
74
72
 
75
- import type { ContentNode } from '../content-kinds/types'
76
-
77
73
  export type JsonPrimitive = string | number | boolean | null
78
74
  export type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue }
79
75
 
@@ -121,16 +117,11 @@ export interface SystemEntry {
121
117
  config?: Record<string, JsonValue>
122
118
  ontology?: OntologyScope
123
119
  systems?: Record<string, SystemEntry>
124
- /**
125
- * @deprecated Compatibility-only bridge for old tenant data and migration readers.
126
- * Author new semantic catalogs in `ontology` and local settings in `config`.
127
- */
128
- content?: Record<string, ContentNode>
129
120
  subsystems?: Record<string, SystemEntry>
130
121
  }
131
122
 
132
- export const SystemEntrySchema: ZodType<SystemEntry> = z
133
- .object({
123
+ export const SystemEntrySchema: ZodType<SystemEntry> = z
124
+ .object({
134
125
  /** Stable tenant-defined system id (e.g. "sys.lead-gen" or "sales.crm"). */
135
126
  id: SystemIdSchema,
136
127
  /** Human-readable system label shown in UI, governance, and operations surfaces. */
@@ -195,14 +186,7 @@ export const SystemEntrySchema: ZodType<SystemEntry> = z
195
186
  */
196
187
  ontology: OntologyScopeSchema.optional(),
197
188
  /**
198
- * @deprecated Compatibility-only bridge for old tenant content nodes and
199
- * migration readers. New schema/catalog authoring belongs in ontology;
200
- * new system-local settings belong in config. Bridge nodes are keyed by
201
- * local NodeId and may still project to content-node:* graph IDs.
202
- */
203
- content: z.record(z.string().trim().min(1).max(200), ContentNodeSchema).optional(),
204
- /**
205
- * Recursive child systems, authored via nesting (per L11).
189
+ * Recursive child systems, authored via nesting (per L11).
206
190
  * The key is the local system id; the full path is computed by joining
207
191
  * ancestor keys with `.` (e.g. parent key `'sales'` + child key `'crm'` → `'sales.crm'`).
208
192
  * Per Phase 4: `id` and `parentSystemId` fields will be removed in favour of
@@ -212,7 +196,8 @@ export const SystemEntrySchema: ZodType<SystemEntry> = z
212
196
  /** @deprecated Use systems. Accepted as a compatibility alias during the ontology bridge. */
213
197
  subsystems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional()
214
198
  })
215
- .refine((system: SystemEntry) => system.label !== undefined || system.title !== undefined, {
199
+ .strict()
200
+ .refine((system: SystemEntry) => system.label !== undefined || system.title !== undefined, {
216
201
  path: ['label'],
217
202
  message: 'System must provide label or title'
218
203
  })