@elevasis/core 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/index.d.ts +166 -85
  2. package/dist/index.js +146 -1346
  3. package/dist/knowledge/index.d.ts +27 -38
  4. package/dist/knowledge/index.js +1 -1
  5. package/dist/organization-model/index.d.ts +166 -85
  6. package/dist/organization-model/index.js +146 -1346
  7. package/dist/test-utils/index.d.ts +23 -31
  8. package/dist/test-utils/index.js +75 -1238
  9. package/package.json +1 -1
  10. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +14 -2
  11. package/src/business/acquisition/api-schemas.test.ts +70 -77
  12. package/src/business/acquisition/api-schemas.ts +21 -42
  13. package/src/business/acquisition/derive-actions.test.ts +11 -21
  14. package/src/business/acquisition/derive-actions.ts +61 -14
  15. package/src/business/acquisition/ontology-validation.ts +4 -4
  16. package/src/business/acquisition/types.ts +7 -8
  17. package/src/knowledge/queries.ts +0 -1
  18. package/src/organization-model/__tests__/content-kinds-registry.test.ts +35 -210
  19. package/src/organization-model/__tests__/defaults.test.ts +4 -4
  20. package/src/organization-model/__tests__/domains/actions.test.ts +12 -36
  21. package/src/organization-model/__tests__/domains/offerings.test.ts +13 -6
  22. package/src/organization-model/__tests__/domains/resources.test.ts +497 -350
  23. package/src/organization-model/__tests__/domains/systems.test.ts +6 -7
  24. package/src/organization-model/__tests__/flatten-additive-merge.test.ts +68 -80
  25. package/src/organization-model/__tests__/foundation.test.ts +81 -14
  26. package/src/organization-model/__tests__/graph.test.ts +662 -694
  27. package/src/organization-model/__tests__/knowledge.test.ts +31 -17
  28. package/src/organization-model/__tests__/lookup-helpers.test.ts +128 -438
  29. package/src/organization-model/__tests__/migration-helpers.test.ts +362 -591
  30. package/src/organization-model/__tests__/prospecting-ssot.test.ts +68 -103
  31. package/src/organization-model/__tests__/published-zero-leak.test.ts +17 -0
  32. package/src/organization-model/__tests__/recursive-system-schema.test.ts +159 -532
  33. package/src/organization-model/__tests__/resolve.test.ts +79 -42
  34. package/src/organization-model/__tests__/schema.test.ts +65 -56
  35. package/src/organization-model/catalogs/lead-gen.ts +0 -103
  36. package/src/organization-model/defaults.ts +17 -702
  37. package/src/organization-model/domains/actions.ts +116 -333
  38. package/src/organization-model/domains/knowledge.ts +15 -7
  39. package/src/organization-model/domains/projects.ts +4 -4
  40. package/src/organization-model/domains/prospecting.ts +405 -395
  41. package/src/organization-model/domains/resources.ts +206 -135
  42. package/src/organization-model/domains/sales.ts +5 -5
  43. package/src/organization-model/domains/systems.ts +8 -23
  44. package/src/organization-model/graph/build.ts +223 -294
  45. package/src/organization-model/graph/schema.ts +2 -3
  46. package/src/organization-model/graph/types.ts +12 -14
  47. package/src/organization-model/helpers.ts +130 -218
  48. package/src/organization-model/index.ts +104 -124
  49. package/src/organization-model/migration-helpers.ts +211 -249
  50. package/src/organization-model/ontology.ts +0 -60
  51. package/src/organization-model/organization-graph.mdx +4 -5
  52. package/src/organization-model/organization-model.mdx +1 -1
  53. package/src/organization-model/published.ts +236 -226
  54. package/src/organization-model/resolve.ts +4 -5
  55. package/src/organization-model/schema.ts +610 -704
  56. package/src/organization-model/types.ts +167 -161
  57. package/src/platform/registry/__tests__/validation.test.ts +23 -0
  58. package/src/platform/registry/validation.ts +13 -2
  59. package/src/reference/_generated/contracts.md +14 -2
  60. package/src/organization-model/content-kinds/config.ts +0 -36
  61. package/src/organization-model/content-kinds/index.ts +0 -78
  62. package/src/organization-model/content-kinds/pipeline.ts +0 -68
  63. package/src/organization-model/content-kinds/registry.ts +0 -44
  64. package/src/organization-model/content-kinds/status.ts +0 -71
  65. package/src/organization-model/content-kinds/template.ts +0 -83
  66. package/src/organization-model/content-kinds/types.ts +0 -117
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",
@@ -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
@@ -2159,7 +1752,10 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2159
1752
  const childSystems = system.systems ?? system.subsystems;
2160
1753
  if (childSystems !== void 0) {
2161
1754
  result.push(
2162
- ...collectAllSystems(childSystems, path, [...currentSchemaPath, system.systems !== void 0 ? "systems" : "subsystems"])
1755
+ ...collectAllSystems(childSystems, path, [
1756
+ ...currentSchemaPath,
1757
+ system.systems !== void 0 ? "systems" : "subsystems"
1758
+ ])
2163
1759
  );
2164
1760
  }
2165
1761
  }
@@ -2180,7 +1776,9 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2180
1776
  `System "${system.id}" references unknown parent "${system.parentSystemId}"`
2181
1777
  );
2182
1778
  }
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("."));
1779
+ const hasChildren = Object.keys(system.systems ?? system.subsystems ?? {}).length > 0 || allSystems.some(
1780
+ (candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes(".")
1781
+ );
2184
1782
  const contributesRoutePath = system.ui?.path !== void 0 || system.path !== void 0 || !hasChildren;
2185
1783
  if (contributesRoutePath) {
2186
1784
  const effectivePath = system.ui?.path ?? system.path ?? defaultSystemPathFor(path);
@@ -2202,11 +1800,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2202
1800
  (candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes(".") && isLifecycleEnabled(candidate.system.lifecycle, candidate.system.enabled)
2203
1801
  );
2204
1802
  if (!hasEnabledDescendant) {
2205
- addIssue(
2206
- ctx,
2207
- [...schemaPath, "lifecycle"],
2208
- `System "${path}" is active but has no active descendants`
2209
- );
1803
+ addIssue(ctx, [...schemaPath, "lifecycle"], `System "${path}" is active but has no active descendants`);
2210
1804
  }
2211
1805
  }
2212
1806
  });
@@ -2438,10 +2032,16 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2438
2032
  }
2439
2033
  });
2440
2034
  });
2441
- const stageIds = /* @__PURE__ */ new Set();
2442
2035
  const actionIds = new Set(Object.keys(model.actions));
2443
2036
  const offeringsById = new Map(Object.entries(model.offerings));
2444
2037
  const ontologyCompilation = compileOrganizationOntology(model);
2038
+ const stageIds = /* @__PURE__ */ new Set();
2039
+ for (const catalog of Object.values(ontologyCompilation.ontology.catalogTypes)) {
2040
+ if (catalog.kind !== "stage") continue;
2041
+ for (const stageId of Object.keys(catalog.entries ?? {})) {
2042
+ stageIds.add(stageId);
2043
+ }
2044
+ }
2445
2045
  const ontologyIndexByKind = {
2446
2046
  object: ontologyCompilation.ontology.objectTypes,
2447
2047
  link: ontologyCompilation.ontology.linkTypes,
@@ -2617,13 +2217,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2617
2217
  if (ontologyIndexByKind[expectedKind][ontologyId] === void 0) {
2618
2218
  addIssue(
2619
2219
  ctx,
2620
- [
2621
- "resources",
2622
- resourceId,
2623
- "ontology",
2624
- bindingKey,
2625
- ...Array.isArray(ids) ? [ontologyIndex] : []
2626
- ],
2220
+ ["resources", resourceId, "ontology", bindingKey, ...Array.isArray(ids) ? [ontologyIndex] : []],
2627
2221
  `Resource "${resourceId}" ontology binding "${bindingKey}" references unknown ${expectedKind} ontology ID "${ontologyId}"`
2628
2222
  );
2629
2223
  }
@@ -2638,6 +2232,23 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2638
2232
  validateResourceOntologyBinding(resource.id, "writes", "object", binding.writes);
2639
2233
  validateResourceOntologyBinding(resource.id, "usesCatalogs", "catalog", binding.usesCatalogs);
2640
2234
  validateResourceOntologyBinding(resource.id, "emits", "event", binding.emits);
2235
+ if (binding.contract !== void 0) {
2236
+ const contractEntries = [
2237
+ ["input", binding.contract.input],
2238
+ ["output", binding.contract.output]
2239
+ ];
2240
+ for (const [side, ref] of contractEntries) {
2241
+ if (ref === void 0) continue;
2242
+ const result = ContractRefSchema.safeParse(ref);
2243
+ if (!result.success) {
2244
+ addIssue(
2245
+ ctx,
2246
+ ["resources", resource.id, "ontology", "contract", side],
2247
+ `Resource "${resource.id}" contract.${side} "${ref}" is not a valid ContractRef (expected "package/subpath#ExportName")`
2248
+ );
2249
+ }
2250
+ }
2251
+ }
2641
2252
  });
2642
2253
  Object.values(model.roles).forEach((role) => {
2643
2254
  if (role.heldBy === void 0) return;
@@ -2672,78 +2283,6 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2672
2283
  }
2673
2284
  });
2674
2285
  });
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
2286
  for (const diagnostic of ontologyCompilation.diagnostics) {
2748
2287
  addIssue(ctx, diagnostic.path, diagnostic.message);
2749
2288
  }
@@ -2764,9 +2303,8 @@ var OrganizationGraphNodeKindSchema = z.enum([
2764
2303
  "goal",
2765
2304
  "surface",
2766
2305
  "navigation-group",
2767
- // Phase 3 preview Phase 4 populates via graph projection of system.content entries.
2768
- "ontology",
2769
- "content-node"
2306
+ // Ontology records are projected from compiled System.ontology scopes.
2307
+ "ontology"
2770
2308
  ]);
2771
2309
  var OrganizationGraphEdgeKindSchema = z.enum([
2772
2310
  "contains",
@@ -2849,311 +2387,11 @@ var SETTINGS_ROLES_SURFACE_ID = "settings.roles";
2849
2387
 
2850
2388
  // src/organization-model/defaults.ts
2851
2389
  var DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE = {};
2852
- var DEFAULT_ORGANIZATION_MODEL_ENTITIES2 = DEFAULT_ORGANIZATION_MODEL_ENTITIES;
2390
+ var DEFAULT_ORGANIZATION_MODEL_ENTITIES2 = {};
2853
2391
  var DEFAULT_ORGANIZATION_MODEL_NAVIGATION2 = {
2854
2392
  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
- }
2393
+ primary: {},
2394
+ bottom: {}
3157
2395
  }
3158
2396
  };
3159
2397
  var DEFAULT_ORGANIZATION_MODEL = {
@@ -3166,406 +2404,19 @@ var DEFAULT_ORGANIZATION_MODEL = {
3166
2404
  offerings: DEFAULT_ORGANIZATION_MODEL_OFFERINGS,
3167
2405
  roles: DEFAULT_ORGANIZATION_MODEL_ROLES,
3168
2406
  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
- },
2407
+ // Generic empty systems map. Elevasis-specific systems (platform, sales, sales.crm,
2408
+ // sales.lead-gen, monitoring, settings, admin, etc.) have been relocated to
2409
+ // `@repo/elevasis-core/src/organization-model/systems.ts` via `canonicalOrganizationModel`.
2410
+ // Tenant OM configs supply their own systems via `resolveOrganizationModel`.
2411
+ systems: {},
3561
2412
  ontology: DEFAULT_ONTOLOGY_SCOPE,
3562
2413
  resources: DEFAULT_ORGANIZATION_MODEL_RESOURCES,
3563
2414
  topology: DEFAULT_ORGANIZATION_MODEL_TOPOLOGY,
3564
- actions: DEFAULT_ORGANIZATION_MODEL_ACTIONS,
2415
+ // Generic empty actions map. Elevasis-specific action entries have been relocated to
2416
+ // `@repo/elevasis-core/src/organization-model/actions.ts`.
2417
+ actions: {},
3565
2418
  entities: DEFAULT_ORGANIZATION_MODEL_ENTITIES2,
3566
2419
  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
2420
  knowledge: DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE
3570
2421
  };
3571
2422
  var StatusSemanticClassSchema = z.enum([
@@ -3870,101 +2721,6 @@ var DEFAULT_ORGANIZATION_MODEL_STATUSES = {
3870
2721
  }
3871
2722
  };
3872
2723
 
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
2724
  // src/organization-model/helpers.ts
3969
2725
  function childSystemsOf2(system) {
3970
2726
  return system.systems ?? system.subsystems ?? {};
@@ -4009,15 +2765,7 @@ function mergeJsonConfig(base, override) {
4009
2765
  function resolveSystemConfig(model, path) {
4010
2766
  const system = getSystem(model, path);
4011
2767
  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 ?? {});
2768
+ return mergeJsonConfig({}, system.config ?? {});
4021
2769
  }
4022
2770
 
4023
2771
  // src/organization-model/resolve.ts
@@ -4101,6 +2849,9 @@ function resolveOrganizationModelWithResources(override, organizationId) {
4101
2849
  }
4102
2850
 
4103
2851
  // src/organization-model/surface-projection.ts
2852
+ function normalizePath(path) {
2853
+ return path.length > 1 ? path.replace(/\/+$/, "") : path;
2854
+ }
4104
2855
  function collectSystemsById(model) {
4105
2856
  const systemsById = /* @__PURE__ */ new Map();
4106
2857
  for (const { path, system } of listAllSystems(model)) {
@@ -4180,6 +2931,55 @@ function projectOrganizationSurfaces(model) {
4180
2931
  };
4181
2932
  });
4182
2933
  }
2934
+ function validateOrganizationSurfaceProjection(model) {
2935
+ const issues = [];
2936
+ const systemsById = collectSystemsById(model);
2937
+ const surfaceIds = /* @__PURE__ */ new Set();
2938
+ const surfacePaths = /* @__PURE__ */ new Map();
2939
+ function addIssue2(issue) {
2940
+ issues.push(issue);
2941
+ }
2942
+ getSidebarSurfaces(model).forEach(({ id, surface, path }) => {
2943
+ if (surfaceIds.has(id)) {
2944
+ addIssue2({
2945
+ code: "duplicate-surface-id",
2946
+ message: `Surface id "${id}" must be unique`,
2947
+ path,
2948
+ surfaceId: id,
2949
+ value: id
2950
+ });
2951
+ } else {
2952
+ surfaceIds.add(id);
2953
+ }
2954
+ const normalizedPath = normalizePath(surface.path);
2955
+ const existingSurfaceId = surfacePaths.get(normalizedPath);
2956
+ if (existingSurfaceId !== void 0) {
2957
+ addIssue2({
2958
+ code: "duplicate-surface-path",
2959
+ message: `Surface path "${surface.path}" is already used by surface "${existingSurfaceId}"`,
2960
+ path: [...path, "path"],
2961
+ surfaceId: id,
2962
+ value: surface.path
2963
+ });
2964
+ } else {
2965
+ surfacePaths.set(normalizedPath, id);
2966
+ }
2967
+ surface.targets?.systems?.forEach((systemId, systemIndex) => {
2968
+ if (systemsById.has(systemId)) {
2969
+ return;
2970
+ }
2971
+ addIssue2({
2972
+ code: "unknown-surface-system",
2973
+ message: `Surface "${id}" references unknown system "${systemId}"`,
2974
+ path: [...path, "targets", "systems", systemIndex],
2975
+ surfaceId: id,
2976
+ systemId,
2977
+ value: systemId
2978
+ });
2979
+ });
2980
+ });
2981
+ return issues;
2982
+ }
4183
2983
 
4184
2984
  // src/organization-model/foundation.ts
4185
2985
  function createFoundationOrganizationModel(override) {
@@ -4536,4 +3336,4 @@ function scaffoldOrganizationModel(model, spec) {
4536
3336
  return scaffoldKnowledgeNode(model, spec);
4537
3337
  }
4538
3338
 
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 };
3339
+ 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 };