@elevasis/core 0.24.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/index.d.ts +3192 -2313
  2. package/dist/index.js +243 -13
  3. package/dist/knowledge/index.d.ts +92 -6
  4. package/dist/organization-model/index.d.ts +3192 -2313
  5. package/dist/organization-model/index.js +243 -13
  6. package/dist/test-utils/index.d.ts +134 -45
  7. package/dist/test-utils/index.js +118 -11
  8. package/package.json +3 -3
  9. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +45 -7
  10. package/src/execution/engine/workflow/types.ts +5 -7
  11. package/src/organization-model/__tests__/domains/resources.test.ts +19 -8
  12. package/src/organization-model/__tests__/domains/topology.test.ts +188 -0
  13. package/src/organization-model/__tests__/graph.test.ts +98 -7
  14. package/src/organization-model/__tests__/schema.test.ts +14 -4
  15. package/src/organization-model/defaults.ts +2 -0
  16. package/src/organization-model/domains/resources.ts +63 -20
  17. package/src/organization-model/domains/topology.ts +261 -0
  18. package/src/organization-model/graph/build.ts +63 -15
  19. package/src/organization-model/graph/schema.ts +4 -3
  20. package/src/organization-model/graph/types.ts +5 -4
  21. package/src/organization-model/index.ts +4 -3
  22. package/src/organization-model/ontology.ts +2 -5
  23. package/src/organization-model/organization-model.mdx +16 -11
  24. package/src/organization-model/published.ts +36 -13
  25. package/src/organization-model/schema.ts +51 -11
  26. package/src/organization-model/types.ts +25 -11
  27. package/src/platform/registry/__tests__/validation.test.ts +199 -14
  28. package/src/platform/registry/resource-registry.ts +11 -11
  29. package/src/platform/registry/validation.ts +226 -34
  30. package/src/reference/_generated/contracts.md +45 -7
  31. package/src/reference/glossary.md +3 -3
  32. package/src/supabase/database.types.ts +3156 -3153
@@ -1601,6 +1601,7 @@ type Database = {
1601
1601
  origin_execution_id: string | null;
1602
1602
  output: Json | null;
1603
1603
  resource_id: string;
1604
+ resource_snapshot: Json | null;
1604
1605
  resource_status: string;
1605
1606
  resource_type: string;
1606
1607
  resource_version: string | null;
@@ -1626,6 +1627,7 @@ type Database = {
1626
1627
  origin_execution_id?: string | null;
1627
1628
  output?: Json | null;
1628
1629
  resource_id: string;
1630
+ resource_snapshot?: Json | null;
1629
1631
  resource_status?: string;
1630
1632
  resource_type?: string;
1631
1633
  resource_version?: string | null;
@@ -1651,6 +1653,7 @@ type Database = {
1651
1653
  origin_execution_id?: string | null;
1652
1654
  output?: Json | null;
1653
1655
  resource_id?: string;
1656
+ resource_snapshot?: Json | null;
1654
1657
  resource_status?: string;
1655
1658
  resource_type?: string;
1656
1659
  resource_version?: string | null;
@@ -3668,41 +3671,6 @@ declare const OntologyScopeSchema: z.ZodDefault<z.ZodObject<{
3668
3671
  }, z.core.$strip>>;
3669
3672
  type OntologyScope = z.infer<typeof OntologyScopeSchema>;
3670
3673
 
3671
- declare const SurfaceTypeSchema: z.ZodEnum<{
3672
- dashboard: "dashboard";
3673
- settings: "settings";
3674
- graph: "graph";
3675
- list: "list";
3676
- page: "page";
3677
- detail: "detail";
3678
- }>;
3679
- interface SidebarSurfaceNode {
3680
- type: 'surface';
3681
- label: string;
3682
- path: string;
3683
- surfaceType: z.infer<typeof SurfaceTypeSchema>;
3684
- description?: string;
3685
- icon?: string;
3686
- order?: number;
3687
- targets?: {
3688
- systems?: string[];
3689
- entities?: string[];
3690
- resources?: string[];
3691
- actions?: string[];
3692
- };
3693
- devOnly?: boolean;
3694
- requiresAdmin?: boolean;
3695
- }
3696
- interface SidebarGroupNode {
3697
- type: 'group';
3698
- label: string;
3699
- description?: string;
3700
- icon?: string;
3701
- order?: number;
3702
- children: Record<string, SidebarNode>;
3703
- }
3704
- type SidebarNode = SidebarSurfaceNode | SidebarGroupNode;
3705
-
3706
3674
  /**
3707
3675
  * Placeholder discriminated union for ContentNode (Wave 1A).
3708
3676
  * Wave 2A wires concrete (kind, type) pairs via the registry.
@@ -3770,6 +3738,46 @@ interface SystemEntry {
3770
3738
  subsystems?: Record<string, SystemEntry>;
3771
3739
  }
3772
3740
 
3741
+ declare const SurfaceTypeSchema: z.ZodEnum<{
3742
+ dashboard: "dashboard";
3743
+ settings: "settings";
3744
+ graph: "graph";
3745
+ list: "list";
3746
+ page: "page";
3747
+ detail: "detail";
3748
+ }>;
3749
+ interface SidebarSurfaceNode {
3750
+ type: 'surface';
3751
+ label: string;
3752
+ path: string;
3753
+ surfaceType: z.infer<typeof SurfaceTypeSchema>;
3754
+ description?: string;
3755
+ icon?: string;
3756
+ order?: number;
3757
+ targets?: {
3758
+ systems?: string[];
3759
+ entities?: string[];
3760
+ resources?: string[];
3761
+ actions?: string[];
3762
+ };
3763
+ devOnly?: boolean;
3764
+ requiresAdmin?: boolean;
3765
+ }
3766
+ interface SidebarGroupNode {
3767
+ type: 'group';
3768
+ label: string;
3769
+ description?: string;
3770
+ icon?: string;
3771
+ order?: number;
3772
+ children: Record<string, SidebarNode>;
3773
+ }
3774
+ type SidebarNode = SidebarSurfaceNode | SidebarGroupNode;
3775
+
3776
+ type OrganizationModel = z.infer<typeof OrganizationModelSchema>;
3777
+ type DeepPartial<T> = T extends Array<infer U> ? Array<DeepPartial<U>> : T extends object ? {
3778
+ [K in keyof T]?: DeepPartial<T[K]>;
3779
+ } : T;
3780
+
3773
3781
  declare const OrganizationModelSchema: z.ZodObject<{
3774
3782
  version: z.ZodDefault<z.ZodLiteral<1>>;
3775
3783
  domainMetadata: z.ZodPipe<z.ZodDefault<z.ZodObject<{
@@ -3809,6 +3817,10 @@ declare const OrganizationModelSchema: z.ZodObject<{
3809
3817
  version: z.ZodDefault<z.ZodLiteral<1>>;
3810
3818
  lastModified: z.ZodString;
3811
3819
  }, z.core.$strip>>;
3820
+ topology: z.ZodOptional<z.ZodObject<{
3821
+ version: z.ZodDefault<z.ZodLiteral<1>>;
3822
+ lastModified: z.ZodString;
3823
+ }, z.core.$strip>>;
3812
3824
  actions: z.ZodOptional<z.ZodObject<{
3813
3825
  version: z.ZodDefault<z.ZodLiteral<1>>;
3814
3826
  lastModified: z.ZodString;
@@ -3862,6 +3874,10 @@ declare const OrganizationModelSchema: z.ZodObject<{
3862
3874
  version: 1;
3863
3875
  lastModified: string;
3864
3876
  };
3877
+ topology: {
3878
+ version: 1;
3879
+ lastModified: string;
3880
+ };
3865
3881
  actions: {
3866
3882
  version: 1;
3867
3883
  lastModified: string;
@@ -3915,6 +3931,10 @@ declare const OrganizationModelSchema: z.ZodObject<{
3915
3931
  version: 1;
3916
3932
  lastModified: string;
3917
3933
  } | undefined;
3934
+ topology?: {
3935
+ version: 1;
3936
+ lastModified: string;
3937
+ } | undefined;
3918
3938
  actions?: {
3919
3939
  version: 1;
3920
3940
  lastModified: string;
@@ -4158,6 +4178,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4158
4178
  id: z.ZodString;
4159
4179
  order: z.ZodDefault<z.ZodNumber>;
4160
4180
  systemPath: z.ZodString;
4181
+ title: z.ZodOptional<z.ZodString>;
4182
+ description: z.ZodOptional<z.ZodString>;
4161
4183
  ownerRoleId: z.ZodOptional<z.ZodString>;
4162
4184
  status: z.ZodEnum<{
4163
4185
  deprecated: "deprecated";
@@ -4165,7 +4187,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4165
4187
  archived: "archived";
4166
4188
  }>;
4167
4189
  ontology: z.ZodOptional<z.ZodObject<{
4168
- implements: z.ZodOptional<z.ZodArray<z.ZodString>>;
4190
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
4191
+ primaryAction: z.ZodOptional<z.ZodString>;
4169
4192
  reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
4170
4193
  writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
4171
4194
  usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -4185,7 +4208,6 @@ declare const OrganizationModelSchema: z.ZodObject<{
4185
4208
  description: z.ZodOptional<z.ZodString>;
4186
4209
  }, z.core.$strip>>>;
4187
4210
  kind: z.ZodLiteral<"workflow">;
4188
- actionKey: z.ZodOptional<z.ZodString>;
4189
4211
  emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
4190
4212
  eventKey: z.ZodString;
4191
4213
  label: z.ZodString;
@@ -4202,6 +4224,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4202
4224
  id: z.ZodString;
4203
4225
  order: z.ZodDefault<z.ZodNumber>;
4204
4226
  systemPath: z.ZodString;
4227
+ title: z.ZodOptional<z.ZodString>;
4228
+ description: z.ZodOptional<z.ZodString>;
4205
4229
  ownerRoleId: z.ZodOptional<z.ZodString>;
4206
4230
  status: z.ZodEnum<{
4207
4231
  deprecated: "deprecated";
@@ -4209,7 +4233,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4209
4233
  archived: "archived";
4210
4234
  }>;
4211
4235
  ontology: z.ZodOptional<z.ZodObject<{
4212
- implements: z.ZodOptional<z.ZodArray<z.ZodString>>;
4236
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
4237
+ primaryAction: z.ZodOptional<z.ZodString>;
4213
4238
  reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
4214
4239
  writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
4215
4240
  usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -4276,6 +4301,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4276
4301
  id: z.ZodString;
4277
4302
  order: z.ZodDefault<z.ZodNumber>;
4278
4303
  systemPath: z.ZodString;
4304
+ title: z.ZodOptional<z.ZodString>;
4305
+ description: z.ZodOptional<z.ZodString>;
4279
4306
  ownerRoleId: z.ZodOptional<z.ZodString>;
4280
4307
  status: z.ZodEnum<{
4281
4308
  deprecated: "deprecated";
@@ -4283,7 +4310,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4283
4310
  archived: "archived";
4284
4311
  }>;
4285
4312
  ontology: z.ZodOptional<z.ZodObject<{
4286
- implements: z.ZodOptional<z.ZodArray<z.ZodString>>;
4313
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
4314
+ primaryAction: z.ZodOptional<z.ZodString>;
4287
4315
  reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
4288
4316
  writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
4289
4317
  usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -4308,6 +4336,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4308
4336
  id: z.ZodString;
4309
4337
  order: z.ZodDefault<z.ZodNumber>;
4310
4338
  systemPath: z.ZodString;
4339
+ title: z.ZodOptional<z.ZodString>;
4340
+ description: z.ZodOptional<z.ZodString>;
4311
4341
  ownerRoleId: z.ZodOptional<z.ZodString>;
4312
4342
  status: z.ZodEnum<{
4313
4343
  deprecated: "deprecated";
@@ -4315,7 +4345,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4315
4345
  archived: "archived";
4316
4346
  }>;
4317
4347
  ontology: z.ZodOptional<z.ZodObject<{
4318
- implements: z.ZodOptional<z.ZodArray<z.ZodString>>;
4348
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
4349
+ primaryAction: z.ZodOptional<z.ZodString>;
4319
4350
  reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
4320
4351
  writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
4321
4352
  usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -4345,6 +4376,69 @@ declare const OrganizationModelSchema: z.ZodObject<{
4345
4376
  file: z.ZodString;
4346
4377
  }, z.core.$strip>]>;
4347
4378
  }, z.core.$strip>], "kind">>>>;
4379
+ topology: z.ZodDefault<z.ZodDefault<z.ZodObject<{
4380
+ version: z.ZodDefault<z.ZodLiteral<1>>;
4381
+ relationships: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4382
+ from: z.ZodDiscriminatedUnion<[z.ZodObject<{
4383
+ kind: z.ZodLiteral<"system">;
4384
+ id: z.ZodString;
4385
+ }, z.core.$strip>, z.ZodObject<{
4386
+ kind: z.ZodLiteral<"resource">;
4387
+ id: z.ZodString;
4388
+ }, z.core.$strip>, z.ZodObject<{
4389
+ kind: z.ZodLiteral<"ontology">;
4390
+ id: z.ZodString;
4391
+ }, z.core.$strip>, z.ZodObject<{
4392
+ kind: z.ZodLiteral<"policy">;
4393
+ id: z.ZodString;
4394
+ }, z.core.$strip>, z.ZodObject<{
4395
+ kind: z.ZodLiteral<"role">;
4396
+ id: z.ZodString;
4397
+ }, z.core.$strip>, z.ZodObject<{
4398
+ kind: z.ZodLiteral<"trigger">;
4399
+ id: z.ZodString;
4400
+ }, z.core.$strip>, z.ZodObject<{
4401
+ kind: z.ZodLiteral<"humanCheckpoint">;
4402
+ id: z.ZodString;
4403
+ }, z.core.$strip>, z.ZodObject<{
4404
+ kind: z.ZodLiteral<"externalResource">;
4405
+ id: z.ZodString;
4406
+ }, z.core.$strip>], "kind">;
4407
+ kind: z.ZodEnum<{
4408
+ triggers: "triggers";
4409
+ uses: "uses";
4410
+ approval: "approval";
4411
+ }>;
4412
+ to: z.ZodDiscriminatedUnion<[z.ZodObject<{
4413
+ kind: z.ZodLiteral<"system">;
4414
+ id: z.ZodString;
4415
+ }, z.core.$strip>, z.ZodObject<{
4416
+ kind: z.ZodLiteral<"resource">;
4417
+ id: z.ZodString;
4418
+ }, z.core.$strip>, z.ZodObject<{
4419
+ kind: z.ZodLiteral<"ontology">;
4420
+ id: z.ZodString;
4421
+ }, z.core.$strip>, z.ZodObject<{
4422
+ kind: z.ZodLiteral<"policy">;
4423
+ id: z.ZodString;
4424
+ }, z.core.$strip>, z.ZodObject<{
4425
+ kind: z.ZodLiteral<"role">;
4426
+ id: z.ZodString;
4427
+ }, z.core.$strip>, z.ZodObject<{
4428
+ kind: z.ZodLiteral<"trigger">;
4429
+ id: z.ZodString;
4430
+ }, z.core.$strip>, z.ZodObject<{
4431
+ kind: z.ZodLiteral<"humanCheckpoint">;
4432
+ id: z.ZodString;
4433
+ }, z.core.$strip>, z.ZodObject<{
4434
+ kind: z.ZodLiteral<"externalResource">;
4435
+ id: z.ZodString;
4436
+ }, z.core.$strip>], "kind">;
4437
+ systemPath: z.ZodOptional<z.ZodString>;
4438
+ required: z.ZodOptional<z.ZodBoolean>;
4439
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
4440
+ }, z.core.$strip>>>;
4441
+ }, z.core.$strip>>>;
4348
4442
  actions: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4349
4443
  id: z.ZodString;
4350
4444
  order: z.ZodNumber;
@@ -4579,11 +4673,6 @@ declare const OrganizationModelSchema: z.ZodObject<{
4579
4673
  }, z.core.$strip>>>>;
4580
4674
  }, z.core.$strip>;
4581
4675
 
4582
- type OrganizationModel = z.infer<typeof OrganizationModelSchema>;
4583
- type DeepPartial<T> = T extends Array<infer U> ? Array<DeepPartial<U>> : T extends object ? {
4584
- [K in keyof T]?: DeepPartial<T[K]>;
4585
- } : T;
4586
-
4587
4676
  interface TestInitializationError {
4588
4677
  layer: 'auth' | 'profile' | 'organization';
4589
4678
  message: string;
@@ -19685,7 +19685,6 @@ function addLegacyEntityProjections(index2, diagnostics, sourcesById, entities)
19685
19685
  table: entity.table
19686
19686
  }
19687
19687
  } : {},
19688
- legacyEntityId: entity.id,
19689
19688
  ...entity.rowSchema !== void 0 ? { rowSchema: entity.rowSchema } : {},
19690
19689
  ...entity.stateCatalogId !== void 0 ? { stateCatalogId: entity.stateCatalogId } : {}
19691
19690
  };
@@ -19710,8 +19709,7 @@ function addLegacyEntityProjections(index2, diagnostics, sourcesById, entities)
19710
19709
  from: legacyObjectId(entity),
19711
19710
  to: legacyObjectId(targetEntity),
19712
19711
  cardinality: link.kind,
19713
- ...link.via !== void 0 ? { via: link.via } : {},
19714
- legacyEntityId: entity.id
19712
+ ...link.via !== void 0 ? { via: link.via } : {}
19715
19713
  };
19716
19714
  addRecord(index2, diagnostics, sourcesById, "linkTypes", linkType, {
19717
19715
  source: "legacy.entities.links",
@@ -19769,8 +19767,7 @@ function addSystemContentProjections(index2, diagnostics, sourcesById, systemPat
19769
19767
  kind: node.type,
19770
19768
  ...typeof node.data?.["entityId"] === "string" ? { appliesTo: formatOntologyId({ scope: systemPath, kind: "object", localId: node.data["entityId"] }) } : {},
19771
19769
  ...Object.keys(entries).length > 0 ? { entries } : {},
19772
- ...node.data !== void 0 ? { data: node.data } : {},
19773
- legacyContentId: `${systemPath}:${localId}`
19770
+ ...node.data !== void 0 ? { data: node.data } : {}
19774
19771
  };
19775
19772
  addRecord(index2, diagnostics, sourcesById, "catalogTypes", catalogType, {
19776
19773
  source: "legacy.system.content",
@@ -20893,11 +20890,20 @@ EventEmissionDescriptorSchema.extend({
20893
20890
  ownerKind: z.enum(["resource", "entity"]).meta({ label: "Owner kind" })
20894
20891
  });
20895
20892
  var ResourceOntologyBindingSchema = z.object({
20896
- implements: z.array(OntologyIdSchema).optional(),
20893
+ actions: z.array(OntologyIdSchema).optional(),
20894
+ primaryAction: OntologyIdSchema.optional(),
20897
20895
  reads: z.array(OntologyIdSchema).optional(),
20898
20896
  writes: z.array(OntologyIdSchema).optional(),
20899
20897
  usesCatalogs: z.array(OntologyIdSchema).optional(),
20900
20898
  emits: z.array(OntologyIdSchema).optional()
20899
+ }).superRefine((binding, ctx) => {
20900
+ if (binding.primaryAction === void 0) return;
20901
+ if (binding.actions?.includes(binding.primaryAction)) return;
20902
+ ctx.addIssue({
20903
+ code: z.ZodIssueCode.custom,
20904
+ path: ["primaryAction"],
20905
+ message: "Resource ontology primaryAction must be included in actions"
20906
+ });
20901
20907
  });
20902
20908
  var CodeReferenceSchema = z.object({
20903
20909
  path: z.string().trim().min(1).max(500).regex(/^[A-Za-z0-9_./$@()[\] -]+$/, "Code reference paths must be repo-relative paths"),
@@ -20912,6 +20918,10 @@ var ResourceEntryBaseSchema = z.object({
20912
20918
  order: z.number().default(0),
20913
20919
  /** Required single System membership — value is a dot-separated system path (e.g. "sales.lead-gen"). */
20914
20920
  systemPath: SystemPathSchema.meta({ ref: "system" }),
20921
+ /** Executable display title owned by the OM Resource descriptor. */
20922
+ title: LabelSchema.optional(),
20923
+ /** Executable display description owned by the OM Resource descriptor. */
20924
+ description: DescriptionSchema.optional(),
20915
20925
  /** Optional role responsible for maintaining this resource. */
20916
20926
  ownerRoleId: ModelIdSchema.meta({ ref: "role" }).optional(),
20917
20927
  status: ResourceGovernanceStatusSchema,
@@ -20926,8 +20936,6 @@ var ResourceEntryBaseSchema = z.object({
20926
20936
  });
20927
20937
  var WorkflowResourceEntrySchema = ResourceEntryBaseSchema.extend({
20928
20938
  kind: z.literal("workflow"),
20929
- /** Mirrors WorkflowConfig.actionKey when the runtime workflow has one. */
20930
- actionKey: z.string().trim().min(1).max(255).optional(),
20931
20939
  emits: z.array(EventEmissionDescriptorSchema).optional()
20932
20940
  });
20933
20941
  var AgentResourceEntrySchema = ResourceEntryBaseSchema.extend({
@@ -21147,6 +21155,73 @@ var OrgKnowledgeNodeSchema = z.object({
21147
21155
  updatedAt: z.string().trim().min(1).max(50)
21148
21156
  });
21149
21157
  var KnowledgeDomainSchema = z.record(ModelIdSchema, OrgKnowledgeNodeSchema).default({});
21158
+ var SecretLikeMetadataKeySchema = /(?:secret|password|passwd|token|api[-_]?key|credential|private[-_]?key)/i;
21159
+ var SecretLikeMetadataValueSchema = /(?:sk-[A-Za-z0-9_-]{12,}|pk_live_[A-Za-z0-9_-]{12,}|eyJ[A-Za-z0-9_-]{20,}|-----BEGIN (?:RSA |OPENSSH |EC )?PRIVATE KEY-----)/;
21160
+ z.enum([
21161
+ "system",
21162
+ "resource",
21163
+ "ontology",
21164
+ "policy",
21165
+ "role",
21166
+ "trigger",
21167
+ "humanCheckpoint",
21168
+ "externalResource"
21169
+ ]);
21170
+ var OmTopologyRelationshipKindSchema = z.enum(["triggers", "uses", "approval"]);
21171
+ var OmTopologyNodeRefSchema = z.discriminatedUnion("kind", [
21172
+ z.object({ kind: z.literal("system"), id: ModelIdSchema }),
21173
+ z.object({ kind: z.literal("resource"), id: ResourceIdSchema }),
21174
+ z.object({ kind: z.literal("ontology"), id: OntologyIdSchema }),
21175
+ z.object({ kind: z.literal("policy"), id: ModelIdSchema }),
21176
+ z.object({ kind: z.literal("role"), id: ModelIdSchema }),
21177
+ z.object({ kind: z.literal("trigger"), id: ResourceIdSchema }),
21178
+ z.object({ kind: z.literal("humanCheckpoint"), id: ResourceIdSchema }),
21179
+ z.object({ kind: z.literal("externalResource"), id: ResourceIdSchema })
21180
+ ]);
21181
+ var OmTopologyMetadataSchema = z.record(z.string().trim().min(1).max(120), JsonValueSchema).superRefine((metadata, ctx) => {
21182
+ function visit(value, path) {
21183
+ if (typeof value === "string" && SecretLikeMetadataValueSchema.test(value)) {
21184
+ ctx.addIssue({
21185
+ code: z.ZodIssueCode.custom,
21186
+ path,
21187
+ message: "Topology metadata must not contain secret-like values"
21188
+ });
21189
+ return;
21190
+ }
21191
+ if (Array.isArray(value)) {
21192
+ value.forEach((entry, index2) => visit(entry, [...path, index2]));
21193
+ return;
21194
+ }
21195
+ if (typeof value !== "object" || value === null) return;
21196
+ Object.entries(value).forEach(([key, entry]) => {
21197
+ if (SecretLikeMetadataKeySchema.test(key)) {
21198
+ ctx.addIssue({
21199
+ code: z.ZodIssueCode.custom,
21200
+ path: [...path, key],
21201
+ message: `Topology metadata key "${key}" looks secret-like`
21202
+ });
21203
+ }
21204
+ visit(entry, [...path, key]);
21205
+ });
21206
+ }
21207
+ visit(metadata, []);
21208
+ });
21209
+ var OmTopologyRelationshipSchema = z.object({
21210
+ from: OmTopologyNodeRefSchema,
21211
+ kind: OmTopologyRelationshipKindSchema,
21212
+ to: OmTopologyNodeRefSchema,
21213
+ systemPath: SystemPathSchema.optional(),
21214
+ required: z.boolean().optional(),
21215
+ metadata: OmTopologyMetadataSchema.optional()
21216
+ });
21217
+ var OmTopologyDomainSchema = z.object({
21218
+ version: z.literal(1).default(1),
21219
+ relationships: z.record(z.string().trim().min(1).max(255), OmTopologyRelationshipSchema).default({})
21220
+ }).default({ version: 1, relationships: {} });
21221
+ var DEFAULT_ORGANIZATION_MODEL_TOPOLOGY = {
21222
+ version: 1,
21223
+ relationships: {}
21224
+ };
21150
21225
  var PolicyIdSchema = ModelIdSchema;
21151
21226
  var PolicyApplicabilitySchema = z.object({
21152
21227
  systemIds: z.array(ModelIdSchema.meta({ ref: "system" })).default([]),
@@ -21236,6 +21311,7 @@ z.enum([
21236
21311
  "systems",
21237
21312
  "ontology",
21238
21313
  "resources",
21314
+ "topology",
21239
21315
  "actions",
21240
21316
  "entities",
21241
21317
  "policies",
@@ -21255,6 +21331,7 @@ var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
21255
21331
  systems: { version: 1, lastModified: "2026-05-10" },
21256
21332
  ontology: { version: 1, lastModified: "2026-05-14" },
21257
21333
  resources: { version: 1, lastModified: "2026-05-10" },
21334
+ topology: { version: 1, lastModified: "2026-05-14" },
21258
21335
  actions: { version: 1, lastModified: "2026-05-10" },
21259
21336
  entities: { version: 1, lastModified: "2026-05-10" },
21260
21337
  policies: { version: 1, lastModified: "2026-05-10" },
@@ -21270,6 +21347,7 @@ var OrganizationModelDomainMetadataByDomainSchema = z.object({
21270
21347
  systems: OrganizationModelDomainMetadataSchema,
21271
21348
  ontology: OrganizationModelDomainMetadataSchema,
21272
21349
  resources: OrganizationModelDomainMetadataSchema,
21350
+ topology: OrganizationModelDomainMetadataSchema,
21273
21351
  actions: OrganizationModelDomainMetadataSchema,
21274
21352
  entities: OrganizationModelDomainMetadataSchema,
21275
21353
  policies: OrganizationModelDomainMetadataSchema,
@@ -21288,6 +21366,7 @@ var OrganizationModelSchemaBase = z.object({
21288
21366
  systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
21289
21367
  ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
21290
21368
  resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
21369
+ topology: OmTopologyDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_TOPOLOGY),
21291
21370
  actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
21292
21371
  entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
21293
21372
  policies: PoliciesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_POLICIES),
@@ -21630,6 +21709,25 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
21630
21709
  surface: ontologyCompilation.ontology.surfaces
21631
21710
  };
21632
21711
  const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index2) => Object.keys(index2)));
21712
+ function topologyTargetExists(ref) {
21713
+ if (ref.kind === "system") return systemsById.has(ref.id);
21714
+ if (ref.kind === "resource") return resourcesById.has(ref.id);
21715
+ if (ref.kind === "ontology") return ontologyIds.has(ref.id);
21716
+ if (ref.kind === "policy") return policiesById.has(ref.id);
21717
+ if (ref.kind === "role") return rolesById.has(ref.id);
21718
+ return true;
21719
+ }
21720
+ Object.entries(model.topology.relationships).forEach(([relationshipId, relationship]) => {
21721
+ ["from", "to"].forEach((side) => {
21722
+ const ref = relationship[side];
21723
+ if (topologyTargetExists(ref)) return;
21724
+ addIssue(
21725
+ ctx,
21726
+ ["topology", "relationships", relationshipId, side],
21727
+ `Topology relationship "${relationshipId}" ${side} references unknown ${ref.kind} "${ref.id}"`
21728
+ );
21729
+ });
21730
+ });
21633
21731
  const ontologyReferenceKeyKinds = {
21634
21732
  valueType: "value-type",
21635
21733
  catalogType: "catalog",
@@ -21768,11 +21866,18 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
21768
21866
  }
21769
21867
  });
21770
21868
  function validateResourceOntologyBinding(resourceId, bindingKey, expectedKind, ids) {
21771
- ids?.forEach((ontologyId, ontologyIndex) => {
21869
+ const ontologyIds2 = ids === void 0 ? [] : Array.isArray(ids) ? ids : [ids];
21870
+ ontologyIds2.forEach((ontologyId, ontologyIndex) => {
21772
21871
  if (ontologyIndexByKind[expectedKind][ontologyId] === void 0) {
21773
21872
  addIssue(
21774
21873
  ctx,
21775
- ["resources", resourceId, "ontology", bindingKey, ontologyIndex],
21874
+ [
21875
+ "resources",
21876
+ resourceId,
21877
+ "ontology",
21878
+ bindingKey,
21879
+ ...Array.isArray(ids) ? [ontologyIndex] : []
21880
+ ],
21776
21881
  `Resource "${resourceId}" ontology binding "${bindingKey}" references unknown ${expectedKind} ontology ID "${ontologyId}"`
21777
21882
  );
21778
21883
  }
@@ -21781,7 +21886,8 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
21781
21886
  Object.values(model.resources).forEach((resource) => {
21782
21887
  const binding = resource.ontology;
21783
21888
  if (binding === void 0) return;
21784
- validateResourceOntologyBinding(resource.id, "implements", "action", binding.implements);
21889
+ validateResourceOntologyBinding(resource.id, "actions", "action", binding.actions);
21890
+ validateResourceOntologyBinding(resource.id, "primaryAction", "action", binding.primaryAction);
21785
21891
  validateResourceOntologyBinding(resource.id, "reads", "object", binding.reads);
21786
21892
  validateResourceOntologyBinding(resource.id, "writes", "object", binding.writes);
21787
21893
  validateResourceOntologyBinding(resource.id, "usesCatalogs", "catalog", binding.usesCatalogs);
@@ -22610,6 +22716,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
22610
22716
  },
22611
22717
  ontology: DEFAULT_ONTOLOGY_SCOPE,
22612
22718
  resources: DEFAULT_ORGANIZATION_MODEL_RESOURCES,
22719
+ topology: DEFAULT_ORGANIZATION_MODEL_TOPOLOGY,
22613
22720
  actions: DEFAULT_ORGANIZATION_MODEL_ACTIONS,
22614
22721
  entities: DEFAULT_ORGANIZATION_MODEL_ENTITIES2,
22615
22722
  policies: DEFAULT_ORGANIZATION_MODEL_POLICIES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elevasis/core",
3
- "version": "0.24.0",
3
+ "version": "0.24.1",
4
4
  "license": "MIT",
5
5
  "description": "Minimal shared constants across Elevasis monorepo",
6
6
  "sideEffects": false,
@@ -41,8 +41,8 @@
41
41
  "rollup-plugin-dts": "^6.3.0",
42
42
  "tsup": "^8.0.0",
43
43
  "typescript": "5.9.2",
44
- "@repo/typescript-config": "0.0.0",
45
- "@repo/eslint-config": "0.0.0"
44
+ "@repo/eslint-config": "0.0.0",
45
+ "@repo/typescript-config": "0.0.0"
46
46
  },
47
47
  "dependencies": {
48
48
  "@anthropic-ai/sdk": "^0.62.0",
@@ -418,6 +418,42 @@ export type OrganizationModelIntegrationResourceEntry = z.infer<typeof Integrati
418
418
  export type OrganizationModelScriptResourceEntry = z.infer<typeof ScriptResourceEntrySchema>
419
419
  ```
420
420
 
421
+ ### `OrganizationModelTopology`
422
+
423
+ ```typescript
424
+ export type OrganizationModelTopology = z.infer<typeof OmTopologyDomainSchema>
425
+ ```
426
+
427
+ ### `OrganizationModelTopologyNodeKind`
428
+
429
+ ```typescript
430
+ export type OrganizationModelTopologyNodeKind = z.infer<typeof OmTopologyNodeKindSchema>
431
+ ```
432
+
433
+ ### `OrganizationModelTopologyNodeRef`
434
+
435
+ ```typescript
436
+ export type OrganizationModelTopologyNodeRef = z.infer<typeof OmTopologyNodeRefSchema>
437
+ ```
438
+
439
+ ### `OrganizationModelTopologyRelationshipKind`
440
+
441
+ ```typescript
442
+ export type OrganizationModelTopologyRelationshipKind = z.infer<typeof OmTopologyRelationshipKindSchema>
443
+ ```
444
+
445
+ ### `OrganizationModelTopologyRelationship`
446
+
447
+ ```typescript
448
+ export type OrganizationModelTopologyRelationship = z.infer<typeof OmTopologyRelationshipSchema>
449
+ ```
450
+
451
+ ### `OrganizationModelTopologyMetadata`
452
+
453
+ ```typescript
454
+ export type OrganizationModelTopologyMetadata = z.infer<typeof OmTopologyMetadataSchema>
455
+ ```
456
+
421
457
  ### `OrganizationModelActions`
422
458
 
423
459
  ```typescript
@@ -1287,13 +1323,15 @@ export interface HumanCheckpointDefinition extends ResourceDefinition {
1287
1323
  * Used by ResourceRegistry for discovery and Command View for visualization.
1288
1324
  */
1289
1325
  export interface DeploymentSpec {
1290
- /** Deployment version (semver) */
1291
- version: string
1292
- /** Optional Organization Model governance catalog used for OM-code validation */
1293
- organizationModel?: {
1294
- systems?: OrganizationModelSystems
1295
- resources?: OrganizationModelResources
1296
- }
1326
+ /** Deployment version (semver) */
1327
+ version: string
1328
+ /** Optional Organization Model governance catalog used for OM-code validation */
1329
+ organizationModel?: Partial<
1330
+ Pick<
1331
+ OrganizationModel,
1332
+ 'systems' | 'resources' | 'ontology' | 'topology' | 'roles' | 'policies' | 'entities' | 'actions'
1333
+ >
1334
+ >
1297
1335
  /** Workflow definitions */
1298
1336
  workflows?: WorkflowDefinition[]
1299
1337
  /** Agent definitions */
@@ -12,13 +12,11 @@ import type { ResourceMetricsConfig } from '../../../operations/observability/ty
12
12
  import type { ExecutionInterface } from '../interface/types'
13
13
 
14
14
  // Workflow configuration
15
- export interface WorkflowConfig extends ResourceDefinition {
16
- type: 'workflow'
17
- /** OM descriptor backing canonical identity and governance metadata. */
18
- resource?: WorkflowResourceEntry
19
- /** Lead-gen action key for registry derivation (e.g. 'lead-gen.company.apollo-import') */
20
- actionKey?: string
21
- }
15
+ export interface WorkflowConfig extends ResourceDefinition {
16
+ type: 'workflow'
17
+ /** OM descriptor backing canonical identity and governance metadata. */
18
+ resource?: WorkflowResourceEntry
19
+ }
22
20
 
23
21
  export type DescriptorBackedWorkflowConfig = Omit<WorkflowConfig, 'resourceId' | 'type' | 'resource'> & {
24
22
  resource: WorkflowResourceEntry