@principal-ai/principal-view-core 0.5.6

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 (204) hide show
  1. package/README.md +126 -0
  2. package/dist/ConfigurationLoader.d.ts +76 -0
  3. package/dist/ConfigurationLoader.d.ts.map +1 -0
  4. package/dist/ConfigurationLoader.js +144 -0
  5. package/dist/ConfigurationLoader.js.map +1 -0
  6. package/dist/ConfigurationValidator.d.ts +31 -0
  7. package/dist/ConfigurationValidator.d.ts.map +1 -0
  8. package/dist/ConfigurationValidator.js +242 -0
  9. package/dist/ConfigurationValidator.js.map +1 -0
  10. package/dist/EventProcessor.d.ts +49 -0
  11. package/dist/EventProcessor.d.ts.map +1 -0
  12. package/dist/EventProcessor.js +215 -0
  13. package/dist/EventProcessor.js.map +1 -0
  14. package/dist/EventRecorderService.d.ts +305 -0
  15. package/dist/EventRecorderService.d.ts.map +1 -0
  16. package/dist/EventRecorderService.js +463 -0
  17. package/dist/EventRecorderService.js.map +1 -0
  18. package/dist/LibraryLoader.d.ts +63 -0
  19. package/dist/LibraryLoader.d.ts.map +1 -0
  20. package/dist/LibraryLoader.js +188 -0
  21. package/dist/LibraryLoader.js.map +1 -0
  22. package/dist/PathBasedEventProcessor.d.ts +90 -0
  23. package/dist/PathBasedEventProcessor.d.ts.map +1 -0
  24. package/dist/PathBasedEventProcessor.js +239 -0
  25. package/dist/PathBasedEventProcessor.js.map +1 -0
  26. package/dist/SessionManager.d.ts +194 -0
  27. package/dist/SessionManager.d.ts.map +1 -0
  28. package/dist/SessionManager.js +299 -0
  29. package/dist/SessionManager.js.map +1 -0
  30. package/dist/ValidationEngine.d.ts +31 -0
  31. package/dist/ValidationEngine.d.ts.map +1 -0
  32. package/dist/ValidationEngine.js +158 -0
  33. package/dist/ValidationEngine.js.map +1 -0
  34. package/dist/helpers/GraphInstrumentationHelper.d.ts +93 -0
  35. package/dist/helpers/GraphInstrumentationHelper.d.ts.map +1 -0
  36. package/dist/helpers/GraphInstrumentationHelper.js +248 -0
  37. package/dist/helpers/GraphInstrumentationHelper.js.map +1 -0
  38. package/dist/index.d.ts +33 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +34 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/rules/config.d.ts +57 -0
  43. package/dist/rules/config.d.ts.map +1 -0
  44. package/dist/rules/config.js +382 -0
  45. package/dist/rules/config.js.map +1 -0
  46. package/dist/rules/engine.d.ts +70 -0
  47. package/dist/rules/engine.d.ts.map +1 -0
  48. package/dist/rules/engine.js +252 -0
  49. package/dist/rules/engine.js.map +1 -0
  50. package/dist/rules/implementations/connection-type-references.d.ts +7 -0
  51. package/dist/rules/implementations/connection-type-references.d.ts.map +1 -0
  52. package/dist/rules/implementations/connection-type-references.js +104 -0
  53. package/dist/rules/implementations/connection-type-references.js.map +1 -0
  54. package/dist/rules/implementations/dead-end-states.d.ts +17 -0
  55. package/dist/rules/implementations/dead-end-states.d.ts.map +1 -0
  56. package/dist/rules/implementations/dead-end-states.js +72 -0
  57. package/dist/rules/implementations/dead-end-states.js.map +1 -0
  58. package/dist/rules/implementations/index.d.ts +24 -0
  59. package/dist/rules/implementations/index.d.ts.map +1 -0
  60. package/dist/rules/implementations/index.js +62 -0
  61. package/dist/rules/implementations/index.js.map +1 -0
  62. package/dist/rules/implementations/library-node-type-match.d.ts +17 -0
  63. package/dist/rules/implementations/library-node-type-match.d.ts.map +1 -0
  64. package/dist/rules/implementations/library-node-type-match.js +123 -0
  65. package/dist/rules/implementations/library-node-type-match.js.map +1 -0
  66. package/dist/rules/implementations/minimum-node-sources.d.ts +22 -0
  67. package/dist/rules/implementations/minimum-node-sources.d.ts.map +1 -0
  68. package/dist/rules/implementations/minimum-node-sources.js +54 -0
  69. package/dist/rules/implementations/minimum-node-sources.js.map +1 -0
  70. package/dist/rules/implementations/no-unknown-fields.d.ts +7 -0
  71. package/dist/rules/implementations/no-unknown-fields.d.ts.map +1 -0
  72. package/dist/rules/implementations/no-unknown-fields.js +211 -0
  73. package/dist/rules/implementations/no-unknown-fields.js.map +1 -0
  74. package/dist/rules/implementations/orphaned-edge-types.d.ts +7 -0
  75. package/dist/rules/implementations/orphaned-edge-types.d.ts.map +1 -0
  76. package/dist/rules/implementations/orphaned-edge-types.js +47 -0
  77. package/dist/rules/implementations/orphaned-edge-types.js.map +1 -0
  78. package/dist/rules/implementations/orphaned-node-types.d.ts +7 -0
  79. package/dist/rules/implementations/orphaned-node-types.d.ts.map +1 -0
  80. package/dist/rules/implementations/orphaned-node-types.js +50 -0
  81. package/dist/rules/implementations/orphaned-node-types.js.map +1 -0
  82. package/dist/rules/implementations/required-metadata.d.ts +7 -0
  83. package/dist/rules/implementations/required-metadata.d.ts.map +1 -0
  84. package/dist/rules/implementations/required-metadata.js +57 -0
  85. package/dist/rules/implementations/required-metadata.js.map +1 -0
  86. package/dist/rules/implementations/state-transition-references.d.ts +7 -0
  87. package/dist/rules/implementations/state-transition-references.d.ts.map +1 -0
  88. package/dist/rules/implementations/state-transition-references.js +135 -0
  89. package/dist/rules/implementations/state-transition-references.js.map +1 -0
  90. package/dist/rules/implementations/unreachable-states.d.ts +7 -0
  91. package/dist/rules/implementations/unreachable-states.d.ts.map +1 -0
  92. package/dist/rules/implementations/unreachable-states.js +80 -0
  93. package/dist/rules/implementations/unreachable-states.js.map +1 -0
  94. package/dist/rules/implementations/valid-action-patterns.d.ts +17 -0
  95. package/dist/rules/implementations/valid-action-patterns.d.ts.map +1 -0
  96. package/dist/rules/implementations/valid-action-patterns.js +109 -0
  97. package/dist/rules/implementations/valid-action-patterns.js.map +1 -0
  98. package/dist/rules/implementations/valid-color-format.d.ts +7 -0
  99. package/dist/rules/implementations/valid-color-format.d.ts.map +1 -0
  100. package/dist/rules/implementations/valid-color-format.js +91 -0
  101. package/dist/rules/implementations/valid-color-format.js.map +1 -0
  102. package/dist/rules/implementations/valid-edge-types.d.ts +7 -0
  103. package/dist/rules/implementations/valid-edge-types.d.ts.map +1 -0
  104. package/dist/rules/implementations/valid-edge-types.js +244 -0
  105. package/dist/rules/implementations/valid-edge-types.js.map +1 -0
  106. package/dist/rules/implementations/valid-node-types.d.ts +7 -0
  107. package/dist/rules/implementations/valid-node-types.d.ts.map +1 -0
  108. package/dist/rules/implementations/valid-node-types.js +175 -0
  109. package/dist/rules/implementations/valid-node-types.js.map +1 -0
  110. package/dist/rules/index.d.ts +28 -0
  111. package/dist/rules/index.d.ts.map +1 -0
  112. package/dist/rules/index.js +45 -0
  113. package/dist/rules/index.js.map +1 -0
  114. package/dist/rules/types.d.ts +309 -0
  115. package/dist/rules/types.d.ts.map +1 -0
  116. package/dist/rules/types.js +35 -0
  117. package/dist/rules/types.js.map +1 -0
  118. package/dist/types/canvas.d.ts +409 -0
  119. package/dist/types/canvas.d.ts.map +1 -0
  120. package/dist/types/canvas.js +70 -0
  121. package/dist/types/canvas.js.map +1 -0
  122. package/dist/types/index.d.ts +311 -0
  123. package/dist/types/index.d.ts.map +1 -0
  124. package/dist/types/index.js +13 -0
  125. package/dist/types/index.js.map +1 -0
  126. package/dist/types/library.d.ts +185 -0
  127. package/dist/types/library.d.ts.map +1 -0
  128. package/dist/types/library.js +15 -0
  129. package/dist/types/library.js.map +1 -0
  130. package/dist/types/path-based-config.d.ts +230 -0
  131. package/dist/types/path-based-config.d.ts.map +1 -0
  132. package/dist/types/path-based-config.js +9 -0
  133. package/dist/types/path-based-config.js.map +1 -0
  134. package/dist/utils/CanvasConverter.d.ts +118 -0
  135. package/dist/utils/CanvasConverter.d.ts.map +1 -0
  136. package/dist/utils/CanvasConverter.js +315 -0
  137. package/dist/utils/CanvasConverter.js.map +1 -0
  138. package/dist/utils/GraphConverter.d.ts +18 -0
  139. package/dist/utils/GraphConverter.d.ts.map +1 -0
  140. package/dist/utils/GraphConverter.js +61 -0
  141. package/dist/utils/GraphConverter.js.map +1 -0
  142. package/dist/utils/LibraryConverter.d.ts +113 -0
  143. package/dist/utils/LibraryConverter.d.ts.map +1 -0
  144. package/dist/utils/LibraryConverter.js +166 -0
  145. package/dist/utils/LibraryConverter.js.map +1 -0
  146. package/dist/utils/PathMatcher.d.ts +55 -0
  147. package/dist/utils/PathMatcher.d.ts.map +1 -0
  148. package/dist/utils/PathMatcher.js +172 -0
  149. package/dist/utils/PathMatcher.js.map +1 -0
  150. package/dist/utils/YamlParser.d.ts +36 -0
  151. package/dist/utils/YamlParser.d.ts.map +1 -0
  152. package/dist/utils/YamlParser.js +63 -0
  153. package/dist/utils/YamlParser.js.map +1 -0
  154. package/package.json +47 -0
  155. package/src/ConfigurationLoader.test.ts +490 -0
  156. package/src/ConfigurationLoader.ts +185 -0
  157. package/src/ConfigurationValidator.test.ts +200 -0
  158. package/src/ConfigurationValidator.ts +283 -0
  159. package/src/EventProcessor.test.ts +405 -0
  160. package/src/EventProcessor.ts +250 -0
  161. package/src/EventRecorderService.test.ts +541 -0
  162. package/src/EventRecorderService.ts +744 -0
  163. package/src/LibraryLoader.ts +215 -0
  164. package/src/PathBasedEventProcessor.test.ts +567 -0
  165. package/src/PathBasedEventProcessor.ts +332 -0
  166. package/src/SessionManager.test.ts +424 -0
  167. package/src/SessionManager.ts +470 -0
  168. package/src/ValidationEngine.test.ts +371 -0
  169. package/src/ValidationEngine.ts +196 -0
  170. package/src/helpers/GraphInstrumentationHelper.test.ts +340 -0
  171. package/src/helpers/GraphInstrumentationHelper.ts +326 -0
  172. package/src/index.ts +85 -0
  173. package/src/rules/config.test.ts +278 -0
  174. package/src/rules/config.ts +459 -0
  175. package/src/rules/engine.test.ts +332 -0
  176. package/src/rules/engine.ts +318 -0
  177. package/src/rules/implementations/connection-type-references.ts +117 -0
  178. package/src/rules/implementations/dead-end-states.ts +101 -0
  179. package/src/rules/implementations/index.ts +73 -0
  180. package/src/rules/implementations/library-node-type-match.ts +148 -0
  181. package/src/rules/implementations/minimum-node-sources.ts +82 -0
  182. package/src/rules/implementations/no-unknown-fields.ts +342 -0
  183. package/src/rules/implementations/orphaned-edge-types.ts +55 -0
  184. package/src/rules/implementations/orphaned-node-types.ts +58 -0
  185. package/src/rules/implementations/required-metadata.ts +64 -0
  186. package/src/rules/implementations/state-transition-references.ts +151 -0
  187. package/src/rules/implementations/unreachable-states.ts +94 -0
  188. package/src/rules/implementations/valid-action-patterns.ts +136 -0
  189. package/src/rules/implementations/valid-color-format.ts +140 -0
  190. package/src/rules/implementations/valid-edge-types.ts +258 -0
  191. package/src/rules/implementations/valid-node-types.ts +189 -0
  192. package/src/rules/index.ts +95 -0
  193. package/src/rules/types.ts +426 -0
  194. package/src/types/canvas.ts +496 -0
  195. package/src/types/index.ts +382 -0
  196. package/src/types/library.ts +233 -0
  197. package/src/types/path-based-config.ts +281 -0
  198. package/src/utils/CanvasConverter.ts +431 -0
  199. package/src/utils/GraphConverter.test.ts +195 -0
  200. package/src/utils/GraphConverter.ts +71 -0
  201. package/src/utils/LibraryConverter.ts +245 -0
  202. package/src/utils/PathMatcher.test.ts +148 -0
  203. package/src/utils/PathMatcher.ts +183 -0
  204. package/src/utils/YamlParser.ts +75 -0
@@ -0,0 +1,252 @@
1
+ /**
2
+ * Graph Rules Engine
3
+ * Central orchestrator for configuration validation rules
4
+ */
5
+ import { normalizeSeverity } from './types';
6
+ /**
7
+ * Graph Rules Engine - validates GraphConfiguration against registered rules
8
+ */
9
+ export class GraphRulesEngine {
10
+ constructor() {
11
+ this.rules = new Map();
12
+ // Rules are registered via registerRule() or registerBuiltinRules()
13
+ }
14
+ /**
15
+ * Register a single rule
16
+ */
17
+ registerRule(rule) {
18
+ if (this.rules.has(rule.id)) {
19
+ throw new Error(`Rule "${rule.id}" is already registered`);
20
+ }
21
+ this.rules.set(rule.id, rule);
22
+ }
23
+ /**
24
+ * Register multiple rules at once
25
+ */
26
+ registerRules(rules) {
27
+ for (const rule of rules) {
28
+ this.registerRule(rule);
29
+ }
30
+ }
31
+ /**
32
+ * Unregister a rule by ID
33
+ */
34
+ unregisterRule(ruleId) {
35
+ return this.rules.delete(ruleId);
36
+ }
37
+ /**
38
+ * Get a rule by ID
39
+ */
40
+ getRule(ruleId) {
41
+ return this.rules.get(ruleId);
42
+ }
43
+ /**
44
+ * Get all registered rules
45
+ */
46
+ getAllRules() {
47
+ return new Map(this.rules);
48
+ }
49
+ /**
50
+ * Get rules by category
51
+ */
52
+ getRulesByCategory(category) {
53
+ return Array.from(this.rules.values()).filter((rule) => rule.category === category);
54
+ }
55
+ /**
56
+ * Lint a configuration against all enabled rules
57
+ */
58
+ async lint(configuration, options) {
59
+ const violations = [];
60
+ for (const [ruleId, rule] of this.rules) {
61
+ // Check if rule should be skipped
62
+ if (!this.shouldRunRule(rule, options)) {
63
+ continue;
64
+ }
65
+ // Build context for this rule
66
+ const context = this.buildRuleContext(configuration, rule, options);
67
+ // Get effective severity
68
+ const effectiveSeverity = this.getEffectiveSeverity(rule, options);
69
+ if (effectiveSeverity === 'off') {
70
+ continue;
71
+ }
72
+ try {
73
+ // Execute rule check
74
+ const ruleViolations = await rule.check(context);
75
+ // Apply effective severity to all violations
76
+ for (const violation of ruleViolations) {
77
+ violation.severity = effectiveSeverity;
78
+ violations.push(violation);
79
+ }
80
+ }
81
+ catch (error) {
82
+ // Rule execution error - report as a violation
83
+ violations.push({
84
+ ruleId,
85
+ severity: 'error',
86
+ message: `Rule "${ruleId}" threw an error: ${error instanceof Error ? error.message : String(error)}`,
87
+ impact: 'Rule could not complete validation',
88
+ fixable: false,
89
+ });
90
+ }
91
+ }
92
+ return this.buildResult(violations);
93
+ }
94
+ /**
95
+ * Lint a configuration with VGC config file settings applied
96
+ */
97
+ async lintWithConfig(configuration, privuConfig, options) {
98
+ // Convert VGC config rules to lint options
99
+ const { ruleOptions, severityOverrides, disabledRules } = this.parsePrivuConfigRules(privuConfig.rules);
100
+ return this.lint(configuration, {
101
+ ...options,
102
+ ruleOptions,
103
+ severityOverrides,
104
+ disabledRules: [...(options?.disabledRules ?? []), ...disabledRules],
105
+ });
106
+ }
107
+ /**
108
+ * Check if a rule should run based on options
109
+ */
110
+ shouldRunRule(rule, options) {
111
+ // Check disabled rules list
112
+ if (options?.disabledRules?.includes(rule.id)) {
113
+ return false;
114
+ }
115
+ // Check enabled rules list (if specified, only run those)
116
+ if (options?.enabledRules && options.enabledRules.length > 0) {
117
+ return options.enabledRules.includes(rule.id);
118
+ }
119
+ // Check rule's default enabled state
120
+ return rule.enabled;
121
+ }
122
+ /**
123
+ * Get the effective severity for a rule
124
+ */
125
+ getEffectiveSeverity(rule, options) {
126
+ // Check for override
127
+ if (options?.severityOverrides?.has(rule.id)) {
128
+ return options.severityOverrides.get(rule.id);
129
+ }
130
+ // Use rule's default severity
131
+ return rule.severity;
132
+ }
133
+ /**
134
+ * Build the context object for a rule
135
+ */
136
+ buildRuleContext(configuration, rule, options) {
137
+ // Merge default options with provided options
138
+ const ruleSpecificOptions = options?.ruleOptions?.get(rule.id);
139
+ const mergedOptions = {
140
+ ...rule.defaultOptions,
141
+ ...ruleSpecificOptions,
142
+ };
143
+ return {
144
+ configuration,
145
+ library: options?.library,
146
+ configPath: options?.configPath,
147
+ libraryPath: options?.libraryPath,
148
+ rawContent: options?.rawContent,
149
+ options: mergedOptions,
150
+ allRuleOptions: options?.ruleOptions,
151
+ };
152
+ }
153
+ /**
154
+ * Build the final lint result from violations
155
+ */
156
+ buildResult(violations) {
157
+ const byCategory = {
158
+ schema: 0,
159
+ reference: 0,
160
+ structure: 0,
161
+ pattern: 0,
162
+ library: 0,
163
+ };
164
+ const byRule = {};
165
+ let errorCount = 0;
166
+ let warningCount = 0;
167
+ let fixableCount = 0;
168
+ for (const violation of violations) {
169
+ // Count by severity
170
+ if (violation.severity === 'error') {
171
+ errorCount++;
172
+ }
173
+ else if (violation.severity === 'warn') {
174
+ warningCount++;
175
+ }
176
+ // Count fixable
177
+ if (violation.fixable) {
178
+ fixableCount++;
179
+ }
180
+ // Count by rule
181
+ byRule[violation.ruleId] = (byRule[violation.ruleId] ?? 0) + 1;
182
+ // Count by category
183
+ const rule = this.rules.get(violation.ruleId);
184
+ if (rule) {
185
+ byCategory[rule.category]++;
186
+ }
187
+ }
188
+ return {
189
+ violations,
190
+ errorCount,
191
+ warningCount,
192
+ fixableCount,
193
+ byCategory,
194
+ byRule,
195
+ };
196
+ }
197
+ /**
198
+ * Parse VGC config rules into lint options
199
+ */
200
+ parsePrivuConfigRules(rules) {
201
+ const ruleOptions = new Map();
202
+ const severityOverrides = new Map();
203
+ const disabledRules = [];
204
+ if (!rules) {
205
+ return { ruleOptions, severityOverrides, disabledRules };
206
+ }
207
+ for (const [ruleId, config] of Object.entries(rules)) {
208
+ // Handle false (disabled)
209
+ if (config === false) {
210
+ disabledRules.push(ruleId);
211
+ continue;
212
+ }
213
+ // Handle severity shorthand
214
+ if (typeof config === 'string' || typeof config === 'number') {
215
+ const severity = normalizeSeverity(config);
216
+ if (severity === 'off') {
217
+ disabledRules.push(ruleId);
218
+ }
219
+ else {
220
+ severityOverrides.set(ruleId, severity);
221
+ }
222
+ continue;
223
+ }
224
+ // Handle full config object
225
+ const ruleConfig = config;
226
+ if (ruleConfig.severity !== undefined) {
227
+ const severity = normalizeSeverity(ruleConfig.severity);
228
+ if (severity === 'off') {
229
+ disabledRules.push(ruleId);
230
+ }
231
+ else {
232
+ severityOverrides.set(ruleId, severity);
233
+ }
234
+ }
235
+ if (ruleConfig.options) {
236
+ ruleOptions.set(ruleId, ruleConfig.options);
237
+ }
238
+ }
239
+ return { ruleOptions, severityOverrides, disabledRules };
240
+ }
241
+ }
242
+ /**
243
+ * Create a new rules engine with optional initial rules
244
+ */
245
+ export function createRulesEngine(rules) {
246
+ const engine = new GraphRulesEngine();
247
+ if (rules) {
248
+ engine.registerRules(rules);
249
+ }
250
+ return engine;
251
+ }
252
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/rules/engine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,OAAO,EAAE,iBAAiB,EAAkB,MAAM,SAAS,C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AC5B,MAAM,UAAU,GAAG,MAAoB,CAAC;YAExC,IAAI,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACtC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;gBACxD,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;oBACvB,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAC7B,CAAC;qBAAM,CAAC;oBACN,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;gBAC1C,CAAC;YACH,CAAC;YAED,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;gBACvB,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAED,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,CAAC;IAC3D,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAmB;IACnD,MAAM,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;IACtC,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Rule: connection-type-references
3
+ * Ensures allowedConnections only reference existing nodeTypes and edgeTypes
4
+ */
5
+ import type { GraphRule } from '../types';
6
+ export declare const connectionTypeReferences: GraphRule;
7
+ //# sourceMappingURL=connection-type-references.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-type-references.d.ts","sourceRoot":"","sources":["../../../src/rules/implementations/connection-type-references.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAwC,MAAM,UAAU,CAAC;AAEhF,eAAO,MAAM,wBAAwB,EAAE,SAgFtC,CAAC"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Rule: connection-type-references
3
+ * Ensures allowedConnections only reference existing nodeTypes and edgeTypes
4
+ */
5
+ export const connectionTypeReferences = {
6
+ id: 'connection-type-references',
7
+ name: 'Connection Type References',
8
+ description: 'allowedConnections must reference existing nodeTypes and edgeTypes',
9
+ impact: 'Invalid references will cause connection validation to fail',
10
+ severity: 'error',
11
+ category: 'reference',
12
+ enabled: true,
13
+ fixable: false,
14
+ async check(context) {
15
+ const violations = [];
16
+ const { configuration, configPath } = context;
17
+ if (!configuration.allowedConnections || configuration.allowedConnections.length === 0) {
18
+ return violations;
19
+ }
20
+ // Get defined node and edge types
21
+ const nodeTypeIds = new Set(Object.keys(configuration.nodeTypes ?? {}));
22
+ const edgeTypeIds = new Set(Object.keys(configuration.edgeTypes ?? {}));
23
+ for (let i = 0; i < configuration.allowedConnections.length; i++) {
24
+ const connection = configuration.allowedConnections[i];
25
+ const basePath = `allowedConnections[${i}]`;
26
+ // Check 'from' references a valid nodeType
27
+ if (connection.from && !nodeTypeIds.has(connection.from)) {
28
+ const suggestion = findSimilar(connection.from, nodeTypeIds);
29
+ violations.push({
30
+ ruleId: 'connection-type-references',
31
+ severity: 'error',
32
+ file: configPath,
33
+ path: `${basePath}.from`,
34
+ message: `Connection rule references undefined nodeType "${connection.from}"`,
35
+ impact: 'This connection rule will not match any nodes',
36
+ suggestion: suggestion
37
+ ? `Did you mean "${suggestion}"?`
38
+ : `Available nodeTypes: ${[...nodeTypeIds].join(', ') || '(none defined)'}`,
39
+ fixable: false,
40
+ });
41
+ }
42
+ // Check 'to' references a valid nodeType
43
+ if (connection.to && !nodeTypeIds.has(connection.to)) {
44
+ const suggestion = findSimilar(connection.to, nodeTypeIds);
45
+ violations.push({
46
+ ruleId: 'connection-type-references',
47
+ severity: 'error',
48
+ file: configPath,
49
+ path: `${basePath}.to`,
50
+ message: `Connection rule references undefined nodeType "${connection.to}"`,
51
+ impact: 'This connection rule will not match any nodes',
52
+ suggestion: suggestion
53
+ ? `Did you mean "${suggestion}"?`
54
+ : `Available nodeTypes: ${[...nodeTypeIds].join(', ') || '(none defined)'}`,
55
+ fixable: false,
56
+ });
57
+ }
58
+ // Check 'via' references a valid edgeType
59
+ if (connection.via && !edgeTypeIds.has(connection.via)) {
60
+ const suggestion = findSimilar(connection.via, edgeTypeIds);
61
+ violations.push({
62
+ ruleId: 'connection-type-references',
63
+ severity: 'error',
64
+ file: configPath,
65
+ path: `${basePath}.via`,
66
+ message: `Connection rule references undefined edgeType "${connection.via}"`,
67
+ impact: 'This connection rule will not match any edges',
68
+ suggestion: suggestion
69
+ ? `Did you mean "${suggestion}"?`
70
+ : `Available edgeTypes: ${[...edgeTypeIds].join(', ') || '(none defined)'}`,
71
+ fixable: false,
72
+ });
73
+ }
74
+ }
75
+ return violations;
76
+ },
77
+ };
78
+ /**
79
+ * Find a similar string from a set (for "did you mean" suggestions)
80
+ */
81
+ function findSimilar(input, candidates) {
82
+ const inputLower = input.toLowerCase();
83
+ for (const candidate of candidates) {
84
+ const candidateLower = candidate.toLowerCase();
85
+ // Exact substring match
86
+ if (inputLower.includes(candidateLower) || candidateLower.includes(inputLower)) {
87
+ return candidate;
88
+ }
89
+ // Small edit distance
90
+ if (Math.abs(input.length - candidate.length) <= 2) {
91
+ let differences = 0;
92
+ const minLen = Math.min(inputLower.length, candidateLower.length);
93
+ for (let i = 0; i < minLen; i++) {
94
+ if (inputLower[i] !== candidateLower[i])
95
+ differences++;
96
+ }
97
+ differences += Math.abs(input.length - candidate.length);
98
+ if (differences <= 2)
99
+ return candidate;
100
+ }
101
+ }
102
+ return null;
103
+ }
104
+ //# sourceMappingURL=connection-type-references.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-type-references.js","sourceRoot":"","sources":["../../../src/rules/implementations/connection-type-references.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,CAAC,MAAM,wBAAwB,GAAc;IACjD,EAAE,EAAE,4BAA4B;IAChC,IAAI,EA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AAC,CAAC;oBAAE,WAAW,EAAE,CAAC;YACzD,CAAC;YACD,WAAW,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;YACzD,IAAI,WAAW,IAAI,CAAC;gBAAE,OAAO,SAAS,CAAC;QACzC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Rule: dead-end-states
3
+ * Warns when states have no exit transitions (except terminal states)
4
+ */
5
+ import type { GraphRule, RuleOptions } from '../types';
6
+ /**
7
+ * Options for dead-end-states rule
8
+ */
9
+ export interface DeadEndStatesOptions extends RuleOptions {
10
+ /**
11
+ * States that are intentionally terminal (no exits expected)
12
+ * @default ["completed", "failed", "terminated", "done", "error", "finished", "end"]
13
+ */
14
+ terminalStates: string[];
15
+ }
16
+ export declare const deadEndStates: GraphRule<DeadEndStatesOptions>;
17
+ //# sourceMappingURL=dead-end-states.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dead-end-states.d.ts","sourceRoot":"","sources":["../../../src/rules/implementations/dead-end-states.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAwC,WAAW,EAAE,MAAM,UAAU,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD;;;OAGG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAMD,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,oBAAoB,CA8EzD,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Rule: dead-end-states
3
+ * Warns when states have no exit transitions (except terminal states)
4
+ */
5
+ const DEFAULT_OPTIONS = {
6
+ terminalStates: ['completed', 'failed', 'terminated', 'done', 'error', 'finished', 'end'],
7
+ };
8
+ export const deadEndStates = {
9
+ id: 'dead-end-states',
10
+ name: 'Dead End States',
11
+ description: 'States should have exit transitions unless they are terminal states',
12
+ impact: 'Dead-end states may trap entities unexpectedly',
13
+ severity: 'error',
14
+ category: 'structure',
15
+ enabled: true,
16
+ fixable: false,
17
+ defaultOptions: DEFAULT_OPTIONS,
18
+ async check(context) {
19
+ const violations = [];
20
+ const { configuration, configPath, options } = context;
21
+ const terminalStates = new Set((options.terminalStates ?? DEFAULT_OPTIONS.terminalStates).map((s) => s.toLowerCase()));
22
+ if (!configuration.nodeTypes) {
23
+ return violations;
24
+ }
25
+ // For each nodeType with states, check if all non-terminal states have exits
26
+ for (const [typeId, nodeType] of Object.entries(configuration.nodeTypes)) {
27
+ if (!nodeType.states || Object.keys(nodeType.states).length === 0) {
28
+ continue;
29
+ }
30
+ const stateIds = Object.keys(nodeType.states);
31
+ // If there's only one state, no transitions expected
32
+ if (stateIds.length <= 1) {
33
+ continue;
34
+ }
35
+ // Get state transitions for this nodeType
36
+ const transitions = configuration.validation?.stateTransitions?.[typeId];
37
+ // Build set of states that have exit transitions
38
+ const statesWithExits = new Set();
39
+ if (transitions && Array.isArray(transitions)) {
40
+ for (const transition of transitions) {
41
+ if (transition.from) {
42
+ statesWithExits.add(transition.from);
43
+ }
44
+ }
45
+ }
46
+ // Check for dead-end states
47
+ for (const stateId of stateIds) {
48
+ // Skip if this state has exits
49
+ if (statesWithExits.has(stateId)) {
50
+ continue;
51
+ }
52
+ // Skip if this is a known terminal state
53
+ if (terminalStates.has(stateId.toLowerCase())) {
54
+ continue;
55
+ }
56
+ // This is a dead-end state
57
+ violations.push({
58
+ ruleId: 'dead-end-states',
59
+ severity: 'error',
60
+ file: configPath,
61
+ path: `nodeTypes.${typeId}.states.${stateId}`,
62
+ message: `State "${stateId}" in node type "${typeId}" has no exit transitions`,
63
+ impact: 'Entities in this state cannot transition to other states',
64
+ suggestion: `Add a transition from "${stateId}" in validation.stateTransitions.${typeId}, or mark it as a terminal state`,
65
+ fixable: false,
66
+ });
67
+ }
68
+ }
69
+ return violations;
70
+ },
71
+ };
72
+ //# sourceMappingURL=dead-end-states.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dead-end-states.js","sourceRoot":"","sources":["../../../src/rules/implementations/dead-end-states.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,MAAM,eAAe,GAAyB;IAC5C,cAAc,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC;CAC1F,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAoC;IAC5D,EAAE,EAAE,iBAAiB;IACrB,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,qEAAqE;IAClF,MAAM,EAAE,gDAAgD;IACxD,QAAQ,EAAE,OAAO;IACjB,QAAQ,EAAE,WAAW;IACrB,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,KAAK;IACd,cAAc,EAAE,eAAe;IAE/B,KAAK,CAAC,KAAK,CAAC,OAA+C;QACzD,MAAM,UAAU,GAAyB,EAAE,CAAC;QAC5C,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAEvD,MAAM,cAAc,GAAG,IAAI,GAAG,CAC5B,CAAC,OAAO,CAAC,cAAc,IAAI,eAAe,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CACvF,CAAC;QAEF,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;YAC7B,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,6EAA6E;QAC7E,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;YACzE,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,C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AkC;oBACzH,OAAO,EAAE,KAAK;iBACf,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Built-in rule implementations
3
+ */
4
+ export { requiredMetadata } from './required-metadata';
5
+ export { validNodeTypes } from './valid-node-types';
6
+ export { validEdgeTypes } from './valid-edge-types';
7
+ export { validColorFormat } from './valid-color-format';
8
+ export { noUnknownFields } from './no-unknown-fields';
9
+ export { connectionTypeReferences } from './connection-type-references';
10
+ export { stateTransitionReferences } from './state-transition-references';
11
+ export { minimumNodeSources, type MinimumNodeSourcesOptions } from './minimum-node-sources';
12
+ export { orphanedNodeTypes } from './orphaned-node-types';
13
+ export { orphanedEdgeTypes } from './orphaned-edge-types';
14
+ export { unreachableStates } from './unreachable-states';
15
+ export { deadEndStates, type DeadEndStatesOptions } from './dead-end-states';
16
+ export { validActionPatterns, type ValidActionPatternsOptions } from './valid-action-patterns';
17
+ export { libraryNodeTypeMatch, type LibraryNodeTypeMatchOptions } from './library-node-type-match';
18
+ import type { GraphRule } from '../types';
19
+ /**
20
+ * All built-in rules
21
+ * Cast to GraphRule[] since rules with specific options extend the base interface
22
+ */
23
+ export declare const builtinRules: GraphRule[];
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rules/implementations/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAG1E,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG7E,OAAO,EAAE,mBAAmB,EAAE,KAAK,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAG/F,OAAO,EAAE,oBAAoB,EAAE,KAAK,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAEnG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAgB1C;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,EAwBnC,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Built-in rule implementations
3
+ */
4
+ // Schema rules
5
+ export { requiredMetadata } from './required-metadata';
6
+ export { validNodeTypes } from './valid-node-types';
7
+ export { validEdgeTypes } from './valid-edge-types';
8
+ export { validColorFormat } from './valid-color-format';
9
+ export { noUnknownFields } from './no-unknown-fields';
10
+ // Reference rules
11
+ export { connectionTypeReferences } from './connection-type-references';
12
+ export { stateTransitionReferences } from './state-transition-references';
13
+ // Structure rules
14
+ export { minimumNodeSources } from './minimum-node-sources';
15
+ export { orphanedNodeTypes } from './orphaned-node-types';
16
+ export { orphanedEdgeTypes } from './orphaned-edge-types';
17
+ export { unreachableStates } from './unreachable-states';
18
+ export { deadEndStates } from './dead-end-states';
19
+ // Pattern rules
20
+ export { validActionPatterns } from './valid-action-patterns';
21
+ // Library rules
22
+ export { libraryNodeTypeMatch } from './library-node-type-match';
23
+ import { requiredMetadata } from './required-metadata';
24
+ import { validNodeTypes } from './valid-node-types';
25
+ import { validEdgeTypes } from './valid-edge-types';
26
+ import { validColorFormat } from './valid-color-format';
27
+ import { noUnknownFields } from './no-unknown-fields';
28
+ import { connectionTypeReferences } from './connection-type-references';
29
+ import { stateTransitionReferences } from './state-transition-references';
30
+ import { minimumNodeSources } from './minimum-node-sources';
31
+ import { orphanedNodeTypes } from './orphaned-node-types';
32
+ import { orphanedEdgeTypes } from './orphaned-edge-types';
33
+ import { unreachableStates } from './unreachable-states';
34
+ import { deadEndStates } from './dead-end-states';
35
+ import { validActionPatterns } from './valid-action-patterns';
36
+ import { libraryNodeTypeMatch } from './library-node-type-match';
37
+ /**
38
+ * All built-in rules
39
+ * Cast to GraphRule[] since rules with specific options extend the base interface
40
+ */
41
+ export const builtinRules = [
42
+ // Schema rules (5)
43
+ noUnknownFields,
44
+ requiredMetadata,
45
+ validNodeTypes,
46
+ validEdgeTypes,
47
+ validColorFormat,
48
+ // Reference rules (2)
49
+ connectionTypeReferences,
50
+ stateTransitionReferences,
51
+ // Structure rules (5)
52
+ minimumNodeSources,
53
+ orphanedNodeTypes,
54
+ orphanedEdgeTypes,
55
+ unreachableStates,
56
+ deadEndStates,
57
+ // Pattern rules (1)
58
+ validActionPatterns,
59
+ // Library rules (1)
60
+ libraryNodeTypeMatch,
61
+ ];
62
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/implementations/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAe;AACf,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,kBAAkB;AA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BAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgB;IACvC,mBAAmB;IACnB,eAAe;IACf,gBAAgB;IAChB,cAAc;IACd,cAAc;IACd,gBAAgB;IAEhB,sBAAsB;IACtB,wBAAwB;IACxB,yBAAyB;IAEzB,sBAAsB;IACtB,kBAA0C;IAC1C,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,aAAqC;IAErC,oBAAoB;IACpB,mBAA2C;IAE3C,oBAAoB;IACpB,oBAA4C;CAC7C,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Rule: library-node-type-match
3
+ * Ensures nodeTypes match library nodeComponents when a library is provided
4
+ */
5
+ import type { GraphRule, RuleOptions } from '../types';
6
+ /**
7
+ * Options for library-node-type-match rule
8
+ */
9
+ export interface LibraryNodeTypeMatchOptions extends RuleOptions {
10
+ /**
11
+ * Allow extra nodeTypes not defined in the library
12
+ * @default false
13
+ */
14
+ allowExtra: boolean;
15
+ }
16
+ export declare const libraryNodeTypeMatch: GraphRule<LibraryNodeTypeMatchOptions>;
17
+ //# sourceMappingURL=library-node-type-match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"library-node-type-match.d.ts","sourceRoot":"","sources":["../../../src/rules/implementations/library-node-type-match.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAwC,WAAW,EAAE,MAAM,UAAU,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,WAAW;IAC9D;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB;AAMD,eAAO,MAAM,oBAAoB,EAAE,SAAS,CAAC,2BAA2B,CAgGvE,CAAC"}