@elevasis/core 0.25.0 → 0.27.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 (80) hide show
  1. package/dist/index.d.ts +171 -90
  2. package/dist/index.js +377 -1541
  3. package/dist/knowledge/index.d.ts +48 -59
  4. package/dist/knowledge/index.js +1 -1
  5. package/dist/organization-model/index.d.ts +171 -90
  6. package/dist/organization-model/index.js +377 -1541
  7. package/dist/test-utils/index.d.ts +25 -33
  8. package/dist/test-utils/index.js +250 -1357
  9. package/package.json +1 -1
  10. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +990 -1065
  11. package/src/business/acquisition/api-schemas.test.ts +1996 -1882
  12. package/src/business/acquisition/api-schemas.ts +1478 -1502
  13. package/src/business/acquisition/crm-next-action.test.ts +45 -25
  14. package/src/business/acquisition/crm-next-action.ts +227 -220
  15. package/src/business/acquisition/crm-priority.test.ts +41 -8
  16. package/src/business/acquisition/crm-priority.ts +365 -349
  17. package/src/business/acquisition/crm-state-actions.test.ts +208 -153
  18. package/src/business/acquisition/derive-actions.test.ts +101 -34
  19. package/src/business/acquisition/derive-actions.ts +8 -92
  20. package/src/business/acquisition/ontology-validation.ts +76 -162
  21. package/src/business/acquisition/types.ts +7 -8
  22. package/src/business/pdf/sections/investment.ts +1 -1
  23. package/src/business/pdf/sections/summary-investment.ts +1 -1
  24. package/src/execution/engine/tools/tool-maps.ts +872 -831
  25. package/src/knowledge/queries.ts +0 -1
  26. package/src/organization-model/__tests__/content-kinds-registry.test.ts +35 -210
  27. package/src/organization-model/__tests__/cross-ref.test.ts +167 -0
  28. package/src/organization-model/__tests__/defaults.test.ts +4 -4
  29. package/src/organization-model/__tests__/domains/actions.test.ts +12 -36
  30. package/src/organization-model/__tests__/domains/offerings.test.ts +13 -6
  31. package/src/organization-model/__tests__/domains/resources.test.ts +497 -350
  32. package/src/organization-model/__tests__/domains/systems.test.ts +6 -7
  33. package/src/organization-model/__tests__/flatten-additive-merge.test.ts +68 -80
  34. package/src/organization-model/__tests__/foundation.test.ts +81 -14
  35. package/src/organization-model/__tests__/graph.test.ts +662 -694
  36. package/src/organization-model/__tests__/knowledge.test.ts +31 -17
  37. package/src/organization-model/__tests__/lookup-helpers.test.ts +128 -438
  38. package/src/organization-model/__tests__/migration-helpers.test.ts +362 -591
  39. package/src/organization-model/__tests__/prospecting-ssot.test.ts +68 -103
  40. package/src/organization-model/__tests__/published-zero-leak.test.ts +76 -0
  41. package/src/organization-model/__tests__/recursive-system-schema.test.ts +159 -532
  42. package/src/organization-model/__tests__/resolve.test.ts +79 -42
  43. package/src/organization-model/__tests__/schema-refinements.test.ts +72 -0
  44. package/src/organization-model/__tests__/schema.test.ts +65 -56
  45. package/src/organization-model/catalogs/lead-gen.ts +0 -103
  46. package/src/organization-model/cross-ref.ts +175 -0
  47. package/src/organization-model/defaults.ts +17 -702
  48. package/src/organization-model/domains/actions.ts +116 -333
  49. package/src/organization-model/domains/branding.ts +6 -6
  50. package/src/organization-model/domains/knowledge.ts +15 -7
  51. package/src/organization-model/domains/projects.ts +4 -4
  52. package/src/organization-model/domains/prospecting.ts +405 -395
  53. package/src/organization-model/domains/resources.ts +206 -135
  54. package/src/organization-model/domains/sales.test.ts +104 -218
  55. package/src/organization-model/domains/sales.ts +217 -380
  56. package/src/organization-model/domains/systems.ts +8 -23
  57. package/src/organization-model/graph/build.ts +223 -294
  58. package/src/organization-model/graph/schema.ts +2 -3
  59. package/src/organization-model/graph/types.ts +12 -14
  60. package/src/organization-model/helpers.ts +130 -218
  61. package/src/organization-model/index.ts +105 -124
  62. package/src/organization-model/migration-helpers.ts +211 -249
  63. package/src/organization-model/ontology.ts +0 -60
  64. package/src/organization-model/organization-graph.mdx +4 -5
  65. package/src/organization-model/organization-model.mdx +1 -1
  66. package/src/organization-model/published.ts +236 -226
  67. package/src/organization-model/resolve.ts +4 -5
  68. package/src/organization-model/schema-refinements.ts +667 -0
  69. package/src/organization-model/schema.ts +88 -889
  70. package/src/organization-model/types.ts +167 -161
  71. package/src/platform/registry/__tests__/validation.test.ts +23 -0
  72. package/src/platform/registry/validation.ts +13 -2
  73. package/src/reference/_generated/contracts.md +990 -1065
  74. package/src/organization-model/content-kinds/config.ts +0 -36
  75. package/src/organization-model/content-kinds/index.ts +0 -78
  76. package/src/organization-model/content-kinds/pipeline.ts +0 -68
  77. package/src/organization-model/content-kinds/registry.ts +0 -44
  78. package/src/organization-model/content-kinds/status.ts +0 -71
  79. package/src/organization-model/content-kinds/template.ts +0 -83
  80. package/src/organization-model/content-kinds/types.ts +0 -117
package/dist/index.js CHANGED
@@ -340,40 +340,6 @@ function addLegacyActionProjections(index, diagnostics, sourcesById, actions, en
340
340
  });
341
341
  }
342
342
  }
343
- function addSystemContentProjections(index, diagnostics, sourcesById, systemPath, system, schemaPath) {
344
- const content = system.content ?? {};
345
- for (const [localId, node] of Object.entries(content)) {
346
- if (node.kind !== "schema") continue;
347
- const entries = Object.fromEntries(
348
- Object.entries(content).filter(([, candidate]) => candidate.parentContentId === localId).map(([entryId, candidate]) => [
349
- entryId,
350
- {
351
- label: candidate.label ?? entryId,
352
- type: candidate.type,
353
- ...candidate.description !== void 0 ? { description: candidate.description } : {},
354
- ...candidate.data !== void 0 ? candidate.data : {}
355
- }
356
- ])
357
- );
358
- const catalogType = {
359
- id: formatOntologyId({ scope: systemPath, kind: "catalog", localId }),
360
- label: node.label ?? localId,
361
- description: node.description,
362
- ownerSystemId: systemPath,
363
- kind: node.type,
364
- ...typeof node.data?.["entityId"] === "string" ? { appliesTo: formatOntologyId({ scope: systemPath, kind: "object", localId: node.data["entityId"] }) } : {},
365
- ...Object.keys(entries).length > 0 ? { entries } : {},
366
- ...node.data !== void 0 ? { data: node.data } : {}
367
- };
368
- addRecord(index, diagnostics, sourcesById, "catalogTypes", catalogType, {
369
- source: "legacy.system.content",
370
- path: [...schemaPath, "content", localId],
371
- kind: "projected",
372
- systemPath,
373
- legacyId: `${systemPath}:${localId}`
374
- });
375
- }
376
- }
377
343
  function addSystemScopes(index, diagnostics, sourcesById, systems, prefix, schemaPath) {
378
344
  for (const [key, system] of Object.entries(systems)) {
379
345
  const systemPath = prefix ? `${prefix}.${key}` : key;
@@ -382,7 +348,6 @@ function addSystemScopes(index, diagnostics, sourcesById, systems, prefix, schem
382
348
  ...currentPath,
383
349
  "ontology"
384
350
  ]);
385
- addSystemContentProjections(index, diagnostics, sourcesById, systemPath, system, currentPath);
386
351
  addSystemScopes(index, diagnostics, sourcesById, childSystemsOf(system), systemPath, [
387
352
  ...currentPath,
388
353
  system.systems !== void 0 ? "systems" : "subsystems"
@@ -402,190 +367,6 @@ function compileOrganizationOntology(model) {
402
367
  function getOntologyDiagnostics(model) {
403
368
  return compileOrganizationOntology(model).diagnostics;
404
369
  }
405
-
406
- // src/organization-model/content-kinds/registry.ts
407
- function defineContentType(def) {
408
- return def;
409
- }
410
- var ContentNodeBaseSchema = z.object({
411
- /** Human-readable label for the content node. */
412
- label: z.string().trim().min(1).max(120).meta({ label: "Label" }),
413
- /** Optional one-paragraph description. */
414
- description: z.string().trim().min(1).max(2e3).optional().meta({ label: "Description" }),
415
- /** Optional display order within the system content map. */
416
- order: z.number().int().optional().meta({ label: "Order" }),
417
- /**
418
- * Local NodeId of the parent content node within the SAME system.
419
- * Per B4/L9: MUST resolve to a sibling in the same `system.content` map.
420
- * Per L19: parent and child MUST share the same `kind` (meta-category).
421
- */
422
- parentContentId: z.string().trim().min(1).max(200).optional().meta({ label: "Parent content id" })
423
- });
424
- var ContentNodeSchema = ContentNodeBaseSchema.extend({
425
- /** Meta-category (e.g. 'schema', 'config', 'knowledge', tenant-defined). */
426
- kind: z.string().trim().min(1).max(100).meta({ label: "Kind" }),
427
- /** Specific family within the meta-category (e.g. 'pipeline', 'kv'). */
428
- type: z.string().trim().min(1).max(100).meta({ label: "Type" }),
429
- /** Payload data; validated against registered payloadSchema when (kind, type) is known. */
430
- data: z.record(z.string(), z.unknown()).optional().meta({ label: "Data" })
431
- });
432
- z.object({
433
- /** Meta-category (tenant-defined or registry-shipped). */
434
- kind: z.string().trim().min(1).max(100).meta({ label: "Kind" }),
435
- /** Specific family within the meta-category. */
436
- type: z.string().trim().min(1).max(100).meta({ label: "Type" }),
437
- /** Human-readable label shown in the KB tree and describe views. */
438
- label: z.string().trim().min(1).max(120).meta({ label: "Label" }),
439
- /** Optional description. */
440
- description: z.string().trim().min(1).max(2e3).optional().meta({ label: "Description" }),
441
- /**
442
- * Which KB tree group this extension renders in.
443
- * Per L6: 'business-model' places it alongside Customers / Offerings / Goals.
444
- */
445
- treeGroup: z.union([z.enum(["profile", "business-model", "systems", "graph", "governance-wiring"]), z.string().min(1).max(100)]).meta({ label: "Tree group" }),
446
- /** Untyped payload; shape governed by the registered payloadSchema when available. */
447
- data: z.record(z.string(), z.unknown()).optional().meta({ label: "Data" })
448
- });
449
- var PipelinePayloadSchema = z.object({
450
- /**
451
- * Local NodeId of the entity this pipeline applies to (e.g. 'crm.deal').
452
- * `.meta({ ref: 'entity' })` enables SchemaDrivenFieldList to render a
453
- * clickable graph link to the referenced entity node.
454
- */
455
- entityId: z.string().trim().min(1).max(200).meta({ label: "Entity", ref: "entity", hint: "The entity type this pipeline tracks" }),
456
- /**
457
- * Optional Kanban column color token for UI rendering.
458
- */
459
- kanbanColor: z.string().trim().min(1).max(40).optional().meta({ label: "Kanban color", hint: "UI color token" })
460
- });
461
- var pipelineKind = defineContentType({
462
- kind: "schema",
463
- type: "pipeline",
464
- label: "Pipeline",
465
- description: "A named progression pipeline that applies to a specific entity type.",
466
- payloadSchema: PipelinePayloadSchema,
467
- parentTypes: []
468
- });
469
- var StagePayloadSchema = z.object({
470
- /**
471
- * Semantic classification for this stage.
472
- * Drives color, icon, and CRM-priority logic in consuming views.
473
- * Optional — prospecting stages use data.entityKind instead.
474
- * Enum aligned with SalesStageSemanticClassSchema (sales.ts).
475
- */
476
- semanticClass: z.enum(["open", "active", "nurturing", "closed_won", "closed_lost", "won", "lost", "closed"]).optional().meta({ label: "Semantic class", hint: "Semantic meaning of this stage", color: "blue" })
477
- });
478
- var stageKind = defineContentType({
479
- kind: "schema",
480
- type: "stage",
481
- label: "Stage",
482
- description: "A stage within a pipeline. Must be parented under a schema:pipeline content node.",
483
- payloadSchema: StagePayloadSchema,
484
- parentTypes: ["schema:pipeline"]
485
- });
486
- var TemplatePayloadSchema = z.object({
487
- /**
488
- * Optional description surfaced in the KB describe view and tooling.
489
- */
490
- description: z.string().trim().min(1).max(2e3).optional().meta({ label: "Description", hint: "What this template is used for" })
491
- });
492
- var templateKind = defineContentType({
493
- kind: "schema",
494
- type: "template",
495
- label: "Template",
496
- description: "A named build template (e.g. a prospecting pipeline sequence).",
497
- payloadSchema: TemplatePayloadSchema,
498
- parentTypes: []
499
- });
500
- var TemplateStepPayloadSchema = z.object({
501
- /**
502
- * Which entity type this step primarily operates on.
503
- */
504
- primaryEntity: z.enum(["company", "contact"]).meta({ label: "Primary entity", hint: "Entity type this step processes", color: "blue" }),
505
- /**
506
- * Action key identifying the workflow action executed by this step.
507
- * `.meta({ ref: 'action' })` enables SchemaDrivenFieldList to render a
508
- * clickable graph link.
509
- */
510
- actionKey: z.string().trim().min(1).max(200).meta({ label: "Action", ref: "action", hint: "Workflow action executed by this step" }),
511
- /**
512
- * IDs of sibling step local NodeIds this step depends on.
513
- */
514
- dependsOn: z.array(z.string().trim().min(1).max(200)).optional().meta({ label: "Depends on", hint: "Local NodeIds of prerequisite steps" })
515
- });
516
- var templateStepKind = defineContentType({
517
- kind: "schema",
518
- type: "template-step",
519
- label: "Template Step",
520
- description: "A step within a build template. Must be parented under a schema:template content node.",
521
- payloadSchema: TemplateStepPayloadSchema,
522
- parentTypes: ["schema:template"]
523
- });
524
- var StatusFlowPayloadSchema = z.object({
525
- /**
526
- * Which entity scope this status flow governs.
527
- */
528
- appliesTo: z.enum(["project", "milestone", "task"]).meta({ label: "Applies to", hint: "Entity scope governed by this status flow", color: "blue" })
529
- });
530
- var statusFlowKind = defineContentType({
531
- kind: "schema",
532
- type: "status-flow",
533
- label: "Status Flow",
534
- description: "A named set of statuses governing a project, milestone, or task entity.",
535
- payloadSchema: StatusFlowPayloadSchema,
536
- parentTypes: []
537
- });
538
- var StatusPayloadSchema = z.object({
539
- /**
540
- * Semantic classification string for this status.
541
- * Free-form to allow tenant-defined classifications (e.g. 'active', 'blocked',
542
- * 'completed'). Used by UI to apply color and icon fallbacks.
543
- * Optional — status nodes may omit this when the label is self-descriptive.
544
- */
545
- semanticClass: z.string().trim().min(1).max(100).optional().meta({ label: "Semantic class", hint: "Semantic meaning of this status (e.g. active, blocked, completed)" }),
546
- /**
547
- * Optional UI color token override for this status.
548
- */
549
- color: z.string().trim().min(1).max(40).optional().meta({ label: "Color", hint: "UI color token" })
550
- });
551
- var statusKind = defineContentType({
552
- kind: "schema",
553
- type: "status",
554
- label: "Status",
555
- description: "A single status within a status flow. Must be parented under a schema:status-flow content node.",
556
- payloadSchema: StatusPayloadSchema,
557
- parentTypes: ["schema:status-flow"]
558
- });
559
- var ConfigKvPayloadSchema = z.object({
560
- /**
561
- * Flat key-value entries. Values are JSON primitives.
562
- * Keys are short identifiers (e.g. 'maxBatchSize', 'featureEnabled').
563
- */
564
- entries: z.record(z.string().trim().min(1).max(200), z.union([z.string(), z.number(), z.boolean(), z.null()])).meta({ label: "Entries", hint: "Key-value configuration entries (string, number, boolean, or null values)" })
565
- });
566
- var configKvKind = defineContentType({
567
- kind: "config",
568
- type: "kv",
569
- label: "Key-Value Config",
570
- description: "A flat key-value configuration store co-located with a system. Values are JSON primitives.",
571
- payloadSchema: ConfigKvPayloadSchema,
572
- parentTypes: []
573
- });
574
-
575
- // src/organization-model/content-kinds/index.ts
576
- var CONTENT_KIND_REGISTRY = {
577
- "schema:pipeline": pipelineKind,
578
- "schema:stage": stageKind,
579
- "schema:template": templateKind,
580
- "schema:template-step": templateStepKind,
581
- "schema:status-flow": statusFlowKind,
582
- "schema:status": statusKind,
583
- "config:kv": configKvKind
584
- };
585
- function lookupContentType(kind, type) {
586
- const key = `${kind}:${type}`;
587
- return CONTENT_KIND_REGISTRY[key];
588
- }
589
370
  var ORGANIZATION_MODEL_ICON_TOKENS = [
590
371
  // Navigation / app areas
591
372
  "dashboard",
@@ -724,8 +505,8 @@ var OrganizationModelBrandingSchema = z.object({
724
505
  });
725
506
  var DEFAULT_ORGANIZATION_MODEL_BRANDING = {
726
507
  organizationName: "Default Organization",
727
- productName: "Elevasis",
728
- shortName: "Elevasis",
508
+ productName: "Organization OS",
509
+ shortName: "Org OS",
729
510
  logos: {}
730
511
  };
731
512
  var SurfaceTypeSchema = z.enum(["page", "dashboard", "graph", "detail", "list", "settings"]).meta({ label: "Surface type", color: "blue" });
@@ -1140,226 +921,7 @@ var ActionSchema = z.object({
1140
921
  var ActionsDomainSchema = z.record(z.string(), ActionSchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
1141
922
  message: "Each action entry id must match its map key"
1142
923
  }).default({});
1143
- var LEAD_GEN_ACTION_ENTRY_INPUTS = [
1144
- {
1145
- id: "lead-gen.company.source",
1146
- order: 10,
1147
- label: "Source companies",
1148
- description: "Import source companies from a list provider.",
1149
- scope: { domain: "sales" },
1150
- resourceId: "lgn-import-workflow",
1151
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/source" }]
1152
- },
1153
- {
1154
- id: "lead-gen.company.apollo-import",
1155
- order: 20,
1156
- label: "Import from Apollo",
1157
- description: "Pull companies and seed contact data from an Apollo search or list.",
1158
- scope: { domain: "sales" },
1159
- resourceId: "lgn-01c-apollo-import-workflow",
1160
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/apollo-import" }]
1161
- },
1162
- {
1163
- id: "lead-gen.contact.discover",
1164
- order: 30,
1165
- label: "Discover contact emails",
1166
- description: "Find email addresses for contacts at qualified companies.",
1167
- scope: { domain: "sales" },
1168
- resourceId: "lgn-04-email-discovery-workflow",
1169
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/discover" }]
1170
- },
1171
- {
1172
- id: "lead-gen.contact.verify-email",
1173
- order: 40,
1174
- label: "Verify emails",
1175
- description: "Check email deliverability before outreach.",
1176
- scope: { domain: "sales" },
1177
- resourceId: "lgn-05-email-verification-workflow",
1178
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/verify-email" }]
1179
- },
1180
- {
1181
- id: "lead-gen.company.apify-crawl",
1182
- order: 50,
1183
- label: "Crawl websites",
1184
- description: "Crawl company websites via Apify and store raw page markdown in enrichmentData.websiteCrawl.pages for downstream LLM analysis.",
1185
- scope: { domain: "sales" },
1186
- resourceId: "lgn-02a-apify-website-crawl-workflow",
1187
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/apify-crawl" }]
1188
- },
1189
- {
1190
- id: "lead-gen.company.website-extract",
1191
- order: 60,
1192
- label: "Extract website signals",
1193
- description: "Scrape and analyze company websites for qualification signals.",
1194
- scope: { domain: "sales" },
1195
- resourceId: "lgn-02-website-extract-workflow",
1196
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/website-extract" }]
1197
- },
1198
- {
1199
- id: "lead-gen.company.qualify",
1200
- order: 70,
1201
- label: "Qualify companies",
1202
- description: "Score and filter companies against the ICP rubric.",
1203
- scope: { domain: "sales" },
1204
- resourceId: "lgn-03-company-qualification-workflow",
1205
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/qualify" }]
1206
- },
1207
- {
1208
- id: "lead-gen.company.dtc-subscription-qualify",
1209
- order: 80,
1210
- label: "Qualify DTC subscription fit",
1211
- description: "Classify subscription potential and consumable-product fit for DTC brands.",
1212
- scope: { domain: "sales" },
1213
- resourceId: "lgn-03b-dtc-subscription-score-workflow",
1214
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/dtc-subscription-qualify" }]
1215
- },
1216
- {
1217
- id: "lead-gen.contact.apollo-decision-maker-enrich",
1218
- order: 90,
1219
- label: "Enrich decision-makers",
1220
- description: "Find and enrich qualified contacts at qualified companies via Apollo.",
1221
- scope: { domain: "sales" },
1222
- resourceId: "lgn-04b-apollo-decision-maker-enrich-workflow",
1223
- invocations: [
1224
- { kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/apollo-decision-maker-enrich" }
1225
- ]
1226
- },
1227
- {
1228
- id: "lead-gen.contact.personalize",
1229
- order: 100,
1230
- label: "Personalize outreach",
1231
- description: "Generate personalized opening lines for each contact.",
1232
- scope: { domain: "sales" },
1233
- resourceId: "ist-personalization-workflow",
1234
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/personalize" }]
1235
- },
1236
- {
1237
- id: "lead-gen.review.outreach-ready",
1238
- order: 110,
1239
- label: "Upload to outreach",
1240
- description: "Upload approved contacts to the outreach sequence after QC review.",
1241
- scope: { domain: "sales" },
1242
- resourceId: "ist-upload-contacts-workflow",
1243
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/review/outreach-ready" }]
1244
- },
1245
- {
1246
- id: "lead-gen.export.list",
1247
- order: 120,
1248
- label: "Export lead list",
1249
- description: "Export approved leads as a downloadable lead list.",
1250
- scope: { domain: "sales" },
1251
- resourceId: "lgn-06-export-list-workflow",
1252
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/export/list" }]
1253
- },
1254
- {
1255
- id: "lead-gen.company.cleanup",
1256
- order: 130,
1257
- label: "Clean up companies",
1258
- description: "Remove disqualified or duplicate companies from the list.",
1259
- scope: { domain: "sales" },
1260
- resourceId: "lgn-company-cleanup-workflow",
1261
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/cleanup" }]
1262
- }
1263
- ];
1264
- var LEAD_GEN_ACTION_ENTRIES = Object.fromEntries(
1265
- LEAD_GEN_ACTION_ENTRY_INPUTS.map((action) => {
1266
- const parsed = ActionSchema.parse(action);
1267
- return [parsed.id, parsed];
1268
- })
1269
- );
1270
- var CRM_ACTION_ENTRY_INPUTS = [
1271
- {
1272
- id: "send_reply",
1273
- order: 210,
1274
- label: "Send Reply",
1275
- description: "Send a contextual reply for an active CRM deal.",
1276
- scope: { domain: "sales" },
1277
- resourceId: "crm-send-reply-workflow",
1278
- affects: ["crm.deal"]
1279
- },
1280
- {
1281
- id: "send_link",
1282
- order: 220,
1283
- label: "Send Booking Link",
1284
- description: "Send a booking link to move a deal toward a scheduled call.",
1285
- scope: { domain: "sales" },
1286
- resourceId: "crm-send-booking-link-workflow",
1287
- affects: ["crm.deal"]
1288
- },
1289
- {
1290
- id: "send_nudge",
1291
- order: 230,
1292
- label: "Send Nudge",
1293
- description: "Send a follow-up nudge for a stalled CRM deal.",
1294
- scope: { domain: "sales" },
1295
- resourceId: "crm-send-nudge-workflow",
1296
- affects: ["crm.deal"]
1297
- },
1298
- {
1299
- id: "rebook",
1300
- order: 240,
1301
- label: "Rebook",
1302
- description: "Rebook a missed or rescheduled CRM appointment.",
1303
- scope: { domain: "sales" },
1304
- resourceId: "crm-rebook-workflow",
1305
- affects: ["crm.deal"]
1306
- },
1307
- {
1308
- id: "move_to_proposal",
1309
- order: 250,
1310
- label: "Move to Proposal",
1311
- description: "Advance a qualified CRM deal into the proposal stage.",
1312
- scope: { domain: "sales" },
1313
- resourceId: "move_to_proposal-workflow",
1314
- affects: ["crm.deal"]
1315
- },
1316
- {
1317
- id: "move_to_closing",
1318
- order: 260,
1319
- label: "Move to Closing",
1320
- description: "Advance a proposal-stage CRM deal into closing.",
1321
- scope: { domain: "sales" },
1322
- resourceId: "move_to_closing-workflow",
1323
- affects: ["crm.deal"]
1324
- },
1325
- {
1326
- id: "move_to_closed_won",
1327
- order: 270,
1328
- label: "Close Won",
1329
- description: "Mark a CRM deal as closed won.",
1330
- scope: { domain: "sales" },
1331
- resourceId: "move_to_closed_won-workflow",
1332
- affects: ["crm.deal"]
1333
- },
1334
- {
1335
- id: "move_to_closed_lost",
1336
- order: 280,
1337
- label: "Close Lost",
1338
- description: "Mark a CRM deal as closed lost.",
1339
- scope: { domain: "sales" },
1340
- resourceId: "move_to_closed_lost-workflow",
1341
- affects: ["crm.deal"]
1342
- },
1343
- {
1344
- id: "move_to_nurturing",
1345
- order: 290,
1346
- label: "Move to Nurturing",
1347
- description: "Move a CRM deal into nurturing for future follow-up.",
1348
- scope: { domain: "sales" },
1349
- resourceId: "move_to_nurturing-workflow",
1350
- affects: ["crm.deal"]
1351
- }
1352
- ];
1353
- var CRM_ACTION_ENTRIES = Object.fromEntries(
1354
- CRM_ACTION_ENTRY_INPUTS.map((action) => {
1355
- const parsed = ActionSchema.parse(action);
1356
- return [parsed.id, parsed];
1357
- })
1358
- );
1359
- var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {
1360
- ...LEAD_GEN_ACTION_ENTRIES,
1361
- ...CRM_ACTION_ENTRIES
1362
- };
924
+ var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {};
1363
925
  function findOrganizationActionById(id, actions = DEFAULT_ORGANIZATION_MODEL_ACTIONS) {
1364
926
  return actions[id];
1365
927
  }
@@ -1377,7 +939,7 @@ var UiPositionSchema = z.enum(["sidebar-primary", "sidebar-bottom"]).meta({ labe
1377
939
  var NodeIdPathSchema = SystemIdSchema;
1378
940
  var NodeIdStringSchema = z.string().trim().min(1).max(200).regex(
1379
941
  /^[a-z][a-z-]*:([a-z0-9-]+)(\.[a-z0-9-]+)*(:[a-z0-9.-]+)*$/,
1380
- "Node references must use kind:dotted-path (e.g. system:sales.crm or content-node:sales.crm:pipeline-id)"
942
+ "Node references must use kind:dotted-path (e.g. system:sales.crm or resource:lead-gen.company.qualify)"
1381
943
  );
1382
944
  var SystemUiSchema = z.object({
1383
945
  path: PathSchema,
@@ -1451,13 +1013,6 @@ var SystemEntrySchema = z.object({
1451
1013
  * shared contract records owned by this system.
1452
1014
  */
1453
1015
  ontology: OntologyScopeSchema.optional(),
1454
- /**
1455
- * @deprecated Compatibility-only bridge for old tenant content nodes and
1456
- * migration readers. New schema/catalog authoring belongs in ontology;
1457
- * new system-local settings belong in config. Bridge nodes are keyed by
1458
- * local NodeId and may still project to content-node:* graph IDs.
1459
- */
1460
- content: z.record(z.string().trim().min(1).max(200), ContentNodeSchema).optional(),
1461
1016
  /**
1462
1017
  * Recursive child systems, authored via nesting (per L11).
1463
1018
  * The key is the local system id; the full path is computed by joining
@@ -1468,7 +1023,7 @@ var SystemEntrySchema = z.object({
1468
1023
  systems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional(),
1469
1024
  /** @deprecated Use systems. Accepted as a compatibility alias during the ontology bridge. */
1470
1025
  subsystems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional()
1471
- }).refine((system) => system.label !== void 0 || system.title !== void 0, {
1026
+ }).strict().refine((system) => system.label !== void 0 || system.title !== void 0, {
1472
1027
  path: ["label"],
1473
1028
  message: "System must provide label or title"
1474
1029
  }).transform((system) => {
@@ -1483,6 +1038,25 @@ var SystemsDomainSchema = z.record(z.string(), SystemEntrySchema).refine((record
1483
1038
  var DEFAULT_ORGANIZATION_MODEL_SYSTEMS = {};
1484
1039
 
1485
1040
  // src/organization-model/domains/resources.ts
1041
+ var ContractRefSchema = z.string().trim().min(1).max(500).regex(
1042
+ /^[A-Za-z0-9@](?:[A-Za-z0-9_./@-]*[A-Za-z0-9_])?\/?[A-Za-z0-9_./@-]*#[A-Za-z_$][A-Za-z0-9_$]*$/,
1043
+ "ContractRef must be in the format package/subpath#ExportName (e.g. @repo/elevasis-core/contracts/apollo-import#inputSchema)"
1044
+ );
1045
+ function parseContractRef(ref) {
1046
+ const hashIndex = ref.lastIndexOf("#");
1047
+ if (hashIndex === -1) {
1048
+ throw new Error(`ContractRef "${ref}" is missing the required "#ExportName" suffix`);
1049
+ }
1050
+ const moduleSpecifier = ref.slice(0, hashIndex);
1051
+ const exportName = ref.slice(hashIndex + 1);
1052
+ if (!moduleSpecifier) {
1053
+ throw new Error(`ContractRef "${ref}" has an empty module specifier before "#"`);
1054
+ }
1055
+ if (!exportName) {
1056
+ throw new Error(`ContractRef "${ref}" has an empty export name after "#"`);
1057
+ }
1058
+ return { moduleSpecifier, exportName };
1059
+ }
1486
1060
  var ResourceKindSchema = z.enum(["workflow", "agent", "integration", "script"]).meta({ label: "Resource kind", color: "orange" });
1487
1061
  var ResourceGovernanceStatusSchema = z.enum(["active", "deprecated", "archived"]).meta({ label: "Governance status", color: "teal" });
1488
1062
  var AgentKindSchema = z.enum(["orchestrator", "specialist", "utility", "platform"]).meta({ label: "Agent kind", color: "violet" });
@@ -1511,7 +1085,20 @@ var ResourceOntologyBindingSchema = z.object({
1511
1085
  reads: z.array(OntologyIdSchema).optional(),
1512
1086
  writes: z.array(OntologyIdSchema).optional(),
1513
1087
  usesCatalogs: z.array(OntologyIdSchema).optional(),
1514
- emits: z.array(OntologyIdSchema).optional()
1088
+ emits: z.array(OntologyIdSchema).optional(),
1089
+ /**
1090
+ * Optional typed contract binding for this resource's workflow I/O.
1091
+ * Each ref is a `package/subpath#ExportName` string that resolves to a
1092
+ * Zod schema in `@repo/elevasis-core` (or the consumer's equivalent package).
1093
+ *
1094
+ * Absence of this field preserves all existing behavior — it is additive + optional.
1095
+ * Tier-1 validation (schema.ts): ref-string shape only (browser-safe, no imports).
1096
+ * Tier-2 validation (om:verify): intra-package typed-map resolution asserts ZodType.
1097
+ */
1098
+ contract: z.object({
1099
+ input: ContractRefSchema.optional(),
1100
+ output: ContractRefSchema.optional()
1101
+ }).optional()
1515
1102
  }).superRefine((binding, ctx) => {
1516
1103
  if (binding.primaryAction === void 0) return;
1517
1104
  if (binding.actions?.includes(binding.primaryAction)) return;
@@ -1727,13 +1314,10 @@ var KnowledgeTargetKindSchema = z.enum([
1727
1314
  "goal",
1728
1315
  "customer-segment",
1729
1316
  "offering",
1730
- "ontology",
1731
- // D4: content nodes are a valid knowledge target after compound-domain data moved into system.content
1732
- "content-node"
1317
+ "ontology"
1733
1318
  ]).meta({ label: "Target kind" });
1734
1319
  var KnowledgeTargetRefSchema = z.object({
1735
1320
  kind: KnowledgeTargetKindSchema,
1736
- // D4: content-node targets use a qualified id format '<system-path>:<local-content-id>'.
1737
1321
  // Ontology targets use the canonical '<scope>:<kind>/<local-id>' ontology id format.
1738
1322
  // Business-logic validation of target existence is done in OrganizationModelSchema.superRefine.
1739
1323
  id: z.string().trim().min(1).max(300)
@@ -1750,6 +1334,15 @@ var KnowledgeTargetRefSchema = z.object({
1750
1334
  });
1751
1335
  var LegacyKnowledgeLinkSchema = z.object({
1752
1336
  nodeId: z.union([NodeIdStringSchema, z.templateLiteral(["ontology:", OntologyIdSchema])])
1337
+ }).superRefine((link, ctx) => {
1338
+ const [kind] = link.nodeId.split(":");
1339
+ if (!KnowledgeTargetKindSchema.safeParse(kind).success) {
1340
+ ctx.addIssue({
1341
+ code: z.ZodIssueCode.custom,
1342
+ path: ["nodeId"],
1343
+ message: `Unknown knowledge target kind "${kind}"`
1344
+ });
1345
+ }
1753
1346
  });
1754
1347
  var CanonicalKnowledgeLinkSchema = z.object({
1755
1348
  target: KnowledgeTargetRefSchema
@@ -2046,112 +1639,166 @@ var PoliciesDomainSchema = z.record(z.string(), PolicySchema).refine((record) =>
2046
1639
  }).default({});
2047
1640
  var DEFAULT_ORGANIZATION_MODEL_POLICIES = {};
2048
1641
 
2049
- // src/organization-model/schema.ts
2050
- var OrganizationModelDomainKeySchema = z.enum([
2051
- "branding",
2052
- "identity",
2053
- "customers",
2054
- "offerings",
2055
- "roles",
2056
- "goals",
2057
- "systems",
2058
- "ontology",
2059
- "resources",
2060
- "topology",
2061
- "actions",
2062
- "entities",
2063
- "policies",
2064
- "knowledge"
2065
- ]);
2066
- var OrganizationModelDomainMetadataSchema = z.object({
2067
- version: z.literal(1).default(1),
2068
- lastModified: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "lastModified must be an ISO date string (YYYY-MM-DD)")
2069
- });
2070
- var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
2071
- branding: { version: 1, lastModified: "2026-05-10" },
2072
- identity: { version: 1, lastModified: "2026-05-10" },
2073
- customers: { version: 1, lastModified: "2026-05-10" },
2074
- offerings: { version: 1, lastModified: "2026-05-10" },
2075
- roles: { version: 1, lastModified: "2026-05-10" },
2076
- goals: { version: 1, lastModified: "2026-05-10" },
2077
- systems: { version: 1, lastModified: "2026-05-10" },
2078
- ontology: { version: 1, lastModified: "2026-05-14" },
2079
- resources: { version: 1, lastModified: "2026-05-10" },
2080
- topology: { version: 1, lastModified: "2026-05-14" },
2081
- actions: { version: 1, lastModified: "2026-05-10" },
2082
- entities: { version: 1, lastModified: "2026-05-10" },
2083
- policies: { version: 1, lastModified: "2026-05-10" },
2084
- knowledge: { version: 1, lastModified: "2026-05-10" }
2085
- };
2086
- var OrganizationModelDomainMetadataByDomainSchema = z.object({
2087
- branding: OrganizationModelDomainMetadataSchema,
2088
- identity: OrganizationModelDomainMetadataSchema,
2089
- customers: OrganizationModelDomainMetadataSchema,
2090
- offerings: OrganizationModelDomainMetadataSchema,
2091
- roles: OrganizationModelDomainMetadataSchema,
2092
- goals: OrganizationModelDomainMetadataSchema,
2093
- systems: OrganizationModelDomainMetadataSchema,
2094
- ontology: OrganizationModelDomainMetadataSchema,
2095
- resources: OrganizationModelDomainMetadataSchema,
2096
- topology: OrganizationModelDomainMetadataSchema,
2097
- actions: OrganizationModelDomainMetadataSchema,
2098
- entities: OrganizationModelDomainMetadataSchema,
2099
- policies: OrganizationModelDomainMetadataSchema,
2100
- knowledge: OrganizationModelDomainMetadataSchema
2101
- }).partial().default(DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA).transform((metadata) => ({ ...DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA, ...metadata }));
2102
- var OrganizationModelSchemaBase = z.object({
2103
- version: z.literal(1).default(1),
2104
- domainMetadata: OrganizationModelDomainMetadataByDomainSchema,
2105
- branding: OrganizationModelBrandingSchema,
2106
- navigation: OrganizationModelNavigationSchema,
2107
- identity: IdentityDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_IDENTITY),
2108
- customers: CustomersDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_CUSTOMERS),
2109
- offerings: OfferingsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_OFFERINGS),
2110
- roles: RolesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ROLES),
2111
- goals: GoalsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_GOALS),
2112
- systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
2113
- ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
2114
- resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
2115
- topology: OmTopologyDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_TOPOLOGY),
2116
- actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
2117
- entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
2118
- policies: PoliciesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_POLICIES),
2119
- // D3: flat Record<id, OrgKnowledgeNode> — no wrapper object
2120
- knowledge: KnowledgeDomainSchema.default({})
2121
- });
2122
- function addIssue(ctx, path, message) {
2123
- ctx.addIssue({
2124
- code: z.ZodIssueCode.custom,
2125
- path,
2126
- message
2127
- });
2128
- }
2129
- function isLifecycleEnabled(lifecycle, enabled) {
2130
- if (enabled === false) return false;
2131
- return lifecycle !== "deprecated" && lifecycle !== "archived";
2132
- }
2133
- function defaultSystemPathFor(id) {
2134
- return `/${id.replaceAll(".", "/")}`;
2135
- }
2136
- function asRoleHolderArray(heldBy) {
2137
- return Array.isArray(heldBy) ? heldBy : [heldBy];
1642
+ // src/organization-model/helpers.ts
1643
+ function childSystemsOf2(system) {
1644
+ return system.systems ?? system.subsystems ?? {};
2138
1645
  }
2139
- function isKnowledgeKindCompatibleWithTarget(knowledgeKind, targetKind) {
2140
- if (knowledgeKind === "reference") return true;
2141
- if (knowledgeKind === "playbook") {
2142
- return ["system", "resource", "stage", "action", "ontology"].includes(targetKind);
2143
- }
2144
- if (knowledgeKind === "strategy") {
2145
- return ["system", "goal", "offering", "customer-segment", "ontology"].includes(targetKind);
1646
+ function getSystem(model, path) {
1647
+ const segments = path.split(".");
1648
+ let current = model.systems;
1649
+ let node;
1650
+ for (const seg of segments) {
1651
+ node = current[seg];
1652
+ if (node === void 0) return void 0;
1653
+ current = childSystemsOf2(node);
2146
1654
  }
2147
- return false;
2148
- }
2149
- function isRecord(value) {
2150
- return typeof value === "object" && value !== null && !Array.isArray(value);
1655
+ return node;
2151
1656
  }
2152
- var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ctx) => {
2153
- function collectAllSystems(systems, prefix = "", schemaPath = ["systems"]) {
2154
- const result = [];
1657
+ function listAllSystems(model) {
1658
+ const results = [];
1659
+ function walk(map, prefix) {
1660
+ for (const [localId, system] of Object.entries(map)) {
1661
+ const fullPath = prefix ? `${prefix}.${localId}` : localId;
1662
+ results.push({ path: fullPath, system });
1663
+ const childSystems = childSystemsOf2(system);
1664
+ if (Object.keys(childSystems).length > 0) {
1665
+ walk(childSystems, fullPath);
1666
+ }
1667
+ }
1668
+ }
1669
+ walk(model.systems, "");
1670
+ return results;
1671
+ }
1672
+ function isPlainJsonObject(value) {
1673
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1674
+ }
1675
+ function mergeJsonConfig(base, override) {
1676
+ const result = { ...base };
1677
+ for (const [key, value] of Object.entries(override)) {
1678
+ const existing = result[key];
1679
+ result[key] = isPlainJsonObject(existing) && isPlainJsonObject(value) ? mergeJsonConfig(existing, value) : value;
1680
+ }
1681
+ return result;
1682
+ }
1683
+ function resolveSystemConfig(model, path) {
1684
+ const system = getSystem(model, path);
1685
+ if (system === void 0) return {};
1686
+ return mergeJsonConfig({}, system.config ?? {});
1687
+ }
1688
+
1689
+ // src/organization-model/cross-ref.ts
1690
+ var ONTOLOGY_REFERENCE_KEY_KINDS = {
1691
+ valueType: "value-type",
1692
+ catalogType: "catalog",
1693
+ objectType: "object",
1694
+ eventType: "event",
1695
+ actionType: "action",
1696
+ linkType: "link",
1697
+ interfaceType: "interface",
1698
+ propertyType: "property",
1699
+ groupType: "group",
1700
+ surfaceType: "surface",
1701
+ stepCatalog: "catalog"
1702
+ };
1703
+ function buildOmCrossRefIndex(model) {
1704
+ const systemsById = /* @__PURE__ */ new Map();
1705
+ for (const { path, system } of listAllSystems(model)) {
1706
+ systemsById.set(path, system);
1707
+ systemsById.set(system.id, system);
1708
+ }
1709
+ const resourceIds = new Set(Object.keys(model.resources ?? {}));
1710
+ const knowledgeIds = new Set(Object.keys(model.knowledge ?? {}));
1711
+ const roleIds = new Set(Object.keys(model.roles ?? {}));
1712
+ const goalIds = new Set(Object.keys(model.goals ?? {}));
1713
+ const actionIds = new Set(Object.keys(model.actions ?? {}));
1714
+ const customerSegmentIds = new Set(Object.keys(model.customers ?? {}));
1715
+ const offeringIds = new Set(Object.keys(model.offerings ?? {}));
1716
+ const ontologyCompilation = compileOrganizationOntology(model);
1717
+ const ontologyIndexByKind = {
1718
+ object: ontologyCompilation.ontology.objectTypes,
1719
+ link: ontologyCompilation.ontology.linkTypes,
1720
+ action: ontologyCompilation.ontology.actionTypes,
1721
+ catalog: ontologyCompilation.ontology.catalogTypes,
1722
+ event: ontologyCompilation.ontology.eventTypes,
1723
+ interface: ontologyCompilation.ontology.interfaceTypes,
1724
+ "value-type": ontologyCompilation.ontology.valueTypes,
1725
+ property: ontologyCompilation.ontology.sharedProperties,
1726
+ group: ontologyCompilation.ontology.groups,
1727
+ surface: ontologyCompilation.ontology.surfaces
1728
+ };
1729
+ const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index) => Object.keys(index)));
1730
+ const stageIds = /* @__PURE__ */ new Set();
1731
+ for (const catalog of Object.values(ontologyCompilation.ontology.catalogTypes)) {
1732
+ if (catalog.kind !== "stage") continue;
1733
+ const entries = catalog.entries;
1734
+ if (entries !== void 0) {
1735
+ for (const stageId of Object.keys(entries)) {
1736
+ stageIds.add(stageId);
1737
+ }
1738
+ }
1739
+ }
1740
+ return {
1741
+ systemsById,
1742
+ resourceIds,
1743
+ knowledgeIds,
1744
+ roleIds,
1745
+ goalIds,
1746
+ actionIds,
1747
+ customerSegmentIds,
1748
+ offeringIds,
1749
+ ontologyIds,
1750
+ ontologyIndexByKind,
1751
+ stageIds
1752
+ };
1753
+ }
1754
+ function knowledgeTargetExists(index, kind, id) {
1755
+ if (kind === "system") return index.systemsById.has(id);
1756
+ if (kind === "resource") return index.resourceIds.has(id);
1757
+ if (kind === "knowledge") return index.knowledgeIds.has(id);
1758
+ if (kind === "stage") return index.stageIds.has(id);
1759
+ if (kind === "action") return index.actionIds.has(id);
1760
+ if (kind === "role") return index.roleIds.has(id);
1761
+ if (kind === "goal") return index.goalIds.has(id);
1762
+ if (kind === "customer-segment") return index.customerSegmentIds.has(id);
1763
+ if (kind === "offering") return index.offeringIds.has(id);
1764
+ if (kind === "ontology") return index.ontologyIds.has(id);
1765
+ return false;
1766
+ }
1767
+
1768
+ // src/organization-model/schema-refinements.ts
1769
+ function addIssue(ctx, path, message) {
1770
+ ctx.addIssue({
1771
+ code: z.ZodIssueCode.custom,
1772
+ path,
1773
+ message
1774
+ });
1775
+ }
1776
+ function isLifecycleEnabled(lifecycle, enabled) {
1777
+ if (enabled === false) return false;
1778
+ return lifecycle !== "deprecated" && lifecycle !== "archived";
1779
+ }
1780
+ function defaultSystemPathFor(id) {
1781
+ return `/${id.replaceAll(".", "/")}`;
1782
+ }
1783
+ function asRoleHolderArray(heldBy) {
1784
+ return Array.isArray(heldBy) ? heldBy : [heldBy];
1785
+ }
1786
+ function isKnowledgeKindCompatibleWithTarget(knowledgeKind, targetKind) {
1787
+ if (knowledgeKind === "reference") return true;
1788
+ if (knowledgeKind === "playbook") {
1789
+ return ["system", "resource", "stage", "action", "ontology"].includes(targetKind);
1790
+ }
1791
+ if (knowledgeKind === "strategy") {
1792
+ return ["system", "goal", "offering", "customer-segment", "ontology"].includes(targetKind);
1793
+ }
1794
+ return false;
1795
+ }
1796
+ function isRecord(value) {
1797
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1798
+ }
1799
+ function refineOrganizationModel(model, ctx) {
1800
+ function collectAllSystems(systems, prefix = "", schemaPath = ["systems"]) {
1801
+ const result = [];
2155
1802
  for (const [key, system] of Object.entries(systems)) {
2156
1803
  const path = prefix ? `${prefix}.${key}` : key;
2157
1804
  const currentSchemaPath = [...schemaPath, key];
@@ -2159,7 +1806,10 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2159
1806
  const childSystems = system.systems ?? system.subsystems;
2160
1807
  if (childSystems !== void 0) {
2161
1808
  result.push(
2162
- ...collectAllSystems(childSystems, path, [...currentSchemaPath, system.systems !== void 0 ? "systems" : "subsystems"])
1809
+ ...collectAllSystems(childSystems, path, [
1810
+ ...currentSchemaPath,
1811
+ system.systems !== void 0 ? "systems" : "subsystems"
1812
+ ])
2163
1813
  );
2164
1814
  }
2165
1815
  }
@@ -2180,7 +1830,9 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2180
1830
  `System "${system.id}" references unknown parent "${system.parentSystemId}"`
2181
1831
  );
2182
1832
  }
2183
- const hasChildren = Object.keys(system.systems ?? system.subsystems ?? {}).length > 0 || allSystems.some((candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes("."));
1833
+ const hasChildren = Object.keys(system.systems ?? system.subsystems ?? {}).length > 0 || allSystems.some(
1834
+ (candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes(".")
1835
+ );
2184
1836
  const contributesRoutePath = system.ui?.path !== void 0 || system.path !== void 0 || !hasChildren;
2185
1837
  if (contributesRoutePath) {
2186
1838
  const effectivePath = system.ui?.path ?? system.path ?? defaultSystemPathFor(path);
@@ -2202,11 +1854,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2202
1854
  (candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes(".") && isLifecycleEnabled(candidate.system.lifecycle, candidate.system.enabled)
2203
1855
  );
2204
1856
  if (!hasEnabledDescendant) {
2205
- addIssue(
2206
- ctx,
2207
- [...schemaPath, "lifecycle"],
2208
- `System "${path}" is active but has no active descendants`
2209
- );
1857
+ addIssue(ctx, [...schemaPath, "lifecycle"], `System "${path}" is active but has no active descendants`);
2210
1858
  }
2211
1859
  }
2212
1860
  });
@@ -2320,7 +1968,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2320
1968
  });
2321
1969
  });
2322
1970
  Object.values(model.entities).forEach((entity) => {
2323
- if (!systemsById.has(entity.ownedBySystemId)) {
1971
+ if (systemsById.size > 0 && !systemsById.has(entity.ownedBySystemId)) {
2324
1972
  addIssue(
2325
1973
  ctx,
2326
1974
  ["entities", entity.id, "ownedBySystemId"],
@@ -2438,23 +2086,9 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2438
2086
  }
2439
2087
  });
2440
2088
  });
2441
- const stageIds = /* @__PURE__ */ new Set();
2442
- const actionIds = new Set(Object.keys(model.actions));
2443
- const offeringsById = new Map(Object.entries(model.offerings));
2089
+ const idx = buildOmCrossRefIndex(model);
2090
+ const { ontologyIndexByKind, ontologyIds } = idx;
2444
2091
  const ontologyCompilation = compileOrganizationOntology(model);
2445
- const ontologyIndexByKind = {
2446
- object: ontologyCompilation.ontology.objectTypes,
2447
- link: ontologyCompilation.ontology.linkTypes,
2448
- action: ontologyCompilation.ontology.actionTypes,
2449
- catalog: ontologyCompilation.ontology.catalogTypes,
2450
- event: ontologyCompilation.ontology.eventTypes,
2451
- interface: ontologyCompilation.ontology.interfaceTypes,
2452
- "value-type": ontologyCompilation.ontology.valueTypes,
2453
- property: ontologyCompilation.ontology.sharedProperties,
2454
- group: ontologyCompilation.ontology.groups,
2455
- surface: ontologyCompilation.ontology.surfaces
2456
- };
2457
- const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index) => Object.keys(index)));
2458
2092
  function topologyTargetExists(ref) {
2459
2093
  if (ref.kind === "system") return systemsById.has(ref.id);
2460
2094
  if (ref.kind === "resource") return resourcesById.has(ref.id);
@@ -2474,19 +2108,6 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2474
2108
  );
2475
2109
  });
2476
2110
  });
2477
- const ontologyReferenceKeyKinds = {
2478
- valueType: "value-type",
2479
- catalogType: "catalog",
2480
- objectType: "object",
2481
- eventType: "event",
2482
- actionType: "action",
2483
- linkType: "link",
2484
- interfaceType: "interface",
2485
- propertyType: "property",
2486
- groupType: "group",
2487
- surfaceType: "surface",
2488
- stepCatalog: "catalog"
2489
- };
2490
2111
  function validateKnownOntologyReferences(ownerId, value, path, seen = /* @__PURE__ */ new WeakSet()) {
2491
2112
  if (Array.isArray(value)) {
2492
2113
  value.forEach((entry, index) => validateKnownOntologyReferences(ownerId, entry, [...path, index], seen));
@@ -2496,7 +2117,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2496
2117
  if (seen.has(value)) return;
2497
2118
  seen.add(value);
2498
2119
  Object.entries(value).forEach(([key, entry]) => {
2499
- const expectedKind = ontologyReferenceKeyKinds[key];
2120
+ const expectedKind = ONTOLOGY_REFERENCE_KEY_KINDS[key];
2500
2121
  if (expectedKind !== void 0) {
2501
2122
  if (typeof entry !== "string") {
2502
2123
  addIssue(ctx, [...path, key], `Ontology record "${ownerId}" ${key} must be an ontology ID string`);
@@ -2557,22 +2178,9 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2557
2178
  );
2558
2179
  }
2559
2180
  });
2560
- function knowledgeTargetExists(kind, id) {
2561
- if (kind === "system") return systemsById.has(id);
2562
- if (kind === "resource") return resourcesById.has(id);
2563
- if (kind === "knowledge") return knowledgeById.has(id);
2564
- if (kind === "stage") return stageIds.has(id);
2565
- if (kind === "action") return actionIds.has(id);
2566
- if (kind === "role") return rolesById.has(id);
2567
- if (kind === "goal") return goalsById.has(id);
2568
- if (kind === "customer-segment") return segmentsById.has(id);
2569
- if (kind === "offering") return offeringsById.has(id);
2570
- if (kind === "ontology") return ontologyIds.has(id);
2571
- return false;
2572
- }
2573
2181
  Object.entries(model.knowledge).forEach(([nodeId, node]) => {
2574
2182
  node.links.forEach((link, linkIndex) => {
2575
- if (!knowledgeTargetExists(link.target.kind, link.target.id)) {
2183
+ if (!knowledgeTargetExists(idx, link.target.kind, link.target.id)) {
2576
2184
  addIssue(
2577
2185
  ctx,
2578
2186
  ["knowledge", nodeId, "links", linkIndex, "target"],
@@ -2617,13 +2225,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2617
2225
  if (ontologyIndexByKind[expectedKind][ontologyId] === void 0) {
2618
2226
  addIssue(
2619
2227
  ctx,
2620
- [
2621
- "resources",
2622
- resourceId,
2623
- "ontology",
2624
- bindingKey,
2625
- ...Array.isArray(ids) ? [ontologyIndex] : []
2626
- ],
2228
+ ["resources", resourceId, "ontology", bindingKey, ...Array.isArray(ids) ? [ontologyIndex] : []],
2627
2229
  `Resource "${resourceId}" ontology binding "${bindingKey}" references unknown ${expectedKind} ontology ID "${ontologyId}"`
2628
2230
  );
2629
2231
  }
@@ -2638,6 +2240,23 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2638
2240
  validateResourceOntologyBinding(resource.id, "writes", "object", binding.writes);
2639
2241
  validateResourceOntologyBinding(resource.id, "usesCatalogs", "catalog", binding.usesCatalogs);
2640
2242
  validateResourceOntologyBinding(resource.id, "emits", "event", binding.emits);
2243
+ if (binding.contract !== void 0) {
2244
+ const contractEntries = [
2245
+ ["input", binding.contract.input],
2246
+ ["output", binding.contract.output]
2247
+ ];
2248
+ for (const [side, ref] of contractEntries) {
2249
+ if (ref === void 0) continue;
2250
+ const result = ContractRefSchema.safeParse(ref);
2251
+ if (!result.success) {
2252
+ addIssue(
2253
+ ctx,
2254
+ ["resources", resource.id, "ontology", "contract", side],
2255
+ `Resource "${resource.id}" contract.${side} "${ref}" is not a valid ContractRef (expected "package/subpath#ExportName")`
2256
+ );
2257
+ }
2258
+ }
2259
+ }
2641
2260
  });
2642
2261
  Object.values(model.roles).forEach((role) => {
2643
2262
  if (role.heldBy === void 0) return;
@@ -2672,82 +2291,85 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2672
2291
  }
2673
2292
  });
2674
2293
  });
2675
- function validateSystemContent(system, systemPath) {
2676
- const childSystems = system.systems ?? system.subsystems;
2677
- const childKey = system.systems !== void 0 ? "systems" : "subsystems";
2678
- const content = system.content;
2679
- if (content === void 0 || Object.keys(content).length === 0) {
2680
- if (childSystems !== void 0) {
2681
- Object.entries(childSystems).forEach(([childLocalId, child]) => {
2682
- validateSystemContent(child, [...systemPath, childKey, childLocalId]);
2683
- });
2684
- }
2685
- return;
2686
- }
2687
- Object.entries(content).forEach(([localId, node]) => {
2688
- if (node.parentContentId !== void 0 && !(node.parentContentId in content)) {
2689
- addIssue(
2690
- ctx,
2691
- [...systemPath, "content", localId, "parentContentId"],
2692
- `Content node "${localId}" parentContentId "${node.parentContentId}" does not resolve within the same system`
2693
- );
2694
- }
2695
- });
2696
- Object.entries(content).forEach(([localId, node]) => {
2697
- const visited = /* @__PURE__ */ new Set();
2698
- let currentId = node.parentContentId;
2699
- while (currentId !== void 0) {
2700
- if (currentId === localId || visited.has(currentId)) {
2701
- addIssue(
2702
- ctx,
2703
- [...systemPath, "content", localId, "parentContentId"],
2704
- `Content node "${localId}" has a parentContentId cycle`
2705
- );
2706
- break;
2707
- }
2708
- visited.add(currentId);
2709
- currentId = content[currentId]?.parentContentId;
2710
- }
2711
- });
2712
- Object.entries(content).forEach(([localId, node]) => {
2713
- const childDef = lookupContentType(node.kind, node.type);
2714
- if (childDef !== void 0 && node.data !== void 0) {
2715
- const result = childDef.payloadSchema.safeParse(node.data);
2716
- if (!result.success) {
2717
- addIssue(
2718
- ctx,
2719
- [...systemPath, "content", localId, "data"],
2720
- `Content node "${localId}" (${node.kind}:${node.type}) data failed payload validation: ${result.error.message}`
2721
- );
2722
- }
2723
- }
2724
- if (node.parentContentId !== void 0 && childDef !== void 0) {
2725
- const parentNode = content[node.parentContentId];
2726
- if (parentNode !== void 0) {
2727
- const parentDef = lookupContentType(parentNode.kind, parentNode.type);
2728
- if (parentDef !== void 0 && childDef.kind !== parentDef.kind) {
2729
- addIssue(
2730
- ctx,
2731
- [...systemPath, "content", localId, "parentContentId"],
2732
- `Content node "${localId}" kind "${childDef.kind}" cannot parent under "${node.parentContentId}" kind "${parentDef.kind}": parentContentId must be same-meta-kind (per L19)`
2733
- );
2734
- }
2735
- }
2736
- }
2737
- });
2738
- if (childSystems !== void 0) {
2739
- Object.entries(childSystems).forEach(([childLocalId, child]) => {
2740
- validateSystemContent(child, [...systemPath, childKey, childLocalId]);
2741
- });
2742
- }
2743
- }
2744
- Object.entries(model.systems).forEach(([systemKey, system]) => {
2745
- validateSystemContent(system, ["systems", systemKey]);
2746
- });
2747
2294
  for (const diagnostic of ontologyCompilation.diagnostics) {
2748
2295
  addIssue(ctx, diagnostic.path, diagnostic.message);
2749
2296
  }
2297
+ }
2298
+
2299
+ // src/organization-model/schema.ts
2300
+ var OrganizationModelDomainKeySchema = z.enum([
2301
+ "branding",
2302
+ "identity",
2303
+ "customers",
2304
+ "offerings",
2305
+ "roles",
2306
+ "goals",
2307
+ "systems",
2308
+ "ontology",
2309
+ "resources",
2310
+ "topology",
2311
+ "actions",
2312
+ "entities",
2313
+ "policies",
2314
+ "knowledge"
2315
+ ]);
2316
+ var OrganizationModelDomainMetadataSchema = z.object({
2317
+ version: z.literal(1).default(1),
2318
+ lastModified: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "lastModified must be an ISO date string (YYYY-MM-DD)")
2319
+ });
2320
+ var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
2321
+ branding: { version: 1, lastModified: "2026-05-10" },
2322
+ identity: { version: 1, lastModified: "2026-05-10" },
2323
+ customers: { version: 1, lastModified: "2026-05-10" },
2324
+ offerings: { version: 1, lastModified: "2026-05-10" },
2325
+ roles: { version: 1, lastModified: "2026-05-10" },
2326
+ goals: { version: 1, lastModified: "2026-05-10" },
2327
+ systems: { version: 1, lastModified: "2026-05-10" },
2328
+ ontology: { version: 1, lastModified: "2026-05-14" },
2329
+ resources: { version: 1, lastModified: "2026-05-10" },
2330
+ topology: { version: 1, lastModified: "2026-05-14" },
2331
+ actions: { version: 1, lastModified: "2026-05-10" },
2332
+ entities: { version: 1, lastModified: "2026-05-10" },
2333
+ policies: { version: 1, lastModified: "2026-05-10" },
2334
+ knowledge: { version: 1, lastModified: "2026-05-10" }
2335
+ };
2336
+ var OrganizationModelDomainMetadataByDomainSchema = z.object({
2337
+ branding: OrganizationModelDomainMetadataSchema,
2338
+ identity: OrganizationModelDomainMetadataSchema,
2339
+ customers: OrganizationModelDomainMetadataSchema,
2340
+ offerings: OrganizationModelDomainMetadataSchema,
2341
+ roles: OrganizationModelDomainMetadataSchema,
2342
+ goals: OrganizationModelDomainMetadataSchema,
2343
+ systems: OrganizationModelDomainMetadataSchema,
2344
+ ontology: OrganizationModelDomainMetadataSchema,
2345
+ resources: OrganizationModelDomainMetadataSchema,
2346
+ topology: OrganizationModelDomainMetadataSchema,
2347
+ actions: OrganizationModelDomainMetadataSchema,
2348
+ entities: OrganizationModelDomainMetadataSchema,
2349
+ policies: OrganizationModelDomainMetadataSchema,
2350
+ knowledge: OrganizationModelDomainMetadataSchema
2351
+ }).partial().default(DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA).transform((metadata) => ({ ...DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA, ...metadata }));
2352
+ var OrganizationModelSchemaBase = z.object({
2353
+ version: z.literal(1).default(1),
2354
+ domainMetadata: OrganizationModelDomainMetadataByDomainSchema,
2355
+ branding: OrganizationModelBrandingSchema.default(DEFAULT_ORGANIZATION_MODEL_BRANDING),
2356
+ navigation: OrganizationModelNavigationSchema,
2357
+ identity: IdentityDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_IDENTITY),
2358
+ customers: CustomersDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_CUSTOMERS),
2359
+ offerings: OfferingsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_OFFERINGS),
2360
+ roles: RolesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ROLES),
2361
+ goals: GoalsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_GOALS),
2362
+ systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
2363
+ ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
2364
+ resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
2365
+ topology: OmTopologyDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_TOPOLOGY),
2366
+ actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
2367
+ entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
2368
+ policies: PoliciesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_POLICIES),
2369
+ // D3: flat Record<id, OrgKnowledgeNode> — no wrapper object
2370
+ knowledge: KnowledgeDomainSchema.default({})
2750
2371
  });
2372
+ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine(refineOrganizationModel);
2751
2373
  var OrganizationGraphNodeKindSchema = z.enum([
2752
2374
  "organization",
2753
2375
  "system",
@@ -2764,9 +2386,8 @@ var OrganizationGraphNodeKindSchema = z.enum([
2764
2386
  "goal",
2765
2387
  "surface",
2766
2388
  "navigation-group",
2767
- // Phase 3 preview Phase 4 populates via graph projection of system.content entries.
2768
- "ontology",
2769
- "content-node"
2389
+ // Ontology records are projected from compiled System.ontology scopes.
2390
+ "ontology"
2770
2391
  ]);
2771
2392
  var OrganizationGraphEdgeKindSchema = z.enum([
2772
2393
  "contains",
@@ -2849,311 +2470,11 @@ var SETTINGS_ROLES_SURFACE_ID = "settings.roles";
2849
2470
 
2850
2471
  // src/organization-model/defaults.ts
2851
2472
  var DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE = {};
2852
- var DEFAULT_ORGANIZATION_MODEL_ENTITIES2 = DEFAULT_ORGANIZATION_MODEL_ENTITIES;
2473
+ var DEFAULT_ORGANIZATION_MODEL_ENTITIES2 = {};
2853
2474
  var DEFAULT_ORGANIZATION_MODEL_NAVIGATION2 = {
2854
2475
  sidebar: {
2855
- primary: {
2856
- dashboard: {
2857
- type: "surface",
2858
- label: "Dashboard",
2859
- path: "/",
2860
- surfaceType: "dashboard",
2861
- icon: "dashboard",
2862
- order: 10,
2863
- targets: { systems: ["dashboard"] }
2864
- },
2865
- business: {
2866
- type: "group",
2867
- label: "Business",
2868
- icon: "briefcase",
2869
- order: 20,
2870
- children: {
2871
- sales: {
2872
- type: "surface",
2873
- label: "Sales",
2874
- path: "/sales",
2875
- surfaceType: "page",
2876
- icon: "sales",
2877
- order: 10,
2878
- targets: { systems: ["sales"] }
2879
- },
2880
- clients: {
2881
- type: "surface",
2882
- label: "Clients",
2883
- path: "/clients",
2884
- surfaceType: "list",
2885
- icon: "clients",
2886
- order: 20,
2887
- targets: { systems: ["clients"] }
2888
- },
2889
- projects: {
2890
- type: "surface",
2891
- label: "Projects",
2892
- path: "/projects",
2893
- surfaceType: "page",
2894
- icon: "projects",
2895
- order: 30,
2896
- targets: { systems: ["projects"] }
2897
- }
2898
- }
2899
- },
2900
- operations: {
2901
- type: "group",
2902
- label: "Operations",
2903
- icon: "operations",
2904
- order: 30,
2905
- children: {
2906
- "operations-overview": {
2907
- type: "surface",
2908
- label: "Overview",
2909
- path: "/operations",
2910
- surfaceType: "page",
2911
- order: 10,
2912
- targets: { systems: ["operations.overview"] }
2913
- },
2914
- "operations-systems": {
2915
- type: "surface",
2916
- label: "Systems",
2917
- path: "/operations/systems",
2918
- surfaceType: "page",
2919
- order: 20,
2920
- targets: { systems: ["operations"] }
2921
- },
2922
- "operations-resources": {
2923
- type: "surface",
2924
- label: "Resources",
2925
- path: "/operations/resources",
2926
- surfaceType: "list",
2927
- order: 30,
2928
- targets: { systems: ["operations.resources"] }
2929
- },
2930
- "operations-command-queue": {
2931
- type: "surface",
2932
- label: "Command Queue",
2933
- path: "/operations/command-queue",
2934
- surfaceType: "list",
2935
- order: 40,
2936
- targets: { systems: ["operations.command-queue"] }
2937
- },
2938
- "operations-task-scheduler": {
2939
- type: "surface",
2940
- label: "Task Scheduler",
2941
- path: "/operations/task-scheduler",
2942
- surfaceType: "list",
2943
- order: 50,
2944
- targets: { systems: ["operations.task-scheduler"] }
2945
- }
2946
- }
2947
- },
2948
- monitoring: {
2949
- type: "group",
2950
- label: "Monitoring",
2951
- icon: "monitoring",
2952
- order: 40,
2953
- children: {
2954
- "monitoring-overview": {
2955
- type: "surface",
2956
- label: "Overview",
2957
- path: "/monitoring",
2958
- surfaceType: "page",
2959
- order: 10,
2960
- targets: { systems: ["monitoring"] }
2961
- },
2962
- "monitoring-calendar": {
2963
- type: "surface",
2964
- label: "Calendar",
2965
- path: "/monitoring/calendar",
2966
- surfaceType: "page",
2967
- order: 20,
2968
- targets: { systems: ["monitoring.calendar"] }
2969
- },
2970
- "monitoring-activity-log": {
2971
- type: "surface",
2972
- label: "Activity Log",
2973
- path: "/monitoring/activity-log",
2974
- surfaceType: "list",
2975
- order: 30,
2976
- targets: { systems: ["monitoring.activity-log"] }
2977
- },
2978
- "monitoring-execution-logs": {
2979
- type: "surface",
2980
- label: "Execution Logs",
2981
- path: "/monitoring/execution-logs",
2982
- surfaceType: "list",
2983
- order: 40,
2984
- targets: { systems: ["monitoring.execution-logs"] }
2985
- },
2986
- "monitoring-execution-health": {
2987
- type: "surface",
2988
- label: "Execution Health",
2989
- path: "/monitoring/execution-health",
2990
- surfaceType: "dashboard",
2991
- order: 50,
2992
- targets: { systems: ["monitoring.execution-health"] }
2993
- },
2994
- "monitoring-notifications": {
2995
- type: "surface",
2996
- label: "Notifications",
2997
- path: "/monitoring/notifications",
2998
- surfaceType: "list",
2999
- order: 60,
3000
- targets: { systems: ["monitoring.notifications"] }
3001
- },
3002
- "monitoring-requests": {
3003
- type: "surface",
3004
- label: "Requests",
3005
- path: "/monitoring/requests",
3006
- surfaceType: "list",
3007
- order: 70,
3008
- targets: { systems: ["monitoring.submitted-requests"] }
3009
- }
3010
- }
3011
- },
3012
- knowledge: {
3013
- type: "surface",
3014
- label: "Knowledge Base",
3015
- path: "/knowledge",
3016
- surfaceType: "page",
3017
- icon: "knowledge",
3018
- order: 50
3019
- }
3020
- },
3021
- bottom: {
3022
- settings: {
3023
- type: "group",
3024
- label: "Settings",
3025
- icon: "settings",
3026
- order: 10,
3027
- children: {
3028
- "settings-account": {
3029
- type: "surface",
3030
- label: "Account",
3031
- path: "/settings/account",
3032
- surfaceType: "settings",
3033
- order: 10,
3034
- targets: { systems: ["settings.account"] }
3035
- },
3036
- "settings-appearance": {
3037
- type: "surface",
3038
- label: "Appearance",
3039
- path: "/settings/appearance",
3040
- surfaceType: "settings",
3041
- order: 20,
3042
- targets: { systems: ["settings.appearance"] }
3043
- },
3044
- "settings-roles": {
3045
- type: "surface",
3046
- label: "My Roles",
3047
- path: "/settings/roles",
3048
- surfaceType: "settings",
3049
- order: 30,
3050
- targets: { systems: ["settings.roles"] }
3051
- },
3052
- "settings-organization": {
3053
- type: "surface",
3054
- label: "Organization",
3055
- path: "/settings/organization",
3056
- surfaceType: "settings",
3057
- order: 40,
3058
- targets: { systems: ["settings.organization"] }
3059
- },
3060
- "settings-credentials": {
3061
- type: "surface",
3062
- label: "Credentials",
3063
- path: "/settings/credentials",
3064
- surfaceType: "settings",
3065
- order: 50,
3066
- targets: { systems: ["settings.credentials"] }
3067
- },
3068
- "settings-api-keys": {
3069
- type: "surface",
3070
- label: "API Keys",
3071
- path: "/settings/api-keys",
3072
- surfaceType: "settings",
3073
- order: 60,
3074
- targets: { systems: ["settings.api-keys"] }
3075
- },
3076
- "settings-webhooks": {
3077
- type: "surface",
3078
- label: "Webhooks",
3079
- path: "/settings/webhooks",
3080
- surfaceType: "settings",
3081
- order: 70,
3082
- targets: { systems: ["settings.webhooks"] }
3083
- },
3084
- "settings-deployments": {
3085
- type: "surface",
3086
- label: "Deployments",
3087
- path: "/settings/deployments",
3088
- surfaceType: "settings",
3089
- order: 80,
3090
- targets: { systems: ["settings.deployments"] }
3091
- }
3092
- }
3093
- },
3094
- admin: {
3095
- type: "group",
3096
- label: "Admin",
3097
- icon: "admin",
3098
- order: 20,
3099
- children: {
3100
- "admin-dashboard": {
3101
- type: "surface",
3102
- label: "Dashboard",
3103
- path: "/admin/dashboard",
3104
- surfaceType: "dashboard",
3105
- order: 10,
3106
- targets: { systems: ["admin"] },
3107
- requiresAdmin: true
3108
- },
3109
- "admin-system-health": {
3110
- type: "surface",
3111
- label: "System Health",
3112
- path: "/admin/system-health",
3113
- surfaceType: "dashboard",
3114
- order: 20,
3115
- targets: { systems: ["admin.system-health"] },
3116
- requiresAdmin: true
3117
- },
3118
- "admin-organizations": {
3119
- type: "surface",
3120
- label: "Organizations",
3121
- path: "/admin/organizations",
3122
- surfaceType: "list",
3123
- order: 30,
3124
- targets: { systems: ["admin.organizations"] },
3125
- requiresAdmin: true
3126
- },
3127
- "admin-users": {
3128
- type: "surface",
3129
- label: "Users",
3130
- path: "/admin/users",
3131
- surfaceType: "list",
3132
- order: 40,
3133
- targets: { systems: ["admin.users"] },
3134
- requiresAdmin: true
3135
- },
3136
- "admin-design-showcase": {
3137
- type: "surface",
3138
- label: "Design Showcase",
3139
- path: "/admin/design-showcase",
3140
- surfaceType: "page",
3141
- order: 50,
3142
- targets: { systems: ["admin.design-showcase"] },
3143
- requiresAdmin: true
3144
- },
3145
- "admin-debug": {
3146
- type: "surface",
3147
- label: "Debug",
3148
- path: "/admin/debug",
3149
- surfaceType: "page",
3150
- order: 60,
3151
- targets: { systems: ["admin.debug"] },
3152
- requiresAdmin: true
3153
- }
3154
- }
3155
- }
3156
- }
2476
+ primary: {},
2477
+ bottom: {}
3157
2478
  }
3158
2479
  };
3159
2480
  var DEFAULT_ORGANIZATION_MODEL = {
@@ -3166,406 +2487,19 @@ var DEFAULT_ORGANIZATION_MODEL = {
3166
2487
  offerings: DEFAULT_ORGANIZATION_MODEL_OFFERINGS,
3167
2488
  roles: DEFAULT_ORGANIZATION_MODEL_ROLES,
3168
2489
  goals: DEFAULT_ORGANIZATION_MODEL_GOALS,
3169
- systems: {
3170
- dashboard: {
3171
- id: "dashboard",
3172
- order: 10,
3173
- label: "Dashboard",
3174
- enabled: true,
3175
- lifecycle: "active",
3176
- path: "/",
3177
- icon: "dashboard"
3178
- },
3179
- platform: {
3180
- id: "platform",
3181
- order: 30,
3182
- label: "Platform",
3183
- description: "Elevasis platform architecture, capabilities, and implementation patterns",
3184
- enabled: true,
3185
- lifecycle: "active",
3186
- color: "cyan",
3187
- icon: "platform"
3188
- },
3189
- finance: {
3190
- id: "finance",
3191
- order: 40,
3192
- label: "Finance",
3193
- description: "Finance operations, accounting, billing, reconciliation, and tax prep",
3194
- enabled: true,
3195
- lifecycle: "active",
3196
- color: "green",
3197
- icon: "finance"
3198
- },
3199
- sales: {
3200
- id: "sales",
3201
- order: 60,
3202
- label: "Sales",
3203
- description: "Revenue workflows and customer acquisition",
3204
- enabled: true,
3205
- lifecycle: "active",
3206
- color: "blue",
3207
- icon: "sales",
3208
- path: "/sales"
3209
- },
3210
- "sales.crm": {
3211
- id: "sales.crm",
3212
- order: 70,
3213
- label: "CRM",
3214
- description: "Relationship pipeline and deal management",
3215
- enabled: true,
3216
- lifecycle: "active",
3217
- actions: Object.values(CRM_ACTION_ENTRIES).map((action) => ({
3218
- actionId: action.id,
3219
- intent: "exposes"
3220
- })),
3221
- color: "blue",
3222
- icon: "crm",
3223
- path: "/crm"
3224
- },
3225
- "sales.lead-gen": {
3226
- id: "sales.lead-gen",
3227
- order: 80,
3228
- label: "Lead Gen",
3229
- description: "Prospecting, qualification, and outreach preparation",
3230
- enabled: true,
3231
- lifecycle: "active",
3232
- actions: Object.values(LEAD_GEN_ACTION_ENTRIES).map((action) => ({
3233
- actionId: action.id,
3234
- intent: "exposes"
3235
- })),
3236
- color: "cyan",
3237
- icon: "lead-gen",
3238
- path: "/lead-gen"
3239
- },
3240
- projects: {
3241
- id: "projects",
3242
- order: 90,
3243
- label: "Projects",
3244
- description: "Projects, milestones, and client work execution",
3245
- enabled: true,
3246
- lifecycle: "active",
3247
- color: "orange",
3248
- icon: "projects",
3249
- path: "/projects"
3250
- },
3251
- clients: {
3252
- id: "clients",
3253
- order: 100,
3254
- label: "Clients",
3255
- description: "Client relationships, accounts, and business context",
3256
- enabled: true,
3257
- lifecycle: "active",
3258
- color: "orange",
3259
- icon: "clients",
3260
- path: "/clients"
3261
- },
3262
- operations: {
3263
- id: "operations",
3264
- order: 110,
3265
- label: "Operations",
3266
- description: "Operational resources, topology, and orchestration visibility",
3267
- enabled: true,
3268
- lifecycle: "active",
3269
- color: "violet",
3270
- icon: "operations"
3271
- },
3272
- "knowledge.command-view": {
3273
- id: "knowledge.command-view",
3274
- order: 120,
3275
- label: "Command View",
3276
- enabled: true,
3277
- lifecycle: "active",
3278
- path: "/knowledge/command-view",
3279
- devOnly: true
3280
- },
3281
- "operations.overview": {
3282
- id: "operations.overview",
3283
- order: 130,
3284
- label: "Overview",
3285
- enabled: true,
3286
- lifecycle: "active",
3287
- path: "/operations"
3288
- },
3289
- "operations.resources": {
3290
- id: "operations.resources",
3291
- order: 140,
3292
- label: "Resources",
3293
- enabled: true,
3294
- lifecycle: "active",
3295
- path: "/operations/resources"
3296
- },
3297
- "operations.command-queue": {
3298
- id: "operations.command-queue",
3299
- order: 150,
3300
- label: "Command Queue",
3301
- enabled: true,
3302
- lifecycle: "active",
3303
- path: "/operations/command-queue"
3304
- },
3305
- "operations.sessions": {
3306
- id: "operations.sessions",
3307
- order: 160,
3308
- label: "Sessions",
3309
- enabled: false,
3310
- lifecycle: "deprecated",
3311
- path: "/operations/sessions"
3312
- },
3313
- "operations.task-scheduler": {
3314
- id: "operations.task-scheduler",
3315
- order: 170,
3316
- label: "Task Scheduler",
3317
- enabled: true,
3318
- lifecycle: "active",
3319
- path: "/operations/task-scheduler"
3320
- },
3321
- monitoring: {
3322
- id: "monitoring",
3323
- order: 180,
3324
- label: "Monitoring",
3325
- enabled: true,
3326
- lifecycle: "active"
3327
- },
3328
- "monitoring.calendar": {
3329
- id: "monitoring.calendar",
3330
- order: 190,
3331
- label: "Calendar",
3332
- description: "Google Calendar events and agenda views",
3333
- enabled: true,
3334
- lifecycle: "active",
3335
- path: "/monitoring/calendar",
3336
- icon: "calendar"
3337
- },
3338
- "monitoring.activity-log": {
3339
- id: "monitoring.activity-log",
3340
- order: 200,
3341
- label: "Activity Log",
3342
- enabled: true,
3343
- lifecycle: "active",
3344
- path: "/monitoring/activity-log"
3345
- },
3346
- "monitoring.execution-logs": {
3347
- id: "monitoring.execution-logs",
3348
- order: 210,
3349
- label: "Execution Logs",
3350
- enabled: true,
3351
- lifecycle: "active",
3352
- path: "/monitoring/execution-logs"
3353
- },
3354
- "monitoring.execution-health": {
3355
- id: "monitoring.execution-health",
3356
- order: 220,
3357
- label: "Execution Health",
3358
- enabled: true,
3359
- lifecycle: "active",
3360
- path: "/monitoring/execution-health"
3361
- },
3362
- "monitoring.cost-analytics": {
3363
- id: "monitoring.cost-analytics",
3364
- order: 230,
3365
- label: "Cost Analytics",
3366
- enabled: false,
3367
- lifecycle: "deprecated",
3368
- path: "/monitoring/cost-analytics"
3369
- },
3370
- "monitoring.notifications": {
3371
- id: "monitoring.notifications",
3372
- order: 240,
3373
- label: "Notifications",
3374
- enabled: true,
3375
- lifecycle: "active",
3376
- path: "/monitoring/notifications"
3377
- },
3378
- "monitoring.submitted-requests": {
3379
- id: "monitoring.submitted-requests",
3380
- order: 250,
3381
- label: "Submitted Requests",
3382
- enabled: true,
3383
- lifecycle: "active",
3384
- path: "/monitoring/requests"
3385
- },
3386
- settings: {
3387
- id: "settings",
3388
- order: 260,
3389
- label: "Settings",
3390
- enabled: true,
3391
- lifecycle: "active",
3392
- icon: "settings"
3393
- },
3394
- "settings.account": {
3395
- id: "settings.account",
3396
- order: 270,
3397
- label: "Account",
3398
- enabled: true,
3399
- lifecycle: "active",
3400
- path: "/settings/account"
3401
- },
3402
- "settings.appearance": {
3403
- id: "settings.appearance",
3404
- order: 280,
3405
- label: "Appearance",
3406
- enabled: true,
3407
- lifecycle: "active",
3408
- path: "/settings/appearance"
3409
- },
3410
- "settings.roles": {
3411
- id: "settings.roles",
3412
- order: 290,
3413
- label: "My Roles",
3414
- enabled: true,
3415
- lifecycle: "active",
3416
- path: "/settings/roles"
3417
- },
3418
- "settings.organization": {
3419
- id: "settings.organization",
3420
- order: 300,
3421
- label: "Organization",
3422
- enabled: true,
3423
- lifecycle: "active",
3424
- path: "/settings/organization"
3425
- },
3426
- "settings.credentials": {
3427
- id: "settings.credentials",
3428
- order: 310,
3429
- label: "Credentials",
3430
- enabled: true,
3431
- lifecycle: "active",
3432
- path: "/settings/credentials"
3433
- },
3434
- "settings.api-keys": {
3435
- id: "settings.api-keys",
3436
- order: 320,
3437
- label: "API Keys",
3438
- enabled: true,
3439
- lifecycle: "active",
3440
- path: "/settings/api-keys"
3441
- },
3442
- "settings.webhooks": {
3443
- id: "settings.webhooks",
3444
- order: 330,
3445
- label: "Webhooks",
3446
- enabled: true,
3447
- lifecycle: "active",
3448
- path: "/settings/webhooks"
3449
- },
3450
- "settings.deployments": {
3451
- id: "settings.deployments",
3452
- order: 340,
3453
- label: "Deployments",
3454
- enabled: true,
3455
- lifecycle: "active",
3456
- path: "/settings/deployments"
3457
- },
3458
- admin: {
3459
- id: "admin",
3460
- order: 350,
3461
- label: "Admin",
3462
- enabled: true,
3463
- lifecycle: "active",
3464
- path: "/admin",
3465
- icon: "admin",
3466
- requiresAdmin: true
3467
- },
3468
- "admin.system-health": {
3469
- id: "admin.system-health",
3470
- order: 360,
3471
- label: "System Health",
3472
- enabled: true,
3473
- lifecycle: "active",
3474
- path: "/admin/system-health"
3475
- },
3476
- "admin.organizations": {
3477
- id: "admin.organizations",
3478
- order: 370,
3479
- label: "Organizations",
3480
- enabled: true,
3481
- lifecycle: "active",
3482
- path: "/admin/organizations"
3483
- },
3484
- "admin.users": {
3485
- id: "admin.users",
3486
- order: 380,
3487
- label: "Users",
3488
- enabled: true,
3489
- lifecycle: "active",
3490
- path: "/admin/users"
3491
- },
3492
- "admin.design-showcase": {
3493
- id: "admin.design-showcase",
3494
- order: 390,
3495
- label: "Design Showcase",
3496
- enabled: true,
3497
- lifecycle: "active",
3498
- path: "/admin/design-showcase"
3499
- },
3500
- "admin.debug": {
3501
- id: "admin.debug",
3502
- order: 400,
3503
- label: "Debug",
3504
- enabled: true,
3505
- lifecycle: "active",
3506
- path: "/admin/debug"
3507
- },
3508
- archive: {
3509
- id: "archive",
3510
- order: 410,
3511
- label: "Archive",
3512
- enabled: true,
3513
- lifecycle: "active",
3514
- path: "/archive",
3515
- icon: "archive",
3516
- devOnly: true
3517
- },
3518
- "archive.agent-chat": {
3519
- id: "archive.agent-chat",
3520
- order: 420,
3521
- label: "Agent Chat",
3522
- enabled: true,
3523
- lifecycle: "active",
3524
- path: "/archive/agent-chat"
3525
- },
3526
- "archive.execution-runner": {
3527
- id: "archive.execution-runner",
3528
- order: 430,
3529
- label: "Execution Runner",
3530
- enabled: true,
3531
- lifecycle: "active",
3532
- path: "/archive/execution-runner"
3533
- },
3534
- seo: {
3535
- id: "seo",
3536
- order: 440,
3537
- label: "SEO",
3538
- enabled: false,
3539
- lifecycle: "deprecated",
3540
- path: "/seo"
3541
- },
3542
- knowledge: {
3543
- id: "knowledge",
3544
- order: 450,
3545
- label: "Knowledge",
3546
- description: "Operational knowledge, playbooks, and strategy docs",
3547
- enabled: true,
3548
- lifecycle: "active",
3549
- color: "teal",
3550
- icon: "knowledge"
3551
- },
3552
- "knowledge.base": {
3553
- id: "knowledge.base",
3554
- order: 460,
3555
- label: "Knowledge Base",
3556
- enabled: true,
3557
- lifecycle: "active",
3558
- path: "/knowledge"
3559
- }
3560
- },
2490
+ // Generic empty systems map. Elevasis-specific systems (platform, sales, sales.crm,
2491
+ // sales.lead-gen, monitoring, settings, admin, etc.) have been relocated to
2492
+ // `@repo/elevasis-core/src/organization-model/systems.ts` via `canonicalOrganizationModel`.
2493
+ // Tenant OM configs supply their own systems via `resolveOrganizationModel`.
2494
+ systems: {},
3561
2495
  ontology: DEFAULT_ONTOLOGY_SCOPE,
3562
2496
  resources: DEFAULT_ORGANIZATION_MODEL_RESOURCES,
3563
2497
  topology: DEFAULT_ORGANIZATION_MODEL_TOPOLOGY,
3564
- actions: DEFAULT_ORGANIZATION_MODEL_ACTIONS,
2498
+ // Generic empty actions map. Elevasis-specific action entries have been relocated to
2499
+ // `@repo/elevasis-core/src/organization-model/actions.ts`.
2500
+ actions: {},
3565
2501
  entities: DEFAULT_ORGANIZATION_MODEL_ENTITIES2,
3566
2502
  policies: DEFAULT_ORGANIZATION_MODEL_POLICIES,
3567
- // Phase 4 (D1): statuses top-level field removed; bridge status mirrors may
3568
- // still project from System.content, but primary authoring belongs in ontology.
3569
2503
  knowledge: DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE
3570
2504
  };
3571
2505
  var StatusSemanticClassSchema = z.enum([
@@ -3870,156 +2804,6 @@ var DEFAULT_ORGANIZATION_MODEL_STATUSES = {
3870
2804
  }
3871
2805
  };
3872
2806
 
3873
- // src/organization-model/catalogs/lead-gen.ts
3874
- var LEAD_GEN_STAGE_CATALOG = {
3875
- // Prospecting - company population
3876
- scraped: {
3877
- key: "scraped",
3878
- label: "Scraped",
3879
- description: "Company was scraped from a source directory (Apify actor run).",
3880
- order: 1,
3881
- entity: "company"
3882
- },
3883
- populated: {
3884
- key: "populated",
3885
- label: "Companies found",
3886
- description: "Companies have been found and added to the lead-gen list.",
3887
- order: 2,
3888
- entity: "company"
3889
- },
3890
- crawled: {
3891
- key: "crawled",
3892
- label: "Websites crawled",
3893
- description: "Company websites have been crawled (e.g. via Apify) and raw page content stored for downstream LLM analysis.",
3894
- order: 2.5,
3895
- entity: "company"
3896
- },
3897
- extracted: {
3898
- key: "extracted",
3899
- label: "Websites analyzed",
3900
- description: "Company websites have been analyzed for business signals.",
3901
- order: 3,
3902
- entity: "company"
3903
- },
3904
- enriched: {
3905
- key: "enriched",
3906
- label: "Enriched",
3907
- description: "Company or contact enriched with third-party data (e.g. Tomba, Anymailfinder).",
3908
- order: 4,
3909
- entity: "company"
3910
- },
3911
- "decision-makers-enriched": {
3912
- key: "decision-makers-enriched",
3913
- label: "Decision-makers found",
3914
- description: "Decision-maker contacts discovered and attached to a qualified company.",
3915
- order: 6,
3916
- entity: "company",
3917
- recordEntity: "contact",
3918
- recordStageKey: "discovered"
3919
- },
3920
- // Prospecting - contact discovery
3921
- discovered: {
3922
- key: "discovered",
3923
- label: "Decision-makers found",
3924
- description: "Decision-maker contact details have been found.",
3925
- order: 5,
3926
- entity: "contact"
3927
- },
3928
- verified: {
3929
- key: "verified",
3930
- label: "Emails verified",
3931
- description: "Contact email addresses have been checked for deliverability.",
3932
- order: 7,
3933
- entity: "contact"
3934
- },
3935
- // Qualification
3936
- qualified: {
3937
- key: "qualified",
3938
- label: "Companies qualified",
3939
- description: "Companies have been scored against the qualification criteria.",
3940
- order: 8,
3941
- entity: "company"
3942
- },
3943
- // Outreach
3944
- personalized: {
3945
- key: "personalized",
3946
- label: "Personalized",
3947
- description: "Outreach message personalized for the contact (Instantly personalization workflow).",
3948
- order: 9,
3949
- entity: "contact"
3950
- },
3951
- uploaded: {
3952
- key: "uploaded",
3953
- label: "Reviewed and exported",
3954
- description: "Approved records have been reviewed and exported for handoff.",
3955
- order: 10,
3956
- entity: "company",
3957
- additionalEntities: ["contact"]
3958
- },
3959
- interested: {
3960
- key: "interested",
3961
- label: "Interested",
3962
- description: "Contact replied with a positive signal (Instantly reply-handler transition).",
3963
- order: 11,
3964
- entity: "contact"
3965
- }
3966
- };
3967
-
3968
- // src/organization-model/helpers.ts
3969
- function childSystemsOf2(system) {
3970
- return system.systems ?? system.subsystems ?? {};
3971
- }
3972
- function getSystem(model, path) {
3973
- const segments = path.split(".");
3974
- let current = model.systems;
3975
- let node;
3976
- for (const seg of segments) {
3977
- node = current[seg];
3978
- if (node === void 0) return void 0;
3979
- current = childSystemsOf2(node);
3980
- }
3981
- return node;
3982
- }
3983
- function listAllSystems(model) {
3984
- const results = [];
3985
- function walk(map, prefix) {
3986
- for (const [localId, system] of Object.entries(map)) {
3987
- const fullPath = prefix ? `${prefix}.${localId}` : localId;
3988
- results.push({ path: fullPath, system });
3989
- const childSystems = childSystemsOf2(system);
3990
- if (Object.keys(childSystems).length > 0) {
3991
- walk(childSystems, fullPath);
3992
- }
3993
- }
3994
- }
3995
- walk(model.systems, "");
3996
- return results;
3997
- }
3998
- function isPlainJsonObject(value) {
3999
- return typeof value === "object" && value !== null && !Array.isArray(value);
4000
- }
4001
- function mergeJsonConfig(base, override) {
4002
- const result = { ...base };
4003
- for (const [key, value] of Object.entries(override)) {
4004
- const existing = result[key];
4005
- result[key] = isPlainJsonObject(existing) && isPlainJsonObject(value) ? mergeJsonConfig(existing, value) : value;
4006
- }
4007
- return result;
4008
- }
4009
- function resolveSystemConfig(model, path) {
4010
- const system = getSystem(model, path);
4011
- if (system === void 0) return {};
4012
- let resolved = {};
4013
- for (const node of Object.values(system.content ?? {})) {
4014
- if (node.kind !== "config" || node.type !== "kv") continue;
4015
- const entries = node.data?.entries;
4016
- if (isPlainJsonObject(entries)) {
4017
- resolved = mergeJsonConfig(resolved, entries);
4018
- }
4019
- }
4020
- return mergeJsonConfig(resolved, system.config ?? {});
4021
- }
4022
-
4023
2807
  // src/organization-model/resolve.ts
4024
2808
  function isPlainObject(value) {
4025
2809
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -4101,6 +2885,9 @@ function resolveOrganizationModelWithResources(override, organizationId) {
4101
2885
  }
4102
2886
 
4103
2887
  // src/organization-model/surface-projection.ts
2888
+ function normalizePath(path) {
2889
+ return path.length > 1 ? path.replace(/\/+$/, "") : path;
2890
+ }
4104
2891
  function collectSystemsById(model) {
4105
2892
  const systemsById = /* @__PURE__ */ new Map();
4106
2893
  for (const { path, system } of listAllSystems(model)) {
@@ -4180,6 +2967,55 @@ function projectOrganizationSurfaces(model) {
4180
2967
  };
4181
2968
  });
4182
2969
  }
2970
+ function validateOrganizationSurfaceProjection(model) {
2971
+ const issues = [];
2972
+ const systemsById = collectSystemsById(model);
2973
+ const surfaceIds = /* @__PURE__ */ new Set();
2974
+ const surfacePaths = /* @__PURE__ */ new Map();
2975
+ function addIssue2(issue) {
2976
+ issues.push(issue);
2977
+ }
2978
+ getSidebarSurfaces(model).forEach(({ id, surface, path }) => {
2979
+ if (surfaceIds.has(id)) {
2980
+ addIssue2({
2981
+ code: "duplicate-surface-id",
2982
+ message: `Surface id "${id}" must be unique`,
2983
+ path,
2984
+ surfaceId: id,
2985
+ value: id
2986
+ });
2987
+ } else {
2988
+ surfaceIds.add(id);
2989
+ }
2990
+ const normalizedPath = normalizePath(surface.path);
2991
+ const existingSurfaceId = surfacePaths.get(normalizedPath);
2992
+ if (existingSurfaceId !== void 0) {
2993
+ addIssue2({
2994
+ code: "duplicate-surface-path",
2995
+ message: `Surface path "${surface.path}" is already used by surface "${existingSurfaceId}"`,
2996
+ path: [...path, "path"],
2997
+ surfaceId: id,
2998
+ value: surface.path
2999
+ });
3000
+ } else {
3001
+ surfacePaths.set(normalizedPath, id);
3002
+ }
3003
+ surface.targets?.systems?.forEach((systemId, systemIndex) => {
3004
+ if (systemsById.has(systemId)) {
3005
+ return;
3006
+ }
3007
+ addIssue2({
3008
+ code: "unknown-surface-system",
3009
+ message: `Surface "${id}" references unknown system "${systemId}"`,
3010
+ path: [...path, "targets", "systems", systemIndex],
3011
+ surfaceId: id,
3012
+ systemId,
3013
+ value: systemId
3014
+ });
3015
+ });
3016
+ });
3017
+ return issues;
3018
+ }
4183
3019
 
4184
3020
  // src/organization-model/foundation.ts
4185
3021
  function createFoundationOrganizationModel(override) {
@@ -4536,4 +3372,4 @@ function scaffoldOrganizationModel(model, spec) {
4536
3372
  return scaffoldKnowledgeNode(model, spec);
4537
3373
  }
4538
3374
 
4539
- export { ActionIdSchema, ActionInvocationKindSchema, ActionInvocationSchema, ActionRefSchema, ActionSchema, ActionScopeSchema, ActionsDomainSchema, AgentKindSchema, AgentResourceEntrySchema, AgentRoleHolderSchema, ApiEndpointInvocationSchema, CRM_ACTION_ENTRIES, CodeReferenceRoleSchema, CodeReferenceSchema, CustomerSegmentSchema, CustomersDomainSchema, DEFAULT_ONTOLOGY_SCOPE, DEFAULT_ORGANIZATION_MODEL, DEFAULT_ORGANIZATION_MODEL_ACTIONS, DEFAULT_ORGANIZATION_MODEL_CUSTOMERS, DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA, DEFAULT_ORGANIZATION_MODEL_ENTITIES, DEFAULT_ORGANIZATION_MODEL_GOALS, DEFAULT_ORGANIZATION_MODEL_NAVIGATION, DEFAULT_ORGANIZATION_MODEL_OFFERINGS, DEFAULT_ORGANIZATION_MODEL_POLICIES, DEFAULT_ORGANIZATION_MODEL_RESOURCES, DEFAULT_ORGANIZATION_MODEL_ROLES, DEFAULT_ORGANIZATION_MODEL_STATUSES, DEFAULT_ORGANIZATION_MODEL_SYSTEMS, DEFAULT_ORGANIZATION_MODEL_TOPOLOGY, EntitiesDomainSchema, EntityIdSchema, EntityLinkKindSchema, EntityLinkSchema, EntitySchema, EventDescriptorSchema, EventEmissionDescriptorSchema, EventIdSchema, FirmographicsSchema, GoalsDomainSchema, HumanRoleHolderSchema, IconNameSchema, IntegrationResourceEntrySchema, KNOWLEDGE_FEATURE_ID, KNOWLEDGE_SYSTEM_ID, KeyResultSchema, KnowledgeDomainSchema, KnowledgeLinkSchema, KnowledgeTargetKindSchema, KnowledgeTargetRefSchema, LEAD_GEN_ACTION_ENTRIES, LEAD_GEN_STAGE_CATALOG, LinkSchema, MONITORING_FEATURE_ID, MONITORING_SYSTEM_ID, McpToolInvocationSchema, NavigationGroupSchema, NodeIdPathSchema, NodeIdStringSchema, OPERATIONS_COMMAND_VIEW_SURFACE_ID, OPERATIONS_FEATURE_ID, OPERATIONS_SYSTEM_ID, ORGANIZATION_MODEL_ICON_TOKENS, ObjectiveSchema, OfferingsDomainSchema, OmTopologyDomainSchema, OmTopologyMetadataSchema, OmTopologyNodeKindSchema, OmTopologyNodeRefSchema, OmTopologyRelationshipKindSchema, OmTopologyRelationshipSchema, OntologyActionTypeSchema, OntologyCatalogTypeSchema, OntologyEventTypeSchema, OntologyGroupSchema, OntologyIdSchema, OntologyInterfaceTypeSchema, OntologyKindSchema, OntologyLinkTypeSchema, OntologyObjectTypeSchema, OntologyScopeSchema, OntologySharedPropertySchema, OntologySurfaceTypeSchema, OntologyValueTypeSchema, OrgKnowledgeKindSchema, OrgKnowledgeNodeSchema, OrganizationModelBuiltinIconTokenSchema, OrganizationModelDomainKeySchema, OrganizationModelDomainMetadataByDomainSchema, OrganizationModelDomainMetadataSchema, OrganizationModelIconTokenSchema, OrganizationModelNavigationSchema, OrganizationModelSchema, PROJECTS_FEATURE_ID, PROJECTS_INDEX_SURFACE_ID, PROJECTS_SYSTEM_ID, PROJECTS_VIEW_ACTION_ID, PROSPECTING_FEATURE_ID, PROSPECTING_LISTS_SURFACE_ID, PROSPECTING_SYSTEM_ID, PoliciesDomainSchema, PolicyApplicabilitySchema, PolicyEffectSchema, PolicyIdSchema, PolicyPredicateSchema, PolicySchema, PolicyTriggerSchema, PricingModelSchema, ProductSchema, ResourceEntrySchema, ResourceGovernanceStatusSchema, ResourceIdSchema, ResourceKindSchema, ResourceOntologyBindingSchema, ResourcesDomainSchema, RoleHolderSchema, RoleHoldersSchema, RoleIdSchema, RoleSchema, RolesDomainSchema, SALES_FEATURE_ID, SALES_PIPELINE_SURFACE_ID, SALES_SYSTEM_ID, SEO_FEATURE_ID, SEO_SYSTEM_ID, SETTINGS_FEATURE_ID, SETTINGS_ROLES_SURFACE_ID, SETTINGS_SYSTEM_ID, ScriptExecutionInvocationSchema, ScriptResourceEntrySchema, ScriptResourceLanguageSchema, ScriptResourceSourceSchema, SidebarNavigationSchema, SidebarNodeSchema, SidebarSectionSchema, SidebarSurfaceTargetsSchema, SlashCommandInvocationSchema, StatusEntrySchema, StatusSemanticClassSchema, StatusesDomainSchema, SurfaceDefinitionSchema, SurfaceTypeSchema, SystemEntrySchema, SystemIdSchema, SystemKindSchema, SystemLifecycleSchema, SystemPathSchema, SystemStatusSchema, SystemUiSchema, SystemsDomainSchema, TeamRoleHolderSchema, TechStackEntrySchema, UiPositionSchema, WorkflowResourceEntrySchema, compileOrganizationOntology, compileTopologyNodeRef, createFoundationOrganizationModel, defineOrganizationModel, defineResource, defineResourceOntology, defineResources, defineTopology, defineTopologyRelationship, findOrganizationActionById, formatOntologyId, getOntologyDiagnostics, getSortedSidebarEntries, isOntologyGraphNodeId, isOntologyTopologyRef, listResolvedOntologyRecords, ontologyGraphNodeId, ontologyIdFromGraphNodeId, parseOntologyId, parseTopologyNodeRef, resolveOrganizationModel, resolveOrganizationModelWithResources, scaffoldOrganizationModel, topologyRef, topologyRelationship };
3375
+ export { ActionIdSchema, ActionInvocationKindSchema, ActionInvocationSchema, ActionRefSchema, ActionSchema, ActionScopeSchema, ActionsDomainSchema, AgentKindSchema, AgentResourceEntrySchema, AgentRoleHolderSchema, ApiEndpointInvocationSchema, CodeReferenceRoleSchema, CodeReferenceSchema, ContractRefSchema, CustomerSegmentSchema, CustomersDomainSchema, DEFAULT_ONTOLOGY_SCOPE, DEFAULT_ORGANIZATION_MODEL, DEFAULT_ORGANIZATION_MODEL_ACTIONS, DEFAULT_ORGANIZATION_MODEL_CUSTOMERS, DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA, DEFAULT_ORGANIZATION_MODEL_ENTITIES, DEFAULT_ORGANIZATION_MODEL_GOALS, DEFAULT_ORGANIZATION_MODEL_NAVIGATION, DEFAULT_ORGANIZATION_MODEL_OFFERINGS, DEFAULT_ORGANIZATION_MODEL_POLICIES, DEFAULT_ORGANIZATION_MODEL_RESOURCES, DEFAULT_ORGANIZATION_MODEL_ROLES, DEFAULT_ORGANIZATION_MODEL_STATUSES, DEFAULT_ORGANIZATION_MODEL_SYSTEMS, DEFAULT_ORGANIZATION_MODEL_TOPOLOGY, EntitiesDomainSchema, EntityIdSchema, EntityLinkKindSchema, EntityLinkSchema, EntitySchema, EventDescriptorSchema, EventEmissionDescriptorSchema, EventIdSchema, FirmographicsSchema, GoalsDomainSchema, HumanRoleHolderSchema, IconNameSchema, IntegrationResourceEntrySchema, KNOWLEDGE_FEATURE_ID, KNOWLEDGE_SYSTEM_ID, KeyResultSchema, KnowledgeDomainSchema, KnowledgeLinkSchema, KnowledgeTargetKindSchema, KnowledgeTargetRefSchema, LinkSchema, MONITORING_FEATURE_ID, MONITORING_SYSTEM_ID, McpToolInvocationSchema, NavigationGroupSchema, NodeIdPathSchema, NodeIdStringSchema, OPERATIONS_COMMAND_VIEW_SURFACE_ID, OPERATIONS_FEATURE_ID, OPERATIONS_SYSTEM_ID, ORGANIZATION_MODEL_ICON_TOKENS, ObjectiveSchema, OfferingsDomainSchema, OmTopologyDomainSchema, OmTopologyMetadataSchema, OmTopologyNodeKindSchema, OmTopologyNodeRefSchema, OmTopologyRelationshipKindSchema, OmTopologyRelationshipSchema, OntologyActionTypeSchema, OntologyCatalogTypeSchema, OntologyEventTypeSchema, OntologyGroupSchema, OntologyIdSchema, OntologyInterfaceTypeSchema, OntologyKindSchema, OntologyLinkTypeSchema, OntologyObjectTypeSchema, OntologyScopeSchema, OntologySharedPropertySchema, OntologySurfaceTypeSchema, OntologyValueTypeSchema, OrgKnowledgeKindSchema, OrgKnowledgeNodeSchema, OrganizationModelBuiltinIconTokenSchema, OrganizationModelDomainKeySchema, OrganizationModelDomainMetadataByDomainSchema, OrganizationModelDomainMetadataSchema, OrganizationModelIconTokenSchema, OrganizationModelNavigationSchema, OrganizationModelSchema, PROJECTS_FEATURE_ID, PROJECTS_INDEX_SURFACE_ID, PROJECTS_SYSTEM_ID, PROJECTS_VIEW_ACTION_ID, PROSPECTING_FEATURE_ID, PROSPECTING_LISTS_SURFACE_ID, PROSPECTING_SYSTEM_ID, PoliciesDomainSchema, PolicyApplicabilitySchema, PolicyEffectSchema, PolicyIdSchema, PolicyPredicateSchema, PolicySchema, PolicyTriggerSchema, PricingModelSchema, ProductSchema, ResourceEntrySchema, ResourceGovernanceStatusSchema, ResourceIdSchema, ResourceKindSchema, ResourceOntologyBindingSchema, ResourcesDomainSchema, RoleHolderSchema, RoleHoldersSchema, RoleIdSchema, RoleSchema, RolesDomainSchema, SALES_FEATURE_ID, SALES_PIPELINE_SURFACE_ID, SALES_SYSTEM_ID, SEO_FEATURE_ID, SEO_SYSTEM_ID, SETTINGS_FEATURE_ID, SETTINGS_ROLES_SURFACE_ID, SETTINGS_SYSTEM_ID, ScriptExecutionInvocationSchema, ScriptResourceEntrySchema, ScriptResourceLanguageSchema, ScriptResourceSourceSchema, SidebarNavigationSchema, SidebarNodeSchema, SidebarSectionSchema, SidebarSurfaceTargetsSchema, SlashCommandInvocationSchema, StatusEntrySchema, StatusSemanticClassSchema, StatusesDomainSchema, SurfaceDefinitionSchema, SurfaceTypeSchema, SystemEntrySchema, SystemIdSchema, SystemKindSchema, SystemLifecycleSchema, SystemPathSchema, SystemStatusSchema, SystemUiSchema, SystemsDomainSchema, TeamRoleHolderSchema, TechStackEntrySchema, UiPositionSchema, WorkflowResourceEntrySchema, compileOrganizationOntology, compileTopologyNodeRef, createFoundationOrganizationModel, defineOrganizationModel, defineResource, defineResourceOntology, defineResources, defineTopology, defineTopologyRelationship, findOrganizationActionById, formatOntologyId, getOntologyDiagnostics, getSortedSidebarEntries, isOntologyGraphNodeId, isOntologyTopologyRef, listAllSystems, listResolvedOntologyRecords, ontologyGraphNodeId, ontologyIdFromGraphNodeId, parseContractRef, parseOntologyId, parseTopologyNodeRef, projectOrganizationSurfaces, resolveOrganizationModel, resolveOrganizationModelWithResources, scaffoldOrganizationModel, topologyRef, topologyRelationship, validateOrganizationSurfaceProjection };