@radicaltools/mcp 0.2.0 → 0.3.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 (159) hide show
  1. package/README.md +41 -23
  2. package/dist/{chunk-OGN3UW2D.js → chunk-Z7THA3L5.js} +670 -64
  3. package/dist/{elkLayout-S62RLGTO.js → elkLayout-TAUBPPVN.js} +1 -1
  4. package/dist/hub-catalogue/concern/concern-api-evolution.radical +935 -0
  5. package/dist/hub-catalogue/concern/concern-architecture-style.radical +1112 -0
  6. package/dist/hub-catalogue/concern/concern-authentication.radical +685 -0
  7. package/dist/hub-catalogue/concern/concern-authorization.radical +1464 -0
  8. package/dist/hub-catalogue/concern/concern-availability.radical +804 -0
  9. package/dist/hub-catalogue/concern/concern-backend-stack.radical +1118 -0
  10. package/dist/hub-catalogue/concern/concern-backup-recovery.radical +1304 -0
  11. package/dist/hub-catalogue/concern/concern-capacity.radical +802 -0
  12. package/dist/hub-catalogue/concern/concern-communication-style.radical +1202 -0
  13. package/dist/hub-catalogue/concern/concern-data-consistency.radical +1081 -0
  14. package/dist/hub-catalogue/concern/concern-data-store.radical +960 -0
  15. package/dist/hub-catalogue/concern/concern-decomposition.radical +1143 -0
  16. package/dist/hub-catalogue/concern/concern-deployment.radical +952 -0
  17. package/dist/hub-catalogue/concern/concern-encryption.radical +1055 -0
  18. package/dist/hub-catalogue/concern/concern-frontend-stack.radical +1340 -0
  19. package/dist/hub-catalogue/concern/concern-infrastructure.radical +1151 -0
  20. package/dist/hub-catalogue/concern/concern-integration-resilience.radical +1079 -0
  21. package/dist/hub-catalogue/concern/concern-messaging.radical +940 -0
  22. package/dist/hub-catalogue/concern/concern-module-boundaries.radical +864 -0
  23. package/dist/hub-catalogue/concern/concern-observability.radical +1048 -0
  24. package/dist/hub-catalogue/concern/concern-personal-data.radical +1434 -0
  25. package/dist/hub-catalogue/concern/concern-rate-limiting.radical +1153 -0
  26. package/dist/hub-catalogue/concern/concern-secrets.radical +1026 -0
  27. package/dist/hub-catalogue/concern/concern-supply-chain.radical +1312 -0
  28. package/dist/hub-catalogue/concern/concern-tenant-isolation.radical +1306 -0
  29. package/dist/hub-catalogue/concern/concern-test-strategy.radical +1193 -0
  30. package/dist/index.js +9440 -3854
  31. package/package.json +1 -1
  32. package/dist/hub-catalogue/adr/adr-api-versioning.radical +0 -53
  33. package/dist/hub-catalogue/adr/adr-auth-strategy.radical +0 -53
  34. package/dist/hub-catalogue/adr/adr-caching-strategy.radical +0 -59
  35. package/dist/hub-catalogue/adr/adr-data-consistency-model.radical +0 -40
  36. package/dist/hub-catalogue/adr/adr-data-store.radical +0 -47
  37. package/dist/hub-catalogue/adr/adr-deployment-strategy.radical +0 -53
  38. package/dist/hub-catalogue/adr/adr-event-schema-evolution.radical +0 -53
  39. package/dist/hub-catalogue/adr/adr-integration-style.radical +0 -50
  40. package/dist/hub-catalogue/adr/adr-ledger-reconciliation-strategy.radical +0 -38
  41. package/dist/hub-catalogue/adr/adr-llm-provider-strategy.radical +0 -40
  42. package/dist/hub-catalogue/adr/adr-marketplace-payments-model.radical +0 -39
  43. package/dist/hub-catalogue/adr/adr-multi-region.radical +0 -60
  44. package/dist/hub-catalogue/adr/adr-multi-tenancy-strategy.radical +0 -41
  45. package/dist/hub-catalogue/adr/adr-observability.radical +0 -59
  46. package/dist/hub-catalogue/adr/adr-realtime-transport.radical +0 -38
  47. package/dist/hub-catalogue/adr/adr-tech-stack.radical +0 -45
  48. package/dist/hub-catalogue/adr/adr-zero-trust-network.radical +0 -40
  49. package/dist/hub-catalogue/blueprint/bp-ai-assistant-platform.radical +0 -1641
  50. package/dist/hub-catalogue/blueprint/bp-analytical-data-platform.radical +0 -1428
  51. package/dist/hub-catalogue/blueprint/bp-ecommerce-platform.radical +0 -1989
  52. package/dist/hub-catalogue/blueprint/bp-fintech-ledger-platform.radical +0 -1701
  53. package/dist/hub-catalogue/blueprint/bp-marketplace-platform.radical +0 -1792
  54. package/dist/hub-catalogue/blueprint/bp-realtime-collaboration.radical +0 -1421
  55. package/dist/hub-catalogue/blueprint/bp-saas-b2b-platform.radical +0 -1713
  56. package/dist/hub-catalogue/fitness-function/ff-accessibility-scan.radical +0 -34
  57. package/dist/hub-catalogue/fitness-function/ff-ai-eval-gate.radical +0 -52
  58. package/dist/hub-catalogue/fitness-function/ff-api-contract.radical +0 -36
  59. package/dist/hub-catalogue/fitness-function/ff-capacity-load-test.radical +0 -67
  60. package/dist/hub-catalogue/fitness-function/ff-carbon-footprint-guard.radical +0 -62
  61. package/dist/hub-catalogue/fitness-function/ff-change-failure-rate.radical +0 -45
  62. package/dist/hub-catalogue/fitness-function/ff-chaos-resilience-test.radical +0 -53
  63. package/dist/hub-catalogue/fitness-function/ff-cost-efficiency-guard.radical +0 -64
  64. package/dist/hub-catalogue/fitness-function/ff-coupling-guard.radical +0 -45
  65. package/dist/hub-catalogue/fitness-function/ff-data-integrity-check.radical +0 -51
  66. package/dist/hub-catalogue/fitness-function/ff-data-residency.radical +0 -43
  67. package/dist/hub-catalogue/fitness-function/ff-dependency-rules.radical +0 -37
  68. package/dist/hub-catalogue/fitness-function/ff-deploy-frequency.radical +0 -46
  69. package/dist/hub-catalogue/fitness-function/ff-dr-drill-success.radical +0 -52
  70. package/dist/hub-catalogue/fitness-function/ff-duplication-guard.radical +0 -53
  71. package/dist/hub-catalogue/fitness-function/ff-error-budget.radical +0 -59
  72. package/dist/hub-catalogue/fitness-function/ff-fail-safe-verification.radical +0 -34
  73. package/dist/hub-catalogue/fitness-function/ff-infra-drift.radical +0 -34
  74. package/dist/hub-catalogue/fitness-function/ff-latency-slo.radical +0 -59
  75. package/dist/hub-catalogue/fitness-function/ff-lead-time.radical +0 -44
  76. package/dist/hub-catalogue/fitness-function/ff-ledger-balance-integrity.radical +0 -45
  77. package/dist/hub-catalogue/fitness-function/ff-license-compliance.radical +0 -43
  78. package/dist/hub-catalogue/fitness-function/ff-mttr.radical +0 -45
  79. package/dist/hub-catalogue/fitness-function/ff-noisy-neighbor-guard.radical +0 -66
  80. package/dist/hub-catalogue/fitness-function/ff-sast-scan.radical +0 -35
  81. package/dist/hub-catalogue/fitness-function/ff-scale-out-verification.radical +0 -66
  82. package/dist/hub-catalogue/fitness-function/ff-security-scan.radical +0 -45
  83. package/dist/hub-catalogue/fitness-function/ff-startup-shutdown-check.radical +0 -66
  84. package/dist/hub-catalogue/fitness-function/ff-sync-convergence-test.radical +0 -45
  85. package/dist/hub-catalogue/fitness-function/ff-test-coverage.radical +0 -43
  86. package/dist/hub-catalogue/fitness-function/ff-web-vitals.radical +0 -57
  87. package/dist/hub-catalogue/pattern/pattern-anti-corruption-layer.radical +0 -88
  88. package/dist/hub-catalogue/pattern/pattern-api-gateway.radical +0 -168
  89. package/dist/hub-catalogue/pattern/pattern-bff.radical +0 -179
  90. package/dist/hub-catalogue/pattern/pattern-bulkhead.radical +0 -114
  91. package/dist/hub-catalogue/pattern/pattern-circuit-breaker.radical +0 -219
  92. package/dist/hub-catalogue/pattern/pattern-cqrs.radical +0 -195
  93. package/dist/hub-catalogue/pattern/pattern-crdt-sync.radical +0 -200
  94. package/dist/hub-catalogue/pattern/pattern-event-driven.radical +0 -210
  95. package/dist/hub-catalogue/pattern/pattern-event-sourced-ledger.radical +0 -211
  96. package/dist/hub-catalogue/pattern/pattern-hexagonal.radical +0 -196
  97. package/dist/hub-catalogue/pattern/pattern-microservices.radical +0 -262
  98. package/dist/hub-catalogue/pattern/pattern-rag-pipeline.radical +0 -213
  99. package/dist/hub-catalogue/pattern/pattern-rate-limiter.radical +0 -114
  100. package/dist/hub-catalogue/pattern/pattern-saga.radical +0 -208
  101. package/dist/hub-catalogue/pattern/pattern-sidecar.radical +0 -123
  102. package/dist/hub-catalogue/pattern/pattern-strangler-fig.radical +0 -227
  103. package/dist/hub-catalogue/pattern/pattern-transactional-outbox.radical +0 -209
  104. package/dist/hub-catalogue/requirement/req-accessibility.radical +0 -48
  105. package/dist/hub-catalogue/requirement/req-ai-autonomous-resolution.radical +0 -51
  106. package/dist/hub-catalogue/requirement/req-ai-groundedness.radical +0 -45
  107. package/dist/hub-catalogue/requirement/req-ai-human-handoff.radical +0 -46
  108. package/dist/hub-catalogue/requirement/req-alerting.radical +0 -52
  109. package/dist/hub-catalogue/requirement/req-api-response-time.radical +0 -51
  110. package/dist/hub-catalogue/requirement/req-api-standard.radical +0 -45
  111. package/dist/hub-catalogue/requirement/req-audit-logging.radical +0 -43
  112. package/dist/hub-catalogue/requirement/req-auth-response-time.radical +0 -45
  113. package/dist/hub-catalogue/requirement/req-auth.radical +0 -43
  114. package/dist/hub-catalogue/requirement/req-autoscaling.radical +0 -62
  115. package/dist/hub-catalogue/requirement/req-availability.radical +0 -50
  116. package/dist/hub-catalogue/requirement/req-backward-compatibility.radical +0 -46
  117. package/dist/hub-catalogue/requirement/req-batch-job-completion.radical +0 -50
  118. package/dist/hub-catalogue/requirement/req-carbon-efficiency.radical +0 -64
  119. package/dist/hub-catalogue/requirement/req-centralised-logging.radical +0 -45
  120. package/dist/hub-catalogue/requirement/req-ci-pipeline-time.radical +0 -43
  121. package/dist/hub-catalogue/requirement/req-code-complexity.radical +0 -43
  122. package/dist/hub-catalogue/requirement/req-config-propagation.radical +0 -45
  123. package/dist/hub-catalogue/requirement/req-data-integrity.radical +0 -35
  124. package/dist/hub-catalogue/requirement/req-data-retention.radical +0 -44
  125. package/dist/hub-catalogue/requirement/req-db-query-response.radical +0 -44
  126. package/dist/hub-catalogue/requirement/req-disaster-recovery.radical +0 -59
  127. package/dist/hub-catalogue/requirement/req-distributed-tracing.radical +0 -45
  128. package/dist/hub-catalogue/requirement/req-encryption.radical +0 -49
  129. package/dist/hub-catalogue/requirement/req-error-rate.radical +0 -45
  130. package/dist/hub-catalogue/requirement/req-error-recovery.radical +0 -34
  131. package/dist/hub-catalogue/requirement/req-event-schema-compatibility.radical +0 -37
  132. package/dist/hub-catalogue/requirement/req-fail-safe-default.radical +0 -55
  133. package/dist/hub-catalogue/requirement/req-fast-startup-graceful-shutdown.radical +0 -69
  134. package/dist/hub-catalogue/requirement/req-gdpr-erasure.radical +0 -44
  135. package/dist/hub-catalogue/requirement/req-graceful-degradation.radical +0 -39
  136. package/dist/hub-catalogue/requirement/req-health-checks.radical +0 -43
  137. package/dist/hub-catalogue/requirement/req-iac.radical +0 -36
  138. package/dist/hub-catalogue/requirement/req-idempotency.radical +0 -47
  139. package/dist/hub-catalogue/requirement/req-input-validation.radical +0 -37
  140. package/dist/hub-catalogue/requirement/req-least-privilege.radical +0 -47
  141. package/dist/hub-catalogue/requirement/req-ledger-immutability.radical +0 -38
  142. package/dist/hub-catalogue/requirement/req-mfa.radical +0 -36
  143. package/dist/hub-catalogue/requirement/req-ml-extraction-accuracy.radical +0 -42
  144. package/dist/hub-catalogue/requirement/req-onboarding-time.radical +0 -42
  145. package/dist/hub-catalogue/requirement/req-page-load-time.radical +0 -59
  146. package/dist/hub-catalogue/requirement/req-payout-latency.radical +0 -46
  147. package/dist/hub-catalogue/requirement/req-presence-latency.radical +0 -46
  148. package/dist/hub-catalogue/requirement/req-rate-limiting.radical +0 -45
  149. package/dist/hub-catalogue/requirement/req-report-generation.radical +0 -44
  150. package/dist/hub-catalogue/requirement/req-resource-efficiency.radical +0 -64
  151. package/dist/hub-catalogue/requirement/req-resource-headroom.radical +0 -53
  152. package/dist/hub-catalogue/requirement/req-resource-isolation.radical +0 -37
  153. package/dist/hub-catalogue/requirement/req-search-response-time.radical +0 -44
  154. package/dist/hub-catalogue/requirement/req-secrets-management.radical +0 -45
  155. package/dist/hub-catalogue/requirement/req-task-success-rate.radical +0 -42
  156. package/dist/hub-catalogue/requirement/req-test-coverage.radical +0 -42
  157. package/dist/hub-catalogue/requirement/req-throughput.radical +0 -55
  158. package/dist/hub-catalogue/requirement/req-vulnerability-scanning.radical +0 -52
  159. package/dist/hub-catalogue/requirement/req-zero-downtime-deploy.radical +0 -39
@@ -4,6 +4,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
7
10
  var __commonJS = (cb, mod) => function __require() {
8
11
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
12
  };
@@ -24,10 +27,29 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
27
  mod
25
28
  ));
26
29
 
30
+ // <define:__RADICAL_BUILD__>
31
+ var define_RADICAL_BUILD_default;
32
+ var init_define_RADICAL_BUILD = __esm({
33
+ "<define:__RADICAL_BUILD__>"() {
34
+ define_RADICAL_BUILD_default = { version: "0.3.0", commit: "f76cbf9", date: "2026-10-27", release: true };
35
+ }
36
+ });
37
+
27
38
  // ../../packages/layout/src/elkLayout.ts
39
+ init_define_RADICAL_BUILD();
28
40
  import ELK from "elkjs/lib/elk.bundled.js";
29
41
 
42
+ // ../../packages/common/src/c4.ts
43
+ init_define_RADICAL_BUILD();
44
+
45
+ // ../../packages/common/src/metamodel/index.ts
46
+ init_define_RADICAL_BUILD();
47
+
48
+ // ../../packages/common/src/metamodel/types.ts
49
+ init_define_RADICAL_BUILD();
50
+
30
51
  // ../../packages/common/src/metamodel/lookup.ts
52
+ init_define_RADICAL_BUILD();
31
53
  function isRelationAllowed(metamodel, fromType, toType) {
32
54
  if (!metamodel) return true;
33
55
  const rts = Object.values(metamodel.relationTypes);
@@ -35,11 +57,14 @@ function isRelationAllowed(metamodel, fromType, toType) {
35
57
  if (rts.some((rt) => rt.allowedPairs.length === 0)) return true;
36
58
  return rts.some((rt) => rt.allowedPairs.some((p) => p.from === fromType && p.to === toType));
37
59
  }
38
- function inferRelationType(metamodel, fromType, toType) {
39
- if (!metamodel) return void 0;
40
- const matches = Object.values(metamodel.relationTypes).filter(
41
- (rt) => rt.allowedPairs.length > 0 && rt.allowedPairs.some((p) => p.from === fromType && p.to === toType)
60
+ function relationTypesFitting(metamodel, fromType, toType) {
61
+ if (!metamodel) return [];
62
+ return Object.values(metamodel.relationTypes).filter(
63
+ (rt) => rt.allowedPairs.length === 0 || rt.allowedPairs.some((p) => p.from === fromType && p.to === toType)
42
64
  );
65
+ }
66
+ function inferRelationType(metamodel, fromType, toType) {
67
+ const matches = relationTypesFitting(metamodel, fromType, toType);
43
68
  return matches.length === 1 ? matches[0].id : void 0;
44
69
  }
45
70
  function isParentAllowed(metamodel, childType, parentType) {
@@ -53,6 +78,20 @@ function isParentAllowed(metamodel, childType, parentType) {
53
78
  }
54
79
  return !!allowed && allowed.includes(parentType);
55
80
  }
81
+ function hasAnyPlace(metamodel, type) {
82
+ const def = metamodel?.nodeTypes[type];
83
+ if (!def) return true;
84
+ return (def.allowedParents?.length ?? 0) > 0 || isParentAllowed(metamodel, type, void 0);
85
+ }
86
+ function allowedPlacesText(metamodel, type) {
87
+ const label = (t) => metamodel?.nodeTypes[t]?.label ?? t;
88
+ const places = (metamodel?.nodeTypes[type]?.allowedParents ?? []).map(label);
89
+ if (isParentAllowed(metamodel, type, void 0)) places.push("the canvas root");
90
+ return places.length ? places.join(", ") : `none (${noPlaceText(metamodel, type)})`;
91
+ }
92
+ function noPlaceText(metamodel, type) {
93
+ return `${metamodel?.nodeTypes[type]?.label ?? type} has no place in the metamodel`;
94
+ }
56
95
  var GROUP_TYPE = "group";
57
96
  function placeOf(node, nodes) {
58
97
  const seen = /* @__PURE__ */ new Set();
@@ -78,8 +117,12 @@ function hasPlaceUnder(metamodel, childType, placeType) {
78
117
  }
79
118
  return false;
80
119
  }
120
+ function isFinalState(node) {
121
+ return node?.type === "state" && node.kind === "final";
122
+ }
81
123
  function isPlacementAllowed(metamodel, childType, parent, nodes) {
82
124
  if (!isParentAllowed(metamodel, childType, parent?.type)) return false;
125
+ if (isFinalState(parent)) return false;
83
126
  if (!parent || parent.type !== GROUP_TYPE) return true;
84
127
  return hasPlaceUnder(metamodel, childType, placeOf(parent, nodes)?.type);
85
128
  }
@@ -100,8 +143,37 @@ function propertyKeyProblem(key, of) {
100
143
  if (!isReservedPropertyKey(key, of)) return null;
101
144
  return `"${key}" is a field every ${of === "node" ? "element" : "relation"} has (${[...RESERVED_PROPERTY_KEYS[of]].join(", ")}): give the property another key.`;
102
145
  }
146
+ function chainTypeNames(raw) {
147
+ const nodeTypes = /* @__PURE__ */ new Set();
148
+ const relationTypes = /* @__PURE__ */ new Set();
149
+ const strings = (v) => Array.isArray(v) ? v.filter((t) => typeof t === "string") : [];
150
+ const levels = raw && typeof raw === "object" ? raw.levels : void 0;
151
+ for (const level of Array.isArray(levels) ? levels : []) {
152
+ if (!level || typeof level !== "object") continue;
153
+ const l = level;
154
+ for (const way of Array.isArray(l.ways) ? l.ways : [l]) {
155
+ if (!way || typeof way !== "object") continue;
156
+ const w = way;
157
+ for (const t of strings(w.types)) nodeTypes.add(t);
158
+ if (typeof w.via?.relationType === "string") relationTypes.add(w.via.relationType);
159
+ }
160
+ for (const filter of Array.isArray(l.filters) ? l.filters : []) {
161
+ const f = filter ?? {};
162
+ if (f.kind === "type") for (const t of strings(f.types)) nodeTypes.add(t);
163
+ if (f.kind === "relation" && typeof f.relationType === "string") relationTypes.add(f.relationType);
164
+ }
165
+ }
166
+ return { nodeTypes: [...nodeTypes], relationTypes: [...relationTypes] };
167
+ }
168
+
169
+ // ../../packages/common/src/metamodel/validate.ts
170
+ init_define_RADICAL_BUILD();
171
+
172
+ // ../../packages/common/src/metamodel/statechart.ts
173
+ init_define_RADICAL_BUILD();
103
174
 
104
175
  // ../../packages/common/src/metamodel/refs.ts
176
+ init_define_RADICAL_BUILD();
105
177
  function refIds(value) {
106
178
  if (typeof value === "string") return value ? [value] : [];
107
179
  if (Array.isArray(value)) return value.filter((v) => typeof v === "string" && v !== "");
@@ -165,6 +237,46 @@ function requirementStatePhrase(requirement, nodes, relations) {
165
237
  const entity = machine ? machineEntity(machine.id, nodes, relations) : void 0;
166
238
  return entity ? `the ${entity.label} is ${state.label}` : `in ${state.label}`;
167
239
  }
240
+ function transitionRefusal(src, dst, nodes, relations, exceptId) {
241
+ const inLabel = (n) => n.parentId ? nodes[n.parentId]?.label ?? "" : "";
242
+ if (isState(src) && stateKind(src) === "final") return `Final state "${src.label}" cannot have outgoing transitions.`;
243
+ if (isPseudo(dst) && pseudoKind(dst) === "initial") return `A transition cannot point at the initial pseudostate of "${inLabel(dst)}"; target the state itself.`;
244
+ if (isPseudo(src) && pseudoKind(src) === "initial" && Object.values(relations).some((r) => r.id !== exceptId && r.sourceId === src.id && r.relationType === "transition")) {
245
+ return `The initial pseudostate of "${inLabel(src)}" has its one transition, to the default state, already.`;
246
+ }
247
+ const from = machineOf(src, nodes);
248
+ const to = machineOf(dst, nodes);
249
+ if (from && to && from.id !== to.id) return `A transition cannot leave its state machine ("${from.label}" \u2192 "${to.label}").`;
250
+ return null;
251
+ }
252
+ function lifecycleRefusal(machine, entity, nodes, relations, exceptId) {
253
+ for (const r of Object.values(relations)) {
254
+ if (r.id === exceptId || r.relationType !== "lifecycle-of") continue;
255
+ if (r.targetId === entity.id && r.sourceId !== machine.id && nodes[r.sourceId]) {
256
+ return `Entity "${entity.label}" has a state machine already ("${nodes[r.sourceId].label}"); model one lifecycle, with parallel regions if parts of it progress at once.`;
257
+ }
258
+ if (r.sourceId === machine.id && r.targetId !== entity.id && nodes[r.targetId]) {
259
+ return `State machine "${machine.label}" is the lifecycle of "${nodes[r.targetId].label}" already.`;
260
+ }
261
+ }
262
+ return null;
263
+ }
264
+ function initialPseudostateRefusal(parent, nodes, exceptId) {
265
+ if (!parent) return null;
266
+ if (isState(parent) && stateKind(parent) === "parallel") return `Parallel state "${parent.label}" enters all its regions; it takes no initial pseudostate.`;
267
+ const held = Object.values(nodes).some((n) => n.id !== exceptId && n.parentId === parent.id && isPseudo(n) && pseudoKind(n) === "initial");
268
+ if (held) return `"${parent.label}" has an initial pseudostate already; keep one.`;
269
+ return null;
270
+ }
271
+ function newPseudostateKind(parent, nodes) {
272
+ return initialPseudostateRefusal(parent, nodes) ? "choice" : "initial";
273
+ }
274
+ function isInitialPseudostate(node) {
275
+ return isPseudo(node) && pseudoKind(node) === "initial";
276
+ }
277
+ function outgoingTransitionCount(id, relations) {
278
+ return Object.values(relations).filter((r) => r.sourceId === id && r.relationType === "transition").length;
279
+ }
168
280
  function validateStateMachines(nodes, relations) {
169
281
  const nodeList = Object.values(nodes);
170
282
  if (!nodeList.some((n) => n.type === "state-machine" || n.type === "state" || n.type === "pseudostate")) return [];
@@ -302,6 +414,7 @@ function validateStateMachines(nodes, relations) {
302
414
  }
303
415
 
304
416
  // ../../packages/common/src/metamodel/domainModel.ts
417
+ init_define_RADICAL_BUILD();
305
418
  var kindOf = (n) => {
306
419
  const kind = n.kind;
307
420
  return typeof kind === "string" && kind ? kind : "aggregate-root";
@@ -341,9 +454,25 @@ function validateDomainModel(nodes, relations) {
341
454
  }
342
455
 
343
456
  // ../../packages/common/src/metamodel/validate.ts
457
+ var isNoValue = (v) => v == null || v === "" || Array.isArray(v) && v.length === 0;
344
458
  function validateModel(nodes, relations, metamodel) {
345
459
  const issues = [];
346
460
  const nodeList = Object.values(nodes);
461
+ const checkValues = (item, props, at, what) => {
462
+ const key = at.nodeId ?? at.relationId;
463
+ for (const p of props ?? []) {
464
+ const v = item[p.key];
465
+ if (p.required && isNoValue(v) && isNoValue(p.default)) {
466
+ issues.push({ id: `missing-prop:${key}:${p.key}`, severity: "warning", message: `${what} is missing required property "${p.label}".`, ...at });
467
+ }
468
+ if (p.type === "enum" && p.options?.length && !isNoValue(v) && !p.options.includes(String(v))) {
469
+ issues.push({ id: `bad-option:${key}:${p.key}`, severity: "warning", message: `${what}: "${p.label}" is "${String(v)}", which is not one of its options (${p.options.join(", ")}).`, ...at });
470
+ }
471
+ if (p.type === "ref" && !p.multiple && refIds(v).length > 1) {
472
+ issues.push({ id: `many-refs:${key}:${p.key}`, severity: "warning", message: `${what}: "${p.label}" points at ${refIds(v).length} elements, but takes one.`, ...at });
473
+ }
474
+ }
475
+ };
347
476
  for (const n of nodeList) {
348
477
  const def = metamodel.nodeTypes[n.type];
349
478
  if (!def) {
@@ -365,12 +494,13 @@ function validateModel(nodes, relations, metamodel) {
365
494
  message: `Node "${n.label}" references a missing parent.`,
366
495
  nodeId: n.id
367
496
  });
368
- } else if (allowed && !allowed.includes(parent.type)) {
497
+ } else if (!allowed?.includes(parent.type)) {
369
498
  const parentLabel = metamodel.nodeTypes[parent.type]?.label ?? parent.type;
499
+ const none = isParentAllowed(metamodel, n.type, void 0) ? "(none \u2014 must be root)" : "(none)";
370
500
  issues.push({
371
501
  id: `bad-parent:${n.id}`,
372
502
  severity: "error",
373
- message: `${def.label} "${n.label}" cannot be inside ${parentLabel}. Allowed parents: ${allowed.length ? allowed.join(", ") : "(none \u2014 must be root)"}.`,
503
+ message: `${def.label} "${n.label}" cannot be inside ${parentLabel}. Allowed parents: ${allowed?.length ? allowed.join(", ") : none}.`,
374
504
  nodeId: n.id
375
505
  });
376
506
  } else if (parent.type === GROUP_TYPE && !hasPlaceUnder(metamodel, n.type, placeOf(parent, nodes)?.type)) {
@@ -391,18 +521,7 @@ function validateModel(nodes, relations, metamodel) {
391
521
  nodeId: n.id
392
522
  });
393
523
  }
394
- for (const p of def.properties ?? []) {
395
- if (!p.required) continue;
396
- const v = n[p.key];
397
- if (v == null || v === "") {
398
- issues.push({
399
- id: `missing-prop:${n.id}:${p.key}`,
400
- severity: "warning",
401
- message: `${def.label} "${n.label}" is missing required property "${p.label}".`,
402
- nodeId: n.id
403
- });
404
- }
405
- }
524
+ checkValues(n, def.properties, { nodeId: n.id }, `${def.label} "${n.label}"`);
406
525
  }
407
526
  for (const def of Object.values(metamodel.nodeTypes)) {
408
527
  const c = def.cardinality;
@@ -425,6 +544,15 @@ function validateModel(nodes, relations, metamodel) {
425
544
  });
426
545
  }
427
546
  }
547
+ for (const def of Object.values(metamodel.nodeTypes)) {
548
+ if (hasAnyPlace(metamodel, def.id)) continue;
549
+ issues.push({
550
+ id: `no-place:${def.id}`,
551
+ severity: "warning",
552
+ message: `${noPlaceText(metamodel, def.id)}: no allowed parent, and not at the root, so nothing can be placed as a ${def.label}.`,
553
+ nodeTypeId: def.id
554
+ });
555
+ }
428
556
  for (const def of [...Object.values(metamodel.nodeTypes), ...Object.values(metamodel.relationTypes)]) {
429
557
  const seen = /* @__PURE__ */ new Set();
430
558
  for (const p of def.properties ?? []) {
@@ -451,6 +579,19 @@ function validateModel(nodes, relations, metamodel) {
451
579
  }
452
580
  }
453
581
  }
582
+ for (const vp of Array.isArray(metamodel.viewpoints) ? metamodel.viewpoints : []) {
583
+ if (!vp || typeof vp !== "object") continue;
584
+ const named = chainTypeNames(vp.pipeline);
585
+ const subject = Array.isArray(vp.subject?.types) ? vp.subject.types : [];
586
+ for (const t of /* @__PURE__ */ new Set([...subject, ...named.nodeTypes])) {
587
+ if (metamodel.nodeTypes[t]) continue;
588
+ issues.push({ id: `viewpoint-unknown-type:${vp.id}:${t}`, severity: "warning", message: `Viewpoint "${vp.label}" names node type "${t}", which the metamodel does not have.` });
589
+ }
590
+ for (const t of named.relationTypes) {
591
+ if (metamodel.relationTypes[t]) continue;
592
+ issues.push({ id: `viewpoint-unknown-rel-type:${vp.id}:${t}`, severity: "warning", message: `Viewpoint "${vp.label}" names relation type "${t}", which the metamodel does not have.` });
593
+ }
594
+ }
454
595
  const restrictiveTypes = Object.values(metamodel.relationTypes).filter((rt) => rt.allowedPairs.length > 0);
455
596
  const anyAllows = Object.values(metamodel.relationTypes).some((rt) => rt.allowedPairs.length === 0);
456
597
  if (restrictiveTypes.length > 0 && !anyAllows) {
@@ -492,20 +633,24 @@ function validateModel(nodes, relations, metamodel) {
492
633
  }
493
634
  for (const r of Object.values(relations)) {
494
635
  const def = r.relationType ? metamodel.relationTypes[r.relationType] : void 0;
495
- for (const p of def?.properties ?? []) {
496
- if (!p.required) continue;
497
- const v = r[p.key];
498
- if (v == null || v === "" || Array.isArray(v) && v.length === 0) {
499
- const src = nodes[r.sourceId]?.label ?? r.sourceId;
500
- const dst = nodes[r.targetId]?.label ?? r.targetId;
501
- issues.push({
502
- id: `missing-prop:${r.id}:${p.key}`,
503
- severity: "warning",
504
- message: `Relation "${src}" \u2192 "${dst}" (${def.label}) is missing required property "${p.label}".`,
505
- relationId: r.id
506
- });
507
- }
508
- }
636
+ if (!def) continue;
637
+ const src = nodes[r.sourceId]?.label ?? r.sourceId;
638
+ const dst = nodes[r.targetId]?.label ?? r.targetId;
639
+ checkValues(r, def.properties, { relationId: r.id }, `Relation "${src}" \u2192 "${dst}" (${def.label})`);
640
+ }
641
+ for (const r of Object.values(relations)) {
642
+ if (r.relationType) continue;
643
+ const src = nodes[r.sourceId];
644
+ const dst = nodes[r.targetId];
645
+ if (!src || !dst) continue;
646
+ const fitting = relationTypesFitting(metamodel, src.type, dst.type);
647
+ if (fitting.length < 2) continue;
648
+ issues.push({
649
+ id: `untyped-rel:${r.id}`,
650
+ severity: "warning",
651
+ message: `Relation "${src.label}" \u2192 "${dst.label}" has no type; give it one of ${fitting.map((rt) => `"${rt.label}"`).join(", ")}.`,
652
+ relationId: r.id
653
+ });
509
654
  }
510
655
  for (const r of Object.values(relations)) {
511
656
  const def = r.relationType ? metamodel.relationTypes[r.relationType] : void 0;
@@ -556,7 +701,23 @@ function validateModel(nodes, relations, metamodel) {
556
701
  return issues;
557
702
  }
558
703
 
704
+ // ../../packages/common/src/metamodel/prose.ts
705
+ init_define_RADICAL_BUILD();
706
+ function relationPhrase(def, direction, ends) {
707
+ if (!def) return { text: direction === "out" ? "Relates to" : "Linked from", reads: true };
708
+ const pair = ends ? def.allowedPairs.find((p) => p.from === ends.from && p.to === ends.to) : void 0;
709
+ if (direction === "out") return { text: pair?.forwardLabel?.trim() || def.forwardLabel?.trim() || def.label, reads: true };
710
+ const inverse = pair?.inverseLabel?.trim() || def.inverseLabel?.trim();
711
+ return inverse ? { text: inverse, reads: true } : { text: def.label, reads: false };
712
+ }
713
+ function relationTypeName(metamodel, typeId, lower = false, ends) {
714
+ const def = metamodel?.relationTypes[typeId];
715
+ const text = def ? relationPhrase(def, "out", ends).text : typeId;
716
+ return lower ? text.charAt(0).toLowerCase() + text.slice(1) : text;
717
+ }
718
+
559
719
  // ../../packages/common/src/metamodel/ears.ts
720
+ init_define_RADICAL_BUILD();
560
721
  function capitalize(s) {
561
722
  return s.charAt(0).toUpperCase() + s.slice(1);
562
723
  }
@@ -613,12 +774,34 @@ function composeEarsSentence(node, subject, statePrecondition) {
613
774
  return { sentence, complete };
614
775
  }
615
776
 
777
+ // ../../packages/common/src/metamodel/wizard.ts
778
+ init_define_RADICAL_BUILD();
779
+
780
+ // ../../packages/common/src/metamodel/categories.ts
781
+ init_define_RADICAL_BUILD();
782
+
783
+ // ../../packages/common/src/metamodel/layoutHints.ts
784
+ init_define_RADICAL_BUILD();
785
+
786
+ // ../../packages/common/src/metamodel/presets/governance.ts
787
+ init_define_RADICAL_BUILD();
788
+
789
+ // ../../packages/common/src/metamodel/presets/ddd.ts
790
+ init_define_RADICAL_BUILD();
791
+
792
+ // ../../packages/common/src/metamodel/presets/c4.ts
793
+ init_define_RADICAL_BUILD();
794
+
616
795
  // ../../packages/common/src/metamodel/presets/viewpoints.ts
796
+ init_define_RADICAL_BUILD();
617
797
  var DEPLOYABLE = ["container", "webapp", "database", "queue"];
618
798
  var BUILDING_BLOCKS = ["system", "container", "webapp", "component", "database", "queue"];
619
799
  function among(types) {
620
800
  return { levels: [{ ways: [{ types }] }], edges: "all" };
621
801
  }
802
+ function aroundOne(types, around) {
803
+ return { levels: [{ ways: [{ types }] }, { ways: [{ via: { anyRelation: true }, types: around }] }], edges: "all" };
804
+ }
622
805
  function c4Viewpoints() {
623
806
  return [
624
807
  {
@@ -637,6 +820,15 @@ function c4Viewpoints() {
637
820
  kind: "static",
638
821
  pipeline: among(["person", "system", ...DEPLOYABLE])
639
822
  },
823
+ {
824
+ id: "system-containers",
825
+ label: "Containers of a system",
826
+ group: "C4",
827
+ description: "One software system with the containers, web apps, databases and queues inside it, and the people, systems and containers they are related to: a view per system (C4 level 2).",
828
+ kind: "static",
829
+ subject: { types: ["system"] },
830
+ pipeline: aroundOne(["system", ...DEPLOYABLE], ["person", "system", ...DEPLOYABLE])
831
+ },
640
832
  {
641
833
  id: "components",
642
834
  label: "Components",
@@ -645,6 +837,15 @@ function c4Viewpoints() {
645
837
  kind: "static",
646
838
  pipeline: among(["container", "webapp", "component", "database", "queue"])
647
839
  },
840
+ {
841
+ id: "container-components",
842
+ label: "Components of a container",
843
+ group: "C4",
844
+ description: "One container or web app with the components inside it, and the people, systems, containers and components they are related to: a view per container (C4 level 3).",
845
+ kind: "static",
846
+ subject: { types: ["container", "webapp"] },
847
+ pipeline: aroundOne(["container", "webapp", "component"], ["person", "system", ...DEPLOYABLE, "component"])
848
+ },
648
849
  {
649
850
  id: "container-dependencies",
650
851
  label: "Container dependencies",
@@ -674,6 +875,21 @@ function radicalViewpoints() {
674
875
  kind: "static",
675
876
  pipeline: among(["entity"])
676
877
  },
878
+ {
879
+ id: "domain-entities",
880
+ label: "Entities of a domain",
881
+ group: "Domain",
882
+ description: "One domain with its subdomains and entities, and the entities of other domains they reference or are part of: a view per domain.",
883
+ kind: "static",
884
+ subject: { types: ["domain"] },
885
+ pipeline: {
886
+ levels: [
887
+ { ways: [{ types: ["domain", "entity"] }] },
888
+ { ways: [{ via: { relationType: "references", direction: "out" }, types: ["entity"] }, { via: { relationType: "part-of", direction: "out" }, types: ["entity"] }] }
889
+ ],
890
+ edges: "all"
891
+ }
892
+ },
677
893
  {
678
894
  id: "domain-realisation",
679
895
  label: "Domain realisation",
@@ -816,6 +1032,21 @@ function radicalViewpoints() {
816
1032
  { ways: [{ via: { relationType: "implements", direction: "in" } }, { via: { relationType: "verifies", direction: "in" }, types: ["scenario"] }] }
817
1033
  ] }
818
1034
  },
1035
+ {
1036
+ id: "state-machine",
1037
+ label: "State machine",
1038
+ group: "States",
1039
+ description: "One state machine with its states, pseudostates, events and transitions, and the entity it is the lifecycle of: a view per machine.",
1040
+ kind: "static",
1041
+ subject: { types: ["state-machine"] },
1042
+ pipeline: {
1043
+ levels: [
1044
+ { ways: [{ types: ["state-machine", "state", "pseudostate", "event"] }] },
1045
+ { ways: [{ via: { relationType: "lifecycle-of", direction: "out" }, types: ["entity"] }] }
1046
+ ],
1047
+ edges: "all"
1048
+ }
1049
+ },
819
1050
  {
820
1051
  id: "event-catalogue",
821
1052
  label: "Event catalogue",
@@ -834,6 +1065,15 @@ function radicalViewpoints() {
834
1065
  description: "The processes and their steps as Warnier\u2013Orr diagrams: what each is made of, what repeats, what is an alternative and what runs at once.",
835
1066
  kind: "warnier",
836
1067
  pipeline: { levels: [{ ways: [{ types: ["process", "step"] }] }] }
1068
+ },
1069
+ {
1070
+ id: "process",
1071
+ label: "Process",
1072
+ group: "Process",
1073
+ description: "One process and its steps as a Warnier\u2013Orr diagram: a view per process.",
1074
+ kind: "warnier",
1075
+ subject: { types: ["process"] },
1076
+ pipeline: { levels: [{ ways: [{ types: ["process", "step"] }] }] }
837
1077
  }
838
1078
  ];
839
1079
  }
@@ -930,6 +1170,11 @@ var VISUALS = {
930
1170
  collapsedHeight: 220
931
1171
  }
932
1172
  };
1173
+ var LAYOUT = {
1174
+ person: { role: "actor", side: "top" },
1175
+ database: { role: "store", side: "right" },
1176
+ queue: { role: "broker" }
1177
+ };
933
1178
  function builtInC4Metamodel() {
934
1179
  const nodeTypes = {};
935
1180
  const allowedParentsMap = {
@@ -963,6 +1208,7 @@ function builtInC4Metamodel() {
963
1208
  nodeTypes[t] = {
964
1209
  id: t,
965
1210
  label: v.label,
1211
+ ...LAYOUT[t] ? { layout: LAYOUT[t] } : {},
966
1212
  description: v.description,
967
1213
  color: v.color,
968
1214
  fg: v.fg,
@@ -978,14 +1224,18 @@ function builtInC4Metamodel() {
978
1224
  properties: props
979
1225
  };
980
1226
  }
1227
+ const DELIVERS = { forwardLabel: "Delivers to", inverseLabel: "Receives from" };
981
1228
  const interactsPairs = [
982
- // Person interacts with the system surface
1229
+ // Person interacts with the system surface, and with other people (a
1230
+ // customer asks the support staff: Structurizr models it)
1231
+ { from: "person", to: "person", forwardLabel: "Interacts with", inverseLabel: "Interacts with" },
983
1232
  { from: "person", to: "system" },
984
1233
  { from: "person", to: "container" },
985
1234
  { from: "person", to: "webapp" },
986
1235
  { from: "person", to: "component" },
987
- // System-level dependencies
988
- { from: "system", to: "person" },
1236
+ // System-level dependencies; to a person a relation delivers (Structurizr's
1237
+ // delivers(): "Sends e-mails to")
1238
+ { from: "system", to: "person", ...DELIVERS },
989
1239
  { from: "system", to: "system" },
990
1240
  { from: "system", to: "container" },
991
1241
  { from: "system", to: "database" },
@@ -993,19 +1243,23 @@ function builtInC4Metamodel() {
993
1243
  { from: "system", to: "queue" },
994
1244
  { from: "system", to: "component" },
995
1245
  // Container-level calls
996
- { from: "container", to: "person" },
1246
+ { from: "container", to: "person", ...DELIVERS },
997
1247
  { from: "container", to: "system" },
998
1248
  { from: "container", to: "container" },
999
1249
  { from: "container", to: "database" },
1000
1250
  { from: "container", to: "webapp" },
1001
1251
  { from: "container", to: "queue" },
1252
+ // …and calls a component of another container (a single-page app calls
1253
+ // the API's controllers, as Structurizr models it)
1254
+ { from: "container", to: "component" },
1002
1255
  // Web / UI container
1003
- { from: "webapp", to: "person" },
1256
+ { from: "webapp", to: "person", ...DELIVERS },
1004
1257
  { from: "webapp", to: "system" },
1005
1258
  { from: "webapp", to: "container" },
1006
1259
  { from: "webapp", to: "database" },
1007
1260
  { from: "webapp", to: "webapp" },
1008
1261
  { from: "webapp", to: "queue" },
1262
+ { from: "webapp", to: "component" },
1009
1263
  // Queues fan out to consumers
1010
1264
  { from: "queue", to: "container" },
1011
1265
  { from: "queue", to: "webapp" },
@@ -1029,7 +1283,8 @@ function builtInC4Metamodel() {
1029
1283
  properties: [
1030
1284
  { key: "technology", label: "Technology", type: "text" }
1031
1285
  ],
1032
- builtin: true
1286
+ builtin: true,
1287
+ layout: { flow: "forward" }
1033
1288
  }
1034
1289
  };
1035
1290
  return { id: "c4-builtin", name: "C4 (built-in)", nodeTypes, relationTypes, viewpoints: c4Viewpoints() };
@@ -1056,6 +1311,7 @@ function builtInDddC4Metamodel() {
1056
1311
  ];
1057
1312
  const domain = {
1058
1313
  id: "domain",
1314
+ layout: { role: "element" },
1059
1315
  label: "Domain",
1060
1316
  description: "A part of the problem space, in the language of the business rather than of the software.",
1061
1317
  color: "#4c1d95",
@@ -1073,6 +1329,7 @@ function builtInDddC4Metamodel() {
1073
1329
  };
1074
1330
  const entity = {
1075
1331
  id: "entity",
1332
+ layout: { role: "element" },
1076
1333
  label: "Entity",
1077
1334
  description: "A thing the domain keeps track of and that has an identity over time: a reservation, an order, a payment.",
1078
1335
  color: "#7e22ce",
@@ -1099,6 +1356,7 @@ function builtInDddC4Metamodel() {
1099
1356
  };
1100
1357
  const realises = {
1101
1358
  id: "realises",
1359
+ layout: { flow: "side" },
1102
1360
  label: "Realises",
1103
1361
  description: "The software behind a domain or an entity: the bounded context that implements the domain, or the element that owns the entity's data.",
1104
1362
  inverseLabel: "Realised by",
@@ -1112,6 +1370,7 @@ function builtInDddC4Metamodel() {
1112
1370
  };
1113
1371
  const partOf = {
1114
1372
  id: "part-of",
1373
+ layout: { flow: "reverse", axis: "vertical" },
1115
1374
  label: "Part of",
1116
1375
  description: "A part of an aggregate points to its root.",
1117
1376
  inverseLabel: "Made up of",
@@ -1122,6 +1381,7 @@ function builtInDddC4Metamodel() {
1122
1381
  };
1123
1382
  const references = {
1124
1383
  id: "references",
1384
+ layout: { flow: "side", axis: "horizontal" },
1125
1385
  label: "References",
1126
1386
  description: "One aggregate refers to another by id.",
1127
1387
  inverseLabel: "Referenced by",
@@ -1144,6 +1404,7 @@ function builtInDddC4Metamodel() {
1144
1404
  ];
1145
1405
  const dependsOn = {
1146
1406
  id: "depends-on",
1407
+ layout: { flow: "forward" },
1147
1408
  label: "Depends on",
1148
1409
  description: "The source domain needs the target to do its work.",
1149
1410
  inverseLabel: "Depended on by",
@@ -1155,6 +1416,7 @@ function builtInDddC4Metamodel() {
1155
1416
  };
1156
1417
  const partnership = {
1157
1418
  id: "partnership",
1419
+ layout: { flow: "side", axis: "horizontal" },
1158
1420
  label: "Partnership",
1159
1421
  description: "How the models of two domains meet, with a context-mapping pattern.",
1160
1422
  forwardLabel: "Partners with",
@@ -1222,10 +1484,14 @@ function builtInGovernanceMetamodel() {
1222
1484
  { key: "context", label: "Context", type: "textarea" },
1223
1485
  { key: "decision", label: "Decision", type: "textarea" },
1224
1486
  { key: "consequences", label: "Consequences", type: "textarea" },
1225
- { key: "alternatives", label: "Alternatives considered", type: "textarea" }
1487
+ { key: "alternatives", label: "Alternatives considered", type: "textarea" },
1488
+ // The Hub concern pack the decision settles (its concern id), for the
1489
+ // check's concern-unaddressed rule; set by a pack's import.
1490
+ { key: "concern", label: "Concern (Hub)", type: "text" }
1226
1491
  ];
1227
1492
  const adr = {
1228
1493
  id: "adr",
1494
+ layout: { role: "note", side: "left" },
1229
1495
  label: "ADR",
1230
1496
  description: "An architecture decision record: the context of a decision, the decision itself, its consequences and the alternatives that were considered.",
1231
1497
  color: "#92400e",
@@ -1305,6 +1571,7 @@ function builtInGovernanceMetamodel() {
1305
1571
  ];
1306
1572
  const fitnessFn = {
1307
1573
  id: "fitness-fn",
1574
+ layout: { role: "note", side: "left" },
1308
1575
  label: "Fitness Function",
1309
1576
  description: "An objective, preferably automated check that the architecture still has a property it was designed for.",
1310
1577
  color: "#5b21b6",
@@ -1370,6 +1637,7 @@ function builtInGovernanceMetamodel() {
1370
1637
  ];
1371
1638
  const need = {
1372
1639
  id: "need",
1640
+ layout: { role: "element" },
1373
1641
  label: "Need",
1374
1642
  description: "Raw input in the stakeholder's own words, kept verbatim: a brief, a user story, a note, a regulation.",
1375
1643
  color: "#475569",
@@ -1438,6 +1706,7 @@ function builtInGovernanceMetamodel() {
1438
1706
  ];
1439
1707
  const requirement = {
1440
1708
  id: "requirement",
1709
+ layout: { role: "note", side: "left" },
1441
1710
  label: "Requirement",
1442
1711
  description: "One thing the system shall do, written as an EARS sentence.",
1443
1712
  color: "#0e7490",
@@ -1511,6 +1780,7 @@ function builtInGovernanceMetamodel() {
1511
1780
  );
1512
1781
  const constrains = {
1513
1782
  id: "constrains",
1783
+ layout: { flow: "side" },
1514
1784
  label: "Constrains",
1515
1785
  description: "The decision, check or requirement applies to the target element.",
1516
1786
  inverseLabel: "Constrained by",
@@ -1519,31 +1789,37 @@ function builtInGovernanceMetamodel() {
1519
1789
  { key: "description", label: "Note", type: "text" }
1520
1790
  ],
1521
1791
  color: "#dc2626",
1792
+ governance: true,
1522
1793
  builtin: true
1523
1794
  };
1524
1795
  const supersedes = {
1525
1796
  id: "supersedes",
1797
+ layout: { flow: "forward" },
1526
1798
  label: "Supersedes",
1527
1799
  description: "The newer decision replaces the older one.",
1528
1800
  inverseLabel: "Superseded by",
1529
1801
  allowedPairs: [{ from: "adr", to: "adr" }],
1530
1802
  properties: [],
1531
1803
  color: "#f59e0b",
1804
+ governance: true,
1532
1805
  builtin: true
1533
1806
  };
1534
1807
  const implements_ = {
1535
1808
  id: "implements",
1809
+ layout: { flow: "side" },
1536
1810
  label: "Implements",
1537
1811
  description: "A fitness function checks that a decision still holds; a C4 element runs a state machine.",
1538
1812
  inverseLabel: "Implemented by",
1539
1813
  allowedPairs: [{ from: "fitness-fn", to: "adr" }],
1540
1814
  properties: [],
1541
1815
  color: "#7c3aed",
1816
+ governance: true,
1542
1817
  builtin: true
1543
1818
  };
1544
1819
  const satisfiesTargets = ["person", "system", "domain", "container", "component", "database", "webapp", "queue"];
1545
1820
  const satisfies = {
1546
1821
  id: "satisfies",
1822
+ layout: { flow: "side" },
1547
1823
  label: "Satisfies",
1548
1824
  description: "The element is what makes the requirement true.",
1549
1825
  inverseLabel: "Satisfied by",
@@ -1552,10 +1828,12 @@ function builtInGovernanceMetamodel() {
1552
1828
  { key: "description", label: "Note", type: "text" }
1553
1829
  ],
1554
1830
  color: "#0891b2",
1831
+ governance: true,
1555
1832
  builtin: true
1556
1833
  };
1557
1834
  const derives = {
1558
1835
  id: "derives",
1836
+ layout: { flow: "reverse", axis: "vertical" },
1559
1837
  label: "Derives from",
1560
1838
  description: "A requirement turns stakeholder input into a shall-statement or refines a broader requirement; a need sits inside a broader need.",
1561
1839
  inverseLabel: "Refined into",
@@ -1566,10 +1844,12 @@ function builtInGovernanceMetamodel() {
1566
1844
  ],
1567
1845
  properties: [],
1568
1846
  color: "#0d9488",
1847
+ governance: true,
1569
1848
  builtin: true
1570
1849
  };
1571
1850
  const tracesTo = {
1572
1851
  id: "traces-to",
1852
+ layout: { flow: "reverse", axis: "vertical" },
1573
1853
  label: "Traces to",
1574
1854
  description: "The decision the requirement led to, or the check that keeps it.",
1575
1855
  inverseLabel: "Traced from",
@@ -1579,6 +1859,7 @@ function builtInGovernanceMetamodel() {
1579
1859
  ],
1580
1860
  properties: [],
1581
1861
  color: "#06b6d4",
1862
+ governance: true,
1582
1863
  builtin: true
1583
1864
  };
1584
1865
  const scenarioProps = [
@@ -1590,6 +1871,7 @@ function builtInGovernanceMetamodel() {
1590
1871
  ];
1591
1872
  const scenario = {
1592
1873
  id: "scenario",
1874
+ layout: { role: "note", side: "left" },
1593
1875
  label: "Scenario",
1594
1876
  description: "An acceptance example in Gherkin: given a starting situation, when something happens, then the outcome.",
1595
1877
  color: "#166534",
@@ -1644,12 +1926,14 @@ function builtInGovernanceMetamodel() {
1644
1926
  const verifiesTargets = ["requirement"];
1645
1927
  const verifies = {
1646
1928
  id: "verifies",
1929
+ layout: { flow: "reverse", axis: "vertical" },
1647
1930
  label: "Verifies",
1648
1931
  description: "The scenario is the acceptance test of the requirement or state machine.",
1649
1932
  inverseLabel: "Verified by",
1650
1933
  allowedPairs: verifiesTargets.map((to) => ({ from: "scenario", to })),
1651
1934
  properties: [],
1652
1935
  color: "#16a34a",
1936
+ governance: true,
1653
1937
  builtin: true
1654
1938
  };
1655
1939
  const blueprintProps = [
@@ -1666,6 +1950,7 @@ function builtInGovernanceMetamodel() {
1666
1950
  ];
1667
1951
  const blueprint = {
1668
1952
  id: "blueprint",
1953
+ layout: { role: "element" },
1669
1954
  label: "Blueprint",
1670
1955
  description: "A curated reference architecture imported from the Concept Hub.",
1671
1956
  color: "#1e3a5f",
@@ -1689,6 +1974,7 @@ function builtInGovernanceMetamodel() {
1689
1974
  ];
1690
1975
  const mockup = {
1691
1976
  id: "mockup",
1977
+ layout: { role: "screen" },
1692
1978
  label: "Mockup",
1693
1979
  description: "One screen of the product, optionally with a low-fi wireframe.",
1694
1980
  color: "#be185d",
@@ -1737,6 +2023,7 @@ function builtInGovernanceMetamodel() {
1737
2023
  };
1738
2024
  const illustrates = {
1739
2025
  id: "illustrates",
2026
+ layout: { flow: "side" },
1740
2027
  label: "Illustrates",
1741
2028
  description: "The screen shows the requirement being met, the step of the scenario, or what the user sees in the state.",
1742
2029
  inverseLabel: "Illustrated by",
@@ -1746,20 +2033,24 @@ function builtInGovernanceMetamodel() {
1746
2033
  ],
1747
2034
  properties: [],
1748
2035
  color: "#db2777",
2036
+ governance: true,
1749
2037
  builtin: true
1750
2038
  };
1751
2039
  const presentedBy = {
1752
2040
  id: "presented-by",
2041
+ layout: { flow: "side" },
1753
2042
  label: "Presented by",
1754
2043
  description: "The part of the architecture that renders the screen.",
1755
2044
  inverseLabel: "Presents",
1756
2045
  allowedPairs: ["webapp", "container", "component", "system"].map((to) => ({ from: "mockup", to })),
1757
2046
  properties: [],
1758
2047
  color: "#be185d",
2048
+ governance: true,
1759
2049
  builtin: true
1760
2050
  };
1761
2051
  const navigatesTo = {
1762
2052
  id: "navigates-to",
2053
+ layout: { flow: "forward", axis: "horizontal" },
1763
2054
  label: "Navigates to",
1764
2055
  description: "One step of a screen flow, with what triggers it.",
1765
2056
  inverseLabel: "Reached from",
@@ -1772,6 +2063,7 @@ function builtInGovernanceMetamodel() {
1772
2063
  };
1773
2064
  const stateMachine = {
1774
2065
  id: "state-machine",
2066
+ layout: { role: "element" },
1775
2067
  label: "State Machine",
1776
2068
  description: "The lifecycle of one entity: the states it can be in and the transitions between them.",
1777
2069
  color: "#3730a3",
@@ -1791,6 +2083,7 @@ function builtInGovernanceMetamodel() {
1791
2083
  };
1792
2084
  const state = {
1793
2085
  id: "state",
2086
+ layout: { role: "element", byProperty: { key: "kind", roles: { final: "end" } } },
1794
2087
  label: "State",
1795
2088
  description: "A situation the entity can be in.",
1796
2089
  color: "#4f46e5",
@@ -1820,6 +2113,7 @@ function builtInGovernanceMetamodel() {
1820
2113
  };
1821
2114
  const pseudostate = {
1822
2115
  id: "pseudostate",
2116
+ layout: { role: "element", byProperty: { key: "kind", roles: { initial: "start" } } },
1823
2117
  label: "Pseudostate",
1824
2118
  description: "A point a state machine passes through but never rests in: where it starts, a choice, a history.",
1825
2119
  color: "#1e1b4b",
@@ -1843,6 +2137,7 @@ function builtInGovernanceMetamodel() {
1843
2137
  };
1844
2138
  const event = {
1845
2139
  id: "event",
2140
+ layout: { role: "note", side: "left" },
1846
2141
  label: "Event",
1847
2142
  description: "Something that happens and can trigger a transition.",
1848
2143
  color: "#c2410c",
@@ -1869,6 +2164,7 @@ function builtInGovernanceMetamodel() {
1869
2164
  const stateNodeTypes = ["state", "pseudostate"];
1870
2165
  const transition = {
1871
2166
  id: "transition",
2167
+ layout: { flow: "forward", axis: "vertical" },
1872
2168
  label: "Transition",
1873
2169
  description: "The machine moves from one state to another: on an event, under a guard, running actions.",
1874
2170
  forwardLabel: "Transitions to",
@@ -1892,6 +2188,7 @@ function builtInGovernanceMetamodel() {
1892
2188
  };
1893
2189
  const lifecycleOf = {
1894
2190
  id: "lifecycle-of",
2191
+ layout: { flow: "side" },
1895
2192
  label: "Lifecycle of",
1896
2193
  description: "The machine is the lifecycle of that entity.",
1897
2194
  inverseLabel: "Lifecycle modelled by",
@@ -1902,6 +2199,7 @@ function builtInGovernanceMetamodel() {
1902
2199
  };
1903
2200
  const emits = {
1904
2201
  id: "emits",
2202
+ layout: { flow: "side" },
1905
2203
  label: "Emits",
1906
2204
  description: "The element raises the event.",
1907
2205
  inverseLabel: "Emitted by",
@@ -1927,6 +2225,7 @@ function builtInGovernanceMetamodel() {
1927
2225
  };
1928
2226
  const process_ = {
1929
2227
  id: "process",
2228
+ layout: { role: "element" },
1930
2229
  label: "Process",
1931
2230
  description: "A procedure: the steps it is made of, what repeats and what is an alternative.",
1932
2231
  color: "#0f766e",
@@ -1949,6 +2248,7 @@ function builtInGovernanceMetamodel() {
1949
2248
  };
1950
2249
  const step = {
1951
2250
  id: "step",
2251
+ layout: { role: "element" },
1952
2252
  label: "Step",
1953
2253
  description: "One part of a process, itself made of steps or not.",
1954
2254
  color: "#14b8a6",
@@ -1978,6 +2278,7 @@ function builtInGovernanceMetamodel() {
1978
2278
  };
1979
2279
  const performedBy = {
1980
2280
  id: "performed-by",
2281
+ layout: { flow: "side" },
1981
2282
  label: "Performed by",
1982
2283
  description: "The person or part of the architecture that does the step.",
1983
2284
  inverseLabel: "Performs",
@@ -2031,6 +2332,34 @@ function builtInGovernanceMetamodel() {
2031
2332
  };
2032
2333
  }
2033
2334
 
2335
+ // ../../packages/common/src/metamodel/layoutHints.ts
2336
+ var preset = null;
2337
+ var presetHints = () => preset ??= builtInGovernanceMetamodel();
2338
+ function nodeLayoutHint(typeId, mm) {
2339
+ return mm?.nodeTypes[typeId]?.layout ?? presetHints().nodeTypes[typeId]?.layout ?? {};
2340
+ }
2341
+ function layoutRoleOf(node, mm) {
2342
+ const hint = nodeLayoutHint(node.type, mm);
2343
+ if (hint.byProperty) {
2344
+ const value = node[hint.byProperty.key];
2345
+ const byValue = typeof value === "string" ? hint.byProperty.roles[value] : void 0;
2346
+ if (byValue) return byValue;
2347
+ }
2348
+ return hint.role ?? "element";
2349
+ }
2350
+ var FORWARD = { flow: "forward", axis: "free" };
2351
+ function relationLayoutHint(typeId, mm) {
2352
+ if (!typeId) return FORWARD;
2353
+ const hint = mm?.relationTypes[typeId]?.layout ?? presetHints().relationTypes[typeId]?.layout;
2354
+ return hint ? { axis: "free", ...hint } : FORWARD;
2355
+ }
2356
+ var LAYOUT_ROLES = ["element", "actor", "store", "note", "start", "end", "broker", "screen"];
2357
+ var LAYOUT_FLOWS = ["forward", "reverse", "side"];
2358
+ var LAYOUT_AXES = ["free", "vertical", "horizontal"];
2359
+
2360
+ // ../../packages/common/src/metamodel/presets/index.ts
2361
+ init_define_RADICAL_BUILD();
2362
+
2034
2363
  // ../../packages/common/src/c4.ts
2035
2364
  var CONTAINER_TYPES = /* @__PURE__ */ new Set([
2036
2365
  "system",
@@ -2047,6 +2376,14 @@ var CONTAINER_TYPES = /* @__PURE__ */ new Set([
2047
2376
  function isContainerType(type) {
2048
2377
  return !!type && CONTAINER_TYPES.has(type);
2049
2378
  }
2379
+ function isBackwardStep(sequence, i) {
2380
+ return sequence?.stepBackward?.[i] === true;
2381
+ }
2382
+ function trimStepBackward(flags) {
2383
+ const out = Array.from(flags ?? [], (flag) => flag === true);
2384
+ while (out.length > 0 && !out[out.length - 1]) out.pop();
2385
+ return out.length ? out : void 0;
2386
+ }
2050
2387
  function pinnedNodeIds(constraints) {
2051
2388
  return constraints?.find((c) => c.type === "pin")?.nodeIds ?? [];
2052
2389
  }
@@ -2095,6 +2432,9 @@ function constraintLines(constraints) {
2095
2432
  ];
2096
2433
  });
2097
2434
  }
2435
+ function slideWithoutMilestone(slide) {
2436
+ return { id: slide.id, name: slide.name, snapshotId: null, viewId: slide.viewId ?? null, viewport: { x: 0, y: 0, zoom: 0 } };
2437
+ }
2098
2438
  var BUILTIN_NODE_TYPES = builtInGovernanceMetamodel().nodeTypes;
2099
2439
  function pluckPerType(fn) {
2100
2440
  const out = {};
@@ -2104,6 +2444,14 @@ function pluckPerType(fn) {
2104
2444
  return out;
2105
2445
  }
2106
2446
  var NODE_SIZES = pluckPerType((def) => ({ width: def.width, height: def.height }));
2447
+ function nodeTypeSize(type, metamodel) {
2448
+ const def = metamodel?.nodeTypes[type];
2449
+ const builtIn = NODE_SIZES[type];
2450
+ return {
2451
+ width: def?.width ?? builtIn?.width ?? 160,
2452
+ height: def?.height ?? builtIn?.height ?? 90
2453
+ };
2454
+ }
2107
2455
  var COLLAPSED_HEIGHT = pluckPerType((def) => def.collapsedHeight ?? def.height);
2108
2456
  var COLLAPSED_WIDTH = pluckPerType((def) => def.collapsedWidth ?? def.width);
2109
2457
  var NODE_COLORS = pluckPerType((def) => def.color);
@@ -2113,6 +2461,14 @@ var TYPE_ICON_PATHS = pluckPerType((def) => def.iconPath);
2113
2461
  function normalizeViewFolder(folder) {
2114
2462
  return (folder ?? "").split("/").map((part) => part.trim()).filter(Boolean).join("/");
2115
2463
  }
2464
+ function viewFolderPaths(views) {
2465
+ const paths = /* @__PURE__ */ new Set();
2466
+ for (const view of views) {
2467
+ const parts = normalizeViewFolder(view.folder).split("/").filter(Boolean);
2468
+ for (let i = 1; i <= parts.length; i++) paths.add(parts.slice(0, i).join("/"));
2469
+ }
2470
+ return [...paths].sort((a, b) => a.localeCompare(b, void 0, { numeric: true, sensitivity: "base" }));
2471
+ }
2116
2472
  var WIKI_DEPTH_MIN = 1;
2117
2473
  var WIKI_DEPTH_MAX = 5;
2118
2474
  function wikiDepthOf(view) {
@@ -2120,15 +2476,28 @@ function wikiDepthOf(view) {
2120
2476
  if (typeof d !== "number" || !Number.isFinite(d)) return WIKI_DEPTH_MIN;
2121
2477
  return Math.min(WIKI_DEPTH_MAX, Math.max(WIKI_DEPTH_MIN, Math.floor(d)));
2122
2478
  }
2479
+ function holderOf(nodes, a, b) {
2480
+ const holds = (outer, inner) => {
2481
+ const seen = /* @__PURE__ */ new Set();
2482
+ for (let id = inner.parentId; id && !seen.has(id); id = nodes[id]?.parentId) {
2483
+ if (id === outer.id) return true;
2484
+ seen.add(id);
2485
+ }
2486
+ return false;
2487
+ };
2488
+ return holds(a, b) ? a : holds(b, a) ? b : void 0;
2489
+ }
2123
2490
  function viewShowsEveryNode(view) {
2124
2491
  return view.nodeIds.length === 0 && !view.empty;
2125
2492
  }
2126
- function viewCanvasPositions(view, nodes, positions) {
2127
- if (view.kind && view.kind !== "static") return {};
2128
- if (viewShowsEveryNode(view)) return positions;
2493
+ function viewCanvasPositions(view, nodes, positions, drawn) {
2494
+ if (view.kind === "explore") return Object.fromEntries(view.nodeIds.filter((id) => id in positions && nodes[id]).map((id) => [id, positions[id]]));
2495
+ if (view.kind && view.kind !== "static") positions = view.positions ?? {};
2496
+ const ids = drawn ?? (viewShowsEveryNode(view) ? void 0 : view.nodeIds);
2497
+ if (!ids) return positions;
2129
2498
  const kept = {};
2130
2499
  const seen = /* @__PURE__ */ new Set();
2131
- for (const id of view.nodeIds) {
2500
+ for (const id of ids) {
2132
2501
  for (let cur = id; cur && nodes[cur] && !seen.has(cur); cur = nodes[cur].parentId) {
2133
2502
  seen.add(cur);
2134
2503
  if (cur in positions) kept[cur] = positions[cur];
@@ -2136,10 +2505,10 @@ function viewCanvasPositions(view, nodes, positions) {
2136
2505
  }
2137
2506
  return kept;
2138
2507
  }
2139
- function withCanvasPositions(views, nodes) {
2508
+ function withCanvasPositions(views, nodes, drawnOf) {
2140
2509
  return views.map((view) => {
2141
- const kept = viewCanvasPositions(view, nodes, view.positions ?? {});
2142
- return Object.keys(kept).length === Object.keys(view.positions ?? {}).length ? view : { ...view, positions: kept };
2510
+ const kept = viewCanvasPositions(view, nodes, view.positions ?? {}, drawnOf?.(view));
2511
+ return view.positions && Object.keys(kept).length === Object.keys(view.positions).length ? view : { ...view, positions: kept };
2143
2512
  });
2144
2513
  }
2145
2514
  function removeFromViewList(view, removed) {
@@ -2154,6 +2523,7 @@ function addToViewList(view, ids) {
2154
2523
  }
2155
2524
 
2156
2525
  // ../../packages/layout/src/elkSpacingBase.ts
2526
+ init_define_RADICAL_BUILD();
2157
2527
  var ELK_ROOT_SPACING = {
2158
2528
  "elk.spacing.nodeNode": "60",
2159
2529
  "elk.layered.spacing.nodeNodeBetweenLayers": "80",
@@ -2170,6 +2540,7 @@ var ELK_CHILD_SPACING = {
2170
2540
  };
2171
2541
 
2172
2542
  // ../../packages/layout/src/geometry.ts
2543
+ init_define_RADICAL_BUILD();
2173
2544
  function effectiveWidth(n) {
2174
2545
  if (isContainerType(n.type) && n.collapsed) return COLLAPSED_WIDTH[n.type];
2175
2546
  return n.width ?? NODE_SIZES[n.type].width;
@@ -2206,25 +2577,10 @@ function fittedParentSize(parent, children) {
2206
2577
  maxBottom = Math.max(maxBottom, child.y + child.height);
2207
2578
  }
2208
2579
  return {
2209
- width: Math.max(maxRight + pad.side, NODE_SIZES[parent.type].width),
2210
- height: Math.max(maxBottom + pad.bottom, NODE_SIZES[parent.type].height)
2580
+ width: Math.max(maxRight + pad.side, COLLAPSED_WIDTH[parent.type] ?? NODE_SIZES[parent.type].width),
2581
+ height: Math.max(maxBottom + pad.bottom, COLLAPSED_HEIGHT[parent.type] ?? NODE_SIZES[parent.type].height)
2211
2582
  };
2212
2583
  }
2213
- function fitAncestors(nodes, startId) {
2214
- const seen = /* @__PURE__ */ new Set();
2215
- let cur = startId ? nodes[startId] : void 0;
2216
- while (cur && !seen.has(cur.id)) {
2217
- seen.add(cur.id);
2218
- const parentId = cur.id;
2219
- const children = Object.values(nodes).filter((n) => n.parentId === parentId);
2220
- if (isContainerType(cur.type) && !cur.collapsed && children.length > 0) {
2221
- const size = fittedParentSize(cur, children.map((c) => ({ x: c.x, y: c.y, width: effectiveWidth(c), height: effectiveHeight(c) })));
2222
- cur.width = size.width;
2223
- cur.height = size.height;
2224
- }
2225
- cur = cur.parentId ? nodes[cur.parentId] : void 0;
2226
- }
2227
- }
2228
2584
  function placeNewNode(nodes, parentId) {
2229
2585
  const parent = parentId ? nodes[parentId] : void 0;
2230
2586
  const siblings = Object.values(nodes).filter((n) => (n.parentId ?? void 0) === (parent?.id ?? void 0));
@@ -2233,6 +2589,223 @@ function placeNewNode(nodes, parentId) {
2233
2589
  const pad = compoundPadding(parent.type);
2234
2590
  return { x: siblings.length ? right + 20 : pad.side, y: pad.top };
2235
2591
  }
2592
+ function placeBesideSiblings(nodes, parentId, counts = () => true) {
2593
+ const parent = parentId ? nodes[parentId] : void 0;
2594
+ const siblings = Object.values(nodes).filter((s) => (s.parentId ?? void 0) === (parent?.id ?? void 0) && counts(s));
2595
+ if (siblings.length === 0) {
2596
+ const pad = parent ? compoundPadding(parent.type) : { top: 0, side: 0 };
2597
+ return { x: pad.side, y: pad.top };
2598
+ }
2599
+ return {
2600
+ x: Math.max(...siblings.map((s) => s.x + effectiveWidth(s))) + (parent ? 20 : 80),
2601
+ y: Math.min(...siblings.map((s) => s.y))
2602
+ };
2603
+ }
2604
+ function centredIn(frame, size, pad) {
2605
+ return {
2606
+ x: Math.max(pad.side, Math.round((frame.width - size.width) / 2)),
2607
+ y: pad.top + Math.max(0, Math.round((frame.height - pad.top - pad.bottom - size.height) / 2))
2608
+ };
2609
+ }
2610
+ var GRID_GAP = 60;
2611
+ function gridSlotIn(nodes, parentId, size, counts = () => true, frame) {
2612
+ const parent = nodes[parentId];
2613
+ const pad = compoundPadding(parent?.type ?? "system");
2614
+ const kids = Object.values(nodes).filter((c) => c.parentId === parentId && counts(c));
2615
+ if (!kids.length) return centredIn(frame ?? { width: parent?.width ?? 0, height: parent?.height ?? 0 }, size, pad);
2616
+ const cellW = Math.max(size.width, ...kids.map(effectiveWidth));
2617
+ const cellH = Math.max(size.height, ...kids.map(effectiveHeight));
2618
+ const taken = kids.map((c) => ({ x: c.x, y: c.y, w: effectiveWidth(c), h: effectiveHeight(c) }));
2619
+ const left = Math.max(pad.side, Math.min(...kids.map((c) => c.x)));
2620
+ const top = Math.max(pad.top, Math.min(...kids.map((c) => c.y)));
2621
+ for (let i = 0; i < 1e4; i++) {
2622
+ const { column, row } = landscapeSlot(i);
2623
+ const box = { x: left + column * (cellW + GRID_GAP), y: top + row * (cellH + GRID_GAP), w: size.width, h: size.height };
2624
+ if (!taken.some((t) => boxesOverlap(box, t))) return { x: box.x, y: box.y };
2625
+ }
2626
+ return placeBesideSiblings(nodes, parentId, counts);
2627
+ }
2628
+ function modelCanvas(nodes, shownIds, frames) {
2629
+ const shown = (n) => (!shownIds || shownIds.has(n.id)) && isVisible(n, nodes);
2630
+ const parents = new Set(Object.values(nodes).filter(shown).map((n) => n.parentId).filter((id) => !!id));
2631
+ const boxOf = (n) => {
2632
+ const size = drawnSize(n, parents.has(n.id));
2633
+ return { x: n.x, y: n.y, w: size.width, h: size.height };
2634
+ };
2635
+ return frames?.size ? { shown, boxOf, frame: (n) => frames.has(n.id) } : { shown, boxOf };
2636
+ }
2637
+ var boxesOverlap = (a, b) => a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;
2638
+ function liesClearInParent(node, nodes, canvas, ignore = () => false) {
2639
+ const box = canvas.boxOf(node);
2640
+ const parent = node.parentId ? nodes[node.parentId] : void 0;
2641
+ if (parent) {
2642
+ const frame = canvas.boxOf(parent);
2643
+ if (box.x < 0 || box.y < 0 || box.x + box.w > frame.w || box.y + box.h > frame.h) return false;
2644
+ }
2645
+ return !Object.values(nodes).some((s) => s.id !== node.id && (s.parentId ?? void 0) === (node.parentId ?? void 0) && canvas.shown(s) && !ignore(s) && drawnBoxesOf(s, nodes, canvas, (c) => c.id !== node.id && !ignore(c)).some((b) => boxesOverlap(box, b)));
2646
+ }
2647
+ function drawnBoxesOf(node, nodes, canvas, keep = () => true) {
2648
+ const box = canvas.boxOf(node);
2649
+ if (!canvas.frame?.(node)) return [box];
2650
+ return Object.values(nodes).filter((c) => c.parentId === node.id && canvas.shown(c) && keep(c)).flatMap((c) => drawnBoxesOf(c, nodes, canvas, keep).map((b) => ({ ...b, x: b.x + box.x, y: b.y + box.y })));
2651
+ }
2652
+ function settleMovedNodes(nodes, ids, canvas, fit = (parentId) => fitShown(nodes, parentId, canvas), opened) {
2653
+ const touched = [];
2654
+ const settle = (moved, on) => {
2655
+ const waiting = new Set(moved);
2656
+ const alone = [];
2657
+ for (const id of moved) {
2658
+ const node = nodes[id];
2659
+ if (!liesClearInParent(node, nodes, on, (s) => waiting.has(s.id))) {
2660
+ const counts = (s) => s.id !== id && !waiting.has(s.id) && on.shown(s);
2661
+ const box = on.boxOf(node);
2662
+ const at = node.parentId && nodes[node.parentId] ? gridSlotIn(nodes, node.parentId, { width: box.w, height: box.h }, (s) => counts(s), { width: on.boxOf(nodes[node.parentId]).w, height: on.boxOf(nodes[node.parentId]).h }) : freeSpotNear(
2663
+ Object.values(nodes).filter((s) => !s.parentId && counts(s)).flatMap((s) => drawnBoxesOf(s, nodes, on, counts)).map((b) => ({ x: b.x, y: b.y, width: b.w, height: b.h })),
2664
+ { width: box.w, height: box.h },
2665
+ { x: box.x + box.w / 2, y: box.y + box.h / 2 }
2666
+ );
2667
+ node.x = at.x;
2668
+ node.y = at.y;
2669
+ touched.push(id);
2670
+ if (node.parentId && !Object.values(nodes).some((s) => s.parentId === node.parentId && counts(s)) && moved.filter((m) => nodes[m]?.parentId === node.parentId).length === 1) alone.push(id);
2671
+ }
2672
+ waiting.delete(id);
2673
+ }
2674
+ const parents = [...new Set(moved.map((id) => nodes[id].parentId).filter((p) => !!p && !!nodes[p]))];
2675
+ for (const parentId of parents) touched.push(...growWithRoom(nodes, parentId, on, fit));
2676
+ for (const id of alone) {
2677
+ const node = nodes[id];
2678
+ const frame = on.boxOf(nodes[node.parentId]);
2679
+ const box = on.boxOf(node);
2680
+ Object.assign(node, centredIn({ width: frame.w, height: frame.h }, { width: box.w, height: box.h }, compoundPadding(nodes[node.parentId].type)));
2681
+ }
2682
+ };
2683
+ settle(ids.filter((id) => nodes[id] && canvas.shown(nodes[id])), canvas);
2684
+ if (opened) settle(ids.filter((id) => nodes[id] && !canvas.shown(nodes[id]) && opened.shown(nodes[id])), opened);
2685
+ return touched;
2686
+ }
2687
+ function growWithRoom(nodes, startId, canvas, fit = (parentId) => fitShown(nodes, parentId, canvas)) {
2688
+ const pushed = [];
2689
+ const seen = /* @__PURE__ */ new Set();
2690
+ for (let cur = nodes[startId]; cur && !seen.has(cur.id); cur = cur.parentId ? nodes[cur.parentId] : void 0) {
2691
+ seen.add(cur.id);
2692
+ const was = canvas.boxOf(cur);
2693
+ fit(cur.id);
2694
+ const now = canvas.boxOf(nodes[cur.id]);
2695
+ if (now.w <= was.w && now.h <= was.h) continue;
2696
+ if (canvas.frame?.(cur)) continue;
2697
+ for (const [id, at] of Object.entries(makeRoomAround(cur.id, nodes, canvas))) {
2698
+ nodes[id].x = at.x;
2699
+ nodes[id].y = at.y;
2700
+ pushed.push(id);
2701
+ }
2702
+ if (cur.parentId) growFrameLeftUp(nodes, cur.parentId, canvas.shown);
2703
+ }
2704
+ return pushed;
2705
+ }
2706
+ var CHILD_TOP_MIN = 50;
2707
+ function growFrameLeftUp(nodes, parentId, shown = () => true) {
2708
+ const parent = nodes[parentId];
2709
+ if (!parent) return;
2710
+ const kids = Object.values(nodes).filter((c) => c.parentId === parentId && shown(c));
2711
+ if (!kids.length) return;
2712
+ const pad = compoundPadding(parent.type);
2713
+ const minX = Math.min(...kids.map((c) => c.x));
2714
+ const minY = Math.min(...kids.map((c) => c.y));
2715
+ const dx = minX < 0 ? pad.side - minX : 0;
2716
+ const dy = minY < CHILD_TOP_MIN ? pad.top - minY : 0;
2717
+ if (!dx && !dy) return;
2718
+ parent.x -= dx;
2719
+ parent.y -= dy;
2720
+ for (const k of kids) {
2721
+ k.x += dx;
2722
+ k.y += dy;
2723
+ }
2724
+ }
2725
+ function fitShown(nodes, parentId, canvas) {
2726
+ const parent = nodes[parentId];
2727
+ if (!parent || !isContainerType(parent.type) || parent.collapsed) return;
2728
+ const children = Object.values(nodes).filter((c) => c.parentId === parentId && canvas.shown(c));
2729
+ if (!children.length) return;
2730
+ const size = fittedParentSize(parent, children.map((c) => ({ x: c.x, y: c.y, width: effectiveWidth(c), height: effectiveHeight(c) })));
2731
+ parent.width = size.width;
2732
+ parent.height = size.height;
2733
+ }
2734
+ var EXPAND_GAP = 20;
2735
+ var HIT_COST = 200;
2736
+ function makeRoomAround(grownId, nodes, canvas) {
2737
+ const grown = nodes[grownId];
2738
+ if (!grown) return {};
2739
+ const { shown, boxOf } = canvas;
2740
+ const siblings = Object.values(nodes).filter((n) => (n.parentId ?? void 0) === (grown.parentId ?? void 0) && shown(n));
2741
+ if (siblings.length < 2) return {};
2742
+ const box = new Map(siblings.map((n) => [n.id, boxOf(n)]));
2743
+ const before = new Map(siblings.map((n) => [n.id, boxOf(n)]));
2744
+ const g = box.get(grownId);
2745
+ const gx = g.x + g.w / 2;
2746
+ const gy = g.y + g.h / 2;
2747
+ const gapTo = (b) => Math.max(g.x - (b.x + b.w), b.x - (g.x + g.w), g.y - (b.y + b.h), b.y - (g.y + g.h), 0);
2748
+ const order = siblings.filter((n) => n.id !== grownId).map((n) => ({ id: n.id, gap: gapTo(box.get(n.id)), centre: Math.hypot(box.get(n.id).x + box.get(n.id).w / 2 - gx, box.get(n.id).y + box.get(n.id).h / 2 - gy) })).sort((a, b) => a.gap - b.gap || a.centre - b.centre || (a.id < b.id ? -1 : 1));
2749
+ const placed = [grownId];
2750
+ const moved = /* @__PURE__ */ new Set([grownId]);
2751
+ const hits = (a, b, gap) => a.x < b.x + b.w + gap && b.x < a.x + a.w + gap && a.y < b.y + b.h + gap && b.y < a.y + a.h + gap;
2752
+ const gapOf = (a, b) => {
2753
+ if (a === grownId || b === grownId) return EXPAND_GAP;
2754
+ const [p, q] = [before.get(a), before.get(b)];
2755
+ return Math.min(EXPAND_GAP, Math.max(0, p.x - (q.x + q.w), q.x - (p.x + p.w), p.y - (q.y + q.h), q.y - (p.y + p.h)));
2756
+ };
2757
+ for (const { id } of order) {
2758
+ const b = box.get(id);
2759
+ const cx = b.x + b.w / 2 - gx;
2760
+ const cy = b.y + b.h / 2 - gy;
2761
+ for (let step = 0; step < placed.length * 4 + 8; step++) {
2762
+ const at = placed.findIndex((pid) => (moved.has(pid) || moved.has(id)) && hits(b, box.get(pid), gapOf(id, pid)));
2763
+ if (at < 0) break;
2764
+ const blocker = box.get(placed[at]);
2765
+ const gap = gapOf(id, placed[at]);
2766
+ const ways = [
2767
+ { dx: blocker.x + blocker.w + gap - b.x, dy: 0, ok: cx >= 0 },
2768
+ { dx: blocker.x - gap - (b.x + b.w), dy: 0, ok: cx <= 0 },
2769
+ { dx: 0, dy: blocker.y + blocker.h + gap - b.y, ok: cy >= 0 },
2770
+ { dx: 0, dy: blocker.y - gap - (b.y + b.h), ok: cy <= 0 }
2771
+ ].filter((w) => w.ok);
2772
+ const cost = (w) => {
2773
+ const to = { x: b.x + w.dx, y: b.y + w.dy, w: b.w, h: b.h };
2774
+ let hit = 0;
2775
+ for (const n of siblings) if (n.id !== id && n.id !== grownId && hits(to, box.get(n.id), 0)) hit++;
2776
+ return Math.abs(w.dx) + Math.abs(w.dy) + HIT_COST * hit;
2777
+ };
2778
+ const way = ways.reduce((best, w) => cost(w) < cost(best) ? w : best);
2779
+ b.x += way.dx;
2780
+ b.y += way.dy;
2781
+ moved.add(id);
2782
+ }
2783
+ placed.push(id);
2784
+ }
2785
+ const result = {};
2786
+ for (const n of siblings) {
2787
+ const b = box.get(n.id);
2788
+ if (n.id !== grownId && (b.x !== n.x || b.y !== n.y)) result[n.id] = { x: b.x, y: b.y };
2789
+ }
2790
+ return result;
2791
+ }
2792
+ function freeSpotNear(taken, size, center, gap = 60) {
2793
+ const fits = (x, y) => taken.every((b) => x + size.width + gap <= b.x || b.x + b.width + gap <= x || y + size.height + gap <= b.y || b.y + b.height + gap <= y);
2794
+ const start = { x: center.x - size.width / 2, y: center.y - size.height / 2 };
2795
+ const step = 80;
2796
+ for (let ring = 0; ring <= 40; ring++) {
2797
+ const spots = [];
2798
+ if (ring === 0) spots.push(start);
2799
+ for (let k = -ring; k <= ring && ring > 0; k++) {
2800
+ spots.push({ x: start.x + k * step, y: start.y - ring * step }, { x: start.x + k * step, y: start.y + ring * step });
2801
+ if (k !== -ring && k !== ring) spots.push({ x: start.x - ring * step, y: start.y + k * step }, { x: start.x + ring * step, y: start.y + k * step });
2802
+ }
2803
+ spots.sort((a, b) => Math.hypot(a.x - start.x, a.y - start.y) - Math.hypot(b.x - start.x, b.y - start.y));
2804
+ for (const s of spots) if (fits(s.x, s.y)) return s;
2805
+ }
2806
+ const right = taken.length ? Math.max(...taken.map((b) => b.x + b.width)) : start.x;
2807
+ return { x: right + gap, y: start.y };
2808
+ }
2236
2809
  var BATCH_CELL = { width: 360, height: 280 };
2237
2810
  var BATCH_GAP = 120;
2238
2811
  function createBatchPlacer(getNodes, visible = () => void 0) {
@@ -2292,6 +2865,7 @@ function projectToVisibleGraph(nodes, relations) {
2292
2865
  if (kept) {
2293
2866
  if (r.label) projected[kept] = { ...projected[kept], label: projected[kept].label ? `${projected[kept].label}
2294
2867
  ${r.label}` : r.label };
2868
+ if (projected[kept].technology !== r.technology) projected[kept] = { ...projected[kept], technology: void 0 };
2295
2869
  continue;
2296
2870
  }
2297
2871
  rolledUpLine.set(key, id);
@@ -2474,6 +3048,7 @@ async function applyElkLayout(inputNodes, inputRelations, opts) {
2474
3048
  elkNodeMap["root"] = root;
2475
3049
  for (const rel of Object.values(c4Relations)) {
2476
3050
  if (!c4Nodes[rel.sourceId] || !c4Nodes[rel.targetId]) continue;
3051
+ if (ancestorChain(rel.sourceId, c4Nodes).includes(rel.targetId) || ancestorChain(rel.targetId, c4Nodes).includes(rel.sourceId)) continue;
2477
3052
  const lca = lcaContainerId(rel.sourceId, rel.targetId, c4Nodes);
2478
3053
  const container = (lca ? elkNodeMap[lca] : root) ?? root;
2479
3054
  const edge = { id: rel.id, sources: [rel.sourceId], targets: [rel.targetId] };
@@ -2543,35 +3118,61 @@ async function applyTreeLayout(c4Nodes, c4Relations) {
2543
3118
  export {
2544
3119
  __commonJS,
2545
3120
  __toESM,
3121
+ init_define_RADICAL_BUILD,
3122
+ define_RADICAL_BUILD_default,
2546
3123
  isRelationAllowed,
2547
3124
  inferRelationType,
2548
3125
  isParentAllowed,
3126
+ allowedPlacesText,
2549
3127
  GROUP_TYPE,
2550
3128
  placeOf,
2551
3129
  hasPlaceUnder,
3130
+ isFinalState,
2552
3131
  isPlacementAllowed,
2553
3132
  canAddMoreOfType,
2554
3133
  isReservedPropertyKey,
2555
3134
  propertyKeyProblem,
3135
+ chainTypeNames,
3136
+ refIds,
2556
3137
  refValue,
2557
3138
  refProblem,
2558
3139
  transitionLabel,
2559
3140
  requirementStatePhrase,
3141
+ transitionRefusal,
3142
+ lifecycleRefusal,
3143
+ initialPseudostateRefusal,
3144
+ newPseudostateKind,
3145
+ isInitialPseudostate,
3146
+ outgoingTransitionCount,
2560
3147
  validateModel,
3148
+ relationTypeName,
2561
3149
  composeEarsSentence,
2562
3150
  builtInC4Metamodel,
3151
+ RADICAL_METAMODEL_NAME,
2563
3152
  builtInGovernanceMetamodel,
3153
+ layoutRoleOf,
3154
+ relationLayoutHint,
3155
+ LAYOUT_ROLES,
3156
+ LAYOUT_FLOWS,
3157
+ LAYOUT_AXES,
2564
3158
  isContainerType,
3159
+ isBackwardStep,
3160
+ trimStepBackward,
2565
3161
  pinnedNodeIds,
2566
3162
  defaultGridColumns,
2567
3163
  landscapeGridColumns,
2568
3164
  gridCells,
2569
3165
  constraintLines,
3166
+ slideWithoutMilestone,
2570
3167
  NODE_SIZES,
3168
+ nodeTypeSize,
2571
3169
  COLLAPSED_HEIGHT,
2572
3170
  COLLAPSED_WIDTH,
2573
3171
  normalizeViewFolder,
3172
+ viewFolderPaths,
3173
+ WIKI_DEPTH_MAX,
2574
3174
  wikiDepthOf,
3175
+ holderOf,
2575
3176
  viewShowsEveryNode,
2576
3177
  viewCanvasPositions,
2577
3178
  withCanvasPositions,
@@ -2583,8 +3184,13 @@ export {
2583
3184
  isVisible,
2584
3185
  compoundPadding,
2585
3186
  fittedParentSize,
2586
- fitAncestors,
2587
3187
  placeNewNode,
3188
+ modelCanvas,
3189
+ settleMovedNodes,
3190
+ growWithRoom,
3191
+ growFrameLeftUp,
3192
+ fitShown,
3193
+ makeRoomAround,
2588
3194
  createBatchPlacer,
2589
3195
  projectToVisibleGraph,
2590
3196
  ELK_ROOT_SPACING,