@grafema/util 0.3.0-beta

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 (324) hide show
  1. package/LICENSE +190 -0
  2. package/dist/api/GraphAPI.d.ts +87 -0
  3. package/dist/api/GraphAPI.d.ts.map +1 -0
  4. package/dist/api/GraphAPI.js +212 -0
  5. package/dist/api/GraphAPI.js.map +1 -0
  6. package/dist/api/GuaranteeAPI.d.ts +147 -0
  7. package/dist/api/GuaranteeAPI.d.ts.map +1 -0
  8. package/dist/api/GuaranteeAPI.js +290 -0
  9. package/dist/api/GuaranteeAPI.js.map +1 -0
  10. package/dist/config/ConfigLoader.d.ts +214 -0
  11. package/dist/config/ConfigLoader.d.ts.map +1 -0
  12. package/dist/config/ConfigLoader.js +441 -0
  13. package/dist/config/ConfigLoader.js.map +1 -0
  14. package/dist/config/index.d.ts +6 -0
  15. package/dist/config/index.d.ts.map +1 -0
  16. package/dist/config/index.js +5 -0
  17. package/dist/config/index.js.map +1 -0
  18. package/dist/core/CoverageAnalyzer.d.ts +65 -0
  19. package/dist/core/CoverageAnalyzer.d.ts.map +1 -0
  20. package/dist/core/CoverageAnalyzer.js +199 -0
  21. package/dist/core/CoverageAnalyzer.js.map +1 -0
  22. package/dist/core/FileExplainer.d.ts +101 -0
  23. package/dist/core/FileExplainer.d.ts.map +1 -0
  24. package/dist/core/FileExplainer.js +140 -0
  25. package/dist/core/FileExplainer.js.map +1 -0
  26. package/dist/core/FileOverview.d.ts +124 -0
  27. package/dist/core/FileOverview.d.ts.map +1 -0
  28. package/dist/core/FileOverview.js +279 -0
  29. package/dist/core/FileOverview.js.map +1 -0
  30. package/dist/core/GrafemaUri.d.ts +66 -0
  31. package/dist/core/GrafemaUri.d.ts.map +1 -0
  32. package/dist/core/GrafemaUri.js +191 -0
  33. package/dist/core/GrafemaUri.js.map +1 -0
  34. package/dist/core/GraphBackend.d.ts +158 -0
  35. package/dist/core/GraphBackend.d.ts.map +1 -0
  36. package/dist/core/GraphBackend.js +85 -0
  37. package/dist/core/GraphBackend.js.map +1 -0
  38. package/dist/core/GraphFreshnessChecker.d.ts +33 -0
  39. package/dist/core/GraphFreshnessChecker.d.ts.map +1 -0
  40. package/dist/core/GraphFreshnessChecker.js +104 -0
  41. package/dist/core/GraphFreshnessChecker.js.map +1 -0
  42. package/dist/core/GuaranteeManager.d.ts +254 -0
  43. package/dist/core/GuaranteeManager.d.ts.map +1 -0
  44. package/dist/core/GuaranteeManager.js +447 -0
  45. package/dist/core/GuaranteeManager.js.map +1 -0
  46. package/dist/core/HashUtils.d.ts +24 -0
  47. package/dist/core/HashUtils.d.ts.map +1 -0
  48. package/dist/core/HashUtils.js +46 -0
  49. package/dist/core/HashUtils.js.map +1 -0
  50. package/dist/core/IncrementalReanalyzer.d.ts +33 -0
  51. package/dist/core/IncrementalReanalyzer.d.ts.map +1 -0
  52. package/dist/core/IncrementalReanalyzer.js +67 -0
  53. package/dist/core/IncrementalReanalyzer.js.map +1 -0
  54. package/dist/core/ResourceRegistry.d.ts +17 -0
  55. package/dist/core/ResourceRegistry.d.ts.map +1 -0
  56. package/dist/core/ResourceRegistry.js +32 -0
  57. package/dist/core/ResourceRegistry.js.map +1 -0
  58. package/dist/core/SemanticId.d.ts +159 -0
  59. package/dist/core/SemanticId.d.ts.map +1 -0
  60. package/dist/core/SemanticId.js +291 -0
  61. package/dist/core/SemanticId.js.map +1 -0
  62. package/dist/core/VersionManager.d.ts +166 -0
  63. package/dist/core/VersionManager.d.ts.map +1 -0
  64. package/dist/core/VersionManager.js +239 -0
  65. package/dist/core/VersionManager.js.map +1 -0
  66. package/dist/core/brandNodeInternal.d.ts +14 -0
  67. package/dist/core/brandNodeInternal.d.ts.map +1 -0
  68. package/dist/core/brandNodeInternal.js +4 -0
  69. package/dist/core/brandNodeInternal.js.map +1 -0
  70. package/dist/core/nodes/GuaranteeNode.d.ts +76 -0
  71. package/dist/core/nodes/GuaranteeNode.d.ts.map +1 -0
  72. package/dist/core/nodes/GuaranteeNode.js +118 -0
  73. package/dist/core/nodes/GuaranteeNode.js.map +1 -0
  74. package/dist/core/nodes/IssueNode.d.ts +73 -0
  75. package/dist/core/nodes/IssueNode.d.ts.map +1 -0
  76. package/dist/core/nodes/IssueNode.js +130 -0
  77. package/dist/core/nodes/IssueNode.js.map +1 -0
  78. package/dist/core/nodes/NodeKind.d.ts +104 -0
  79. package/dist/core/nodes/NodeKind.d.ts.map +1 -0
  80. package/dist/core/nodes/NodeKind.js +166 -0
  81. package/dist/core/nodes/NodeKind.js.map +1 -0
  82. package/dist/diagnostics/DiagnosticCollector.d.ts +103 -0
  83. package/dist/diagnostics/DiagnosticCollector.d.ts.map +1 -0
  84. package/dist/diagnostics/DiagnosticCollector.js +133 -0
  85. package/dist/diagnostics/DiagnosticCollector.js.map +1 -0
  86. package/dist/diagnostics/DiagnosticReporter.d.ts +122 -0
  87. package/dist/diagnostics/DiagnosticReporter.d.ts.map +1 -0
  88. package/dist/diagnostics/DiagnosticReporter.js +300 -0
  89. package/dist/diagnostics/DiagnosticReporter.js.map +1 -0
  90. package/dist/diagnostics/DiagnosticWriter.d.ts +31 -0
  91. package/dist/diagnostics/DiagnosticWriter.d.ts.map +1 -0
  92. package/dist/diagnostics/DiagnosticWriter.js +44 -0
  93. package/dist/diagnostics/DiagnosticWriter.js.map +1 -0
  94. package/dist/diagnostics/categories.d.ts +57 -0
  95. package/dist/diagnostics/categories.d.ts.map +1 -0
  96. package/dist/diagnostics/categories.js +71 -0
  97. package/dist/diagnostics/categories.js.map +1 -0
  98. package/dist/diagnostics/index.d.ts +17 -0
  99. package/dist/diagnostics/index.d.ts.map +1 -0
  100. package/dist/diagnostics/index.js +15 -0
  101. package/dist/diagnostics/index.js.map +1 -0
  102. package/dist/errors/GrafemaError.d.ts +200 -0
  103. package/dist/errors/GrafemaError.d.ts.map +1 -0
  104. package/dist/errors/GrafemaError.js +209 -0
  105. package/dist/errors/GrafemaError.js.map +1 -0
  106. package/dist/index.d.ts +75 -0
  107. package/dist/index.d.ts.map +1 -0
  108. package/dist/index.js +76 -0
  109. package/dist/index.js.map +1 -0
  110. package/dist/instructions/index.d.ts +8 -0
  111. package/dist/instructions/index.d.ts.map +1 -0
  112. package/dist/instructions/index.js +20 -0
  113. package/dist/instructions/index.js.map +1 -0
  114. package/dist/instructions/onboarding.md +133 -0
  115. package/dist/knowledge/KnowledgeBase.d.ts +113 -0
  116. package/dist/knowledge/KnowledgeBase.d.ts.map +1 -0
  117. package/dist/knowledge/KnowledgeBase.js +420 -0
  118. package/dist/knowledge/KnowledgeBase.js.map +1 -0
  119. package/dist/knowledge/SemanticAddressResolver.d.ts +59 -0
  120. package/dist/knowledge/SemanticAddressResolver.d.ts.map +1 -0
  121. package/dist/knowledge/SemanticAddressResolver.js +160 -0
  122. package/dist/knowledge/SemanticAddressResolver.js.map +1 -0
  123. package/dist/knowledge/git-ingest.d.ts +58 -0
  124. package/dist/knowledge/git-ingest.d.ts.map +1 -0
  125. package/dist/knowledge/git-ingest.js +301 -0
  126. package/dist/knowledge/git-ingest.js.map +1 -0
  127. package/dist/knowledge/git-queries.d.ts +86 -0
  128. package/dist/knowledge/git-queries.d.ts.map +1 -0
  129. package/dist/knowledge/git-queries.js +177 -0
  130. package/dist/knowledge/git-queries.js.map +1 -0
  131. package/dist/knowledge/index.d.ts +14 -0
  132. package/dist/knowledge/index.d.ts.map +1 -0
  133. package/dist/knowledge/index.js +10 -0
  134. package/dist/knowledge/index.js.map +1 -0
  135. package/dist/knowledge/parser.d.ts +39 -0
  136. package/dist/knowledge/parser.d.ts.map +1 -0
  137. package/dist/knowledge/parser.js +292 -0
  138. package/dist/knowledge/parser.js.map +1 -0
  139. package/dist/knowledge/types.d.ts +133 -0
  140. package/dist/knowledge/types.d.ts.map +1 -0
  141. package/dist/knowledge/types.js +8 -0
  142. package/dist/knowledge/types.js.map +1 -0
  143. package/dist/logging/Logger.d.ts +98 -0
  144. package/dist/logging/Logger.d.ts.map +1 -0
  145. package/dist/logging/Logger.js +274 -0
  146. package/dist/logging/Logger.js.map +1 -0
  147. package/dist/notation/archetypes.d.ts +36 -0
  148. package/dist/notation/archetypes.d.ts.map +1 -0
  149. package/dist/notation/archetypes.js +173 -0
  150. package/dist/notation/archetypes.js.map +1 -0
  151. package/dist/notation/fold.d.ts +25 -0
  152. package/dist/notation/fold.d.ts.map +1 -0
  153. package/dist/notation/fold.js +598 -0
  154. package/dist/notation/fold.js.map +1 -0
  155. package/dist/notation/index.d.ts +18 -0
  156. package/dist/notation/index.d.ts.map +1 -0
  157. package/dist/notation/index.js +16 -0
  158. package/dist/notation/index.js.map +1 -0
  159. package/dist/notation/lodExtractor.d.ts +32 -0
  160. package/dist/notation/lodExtractor.d.ts.map +1 -0
  161. package/dist/notation/lodExtractor.js +149 -0
  162. package/dist/notation/lodExtractor.js.map +1 -0
  163. package/dist/notation/nameShortener.d.ts +22 -0
  164. package/dist/notation/nameShortener.d.ts.map +1 -0
  165. package/dist/notation/nameShortener.js +24 -0
  166. package/dist/notation/nameShortener.js.map +1 -0
  167. package/dist/notation/perspectives.d.ts +11 -0
  168. package/dist/notation/perspectives.d.ts.map +1 -0
  169. package/dist/notation/perspectives.js +16 -0
  170. package/dist/notation/perspectives.js.map +1 -0
  171. package/dist/notation/renderer.d.ts +31 -0
  172. package/dist/notation/renderer.d.ts.map +1 -0
  173. package/dist/notation/renderer.js +315 -0
  174. package/dist/notation/renderer.js.map +1 -0
  175. package/dist/notation/traceRenderer.d.ts +39 -0
  176. package/dist/notation/traceRenderer.d.ts.map +1 -0
  177. package/dist/notation/traceRenderer.js +358 -0
  178. package/dist/notation/traceRenderer.js.map +1 -0
  179. package/dist/notation/types.d.ts +66 -0
  180. package/dist/notation/types.d.ts.map +1 -0
  181. package/dist/notation/types.js +10 -0
  182. package/dist/notation/types.js.map +1 -0
  183. package/dist/queries/NodeContext.d.ts +81 -0
  184. package/dist/queries/NodeContext.d.ts.map +1 -0
  185. package/dist/queries/NodeContext.js +196 -0
  186. package/dist/queries/NodeContext.js.map +1 -0
  187. package/dist/queries/findCallsInFunction.d.ts +62 -0
  188. package/dist/queries/findCallsInFunction.d.ts.map +1 -0
  189. package/dist/queries/findCallsInFunction.js +169 -0
  190. package/dist/queries/findCallsInFunction.js.map +1 -0
  191. package/dist/queries/findContainingFunction.d.ts +57 -0
  192. package/dist/queries/findContainingFunction.d.ts.map +1 -0
  193. package/dist/queries/findContainingFunction.js +91 -0
  194. package/dist/queries/findContainingFunction.js.map +1 -0
  195. package/dist/queries/index.d.ts +18 -0
  196. package/dist/queries/index.d.ts.map +1 -0
  197. package/dist/queries/index.js +14 -0
  198. package/dist/queries/index.js.map +1 -0
  199. package/dist/queries/traceDataflow.d.ts +65 -0
  200. package/dist/queries/traceDataflow.d.ts.map +1 -0
  201. package/dist/queries/traceDataflow.js +754 -0
  202. package/dist/queries/traceDataflow.js.map +1 -0
  203. package/dist/queries/traceValues.d.ts +70 -0
  204. package/dist/queries/traceValues.d.ts.map +1 -0
  205. package/dist/queries/traceValues.js +373 -0
  206. package/dist/queries/traceValues.js.map +1 -0
  207. package/dist/queries/types.d.ts +166 -0
  208. package/dist/queries/types.d.ts.map +1 -0
  209. package/dist/queries/types.js +10 -0
  210. package/dist/queries/types.js.map +1 -0
  211. package/dist/schema/GraphSchemaExtractor.d.ts +53 -0
  212. package/dist/schema/GraphSchemaExtractor.d.ts.map +1 -0
  213. package/dist/schema/GraphSchemaExtractor.js +125 -0
  214. package/dist/schema/GraphSchemaExtractor.js.map +1 -0
  215. package/dist/schema/InterfaceSchemaExtractor.d.ts +73 -0
  216. package/dist/schema/InterfaceSchemaExtractor.d.ts.map +1 -0
  217. package/dist/schema/InterfaceSchemaExtractor.js +113 -0
  218. package/dist/schema/InterfaceSchemaExtractor.js.map +1 -0
  219. package/dist/schema/index.d.ts +5 -0
  220. package/dist/schema/index.d.ts.map +1 -0
  221. package/dist/schema/index.js +3 -0
  222. package/dist/schema/index.js.map +1 -0
  223. package/dist/storage/backends/RFDBServerBackend.d.ts +356 -0
  224. package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -0
  225. package/dist/storage/backends/RFDBServerBackend.js +748 -0
  226. package/dist/storage/backends/RFDBServerBackend.js.map +1 -0
  227. package/dist/storage/backends/typeValidation.d.ts +47 -0
  228. package/dist/storage/backends/typeValidation.d.ts.map +1 -0
  229. package/dist/storage/backends/typeValidation.js +141 -0
  230. package/dist/storage/backends/typeValidation.js.map +1 -0
  231. package/dist/utils/findRfdbBinary.d.ts +67 -0
  232. package/dist/utils/findRfdbBinary.d.ts.map +1 -0
  233. package/dist/utils/findRfdbBinary.js +261 -0
  234. package/dist/utils/findRfdbBinary.js.map +1 -0
  235. package/dist/utils/lazyDownload.d.ts +43 -0
  236. package/dist/utils/lazyDownload.d.ts.map +1 -0
  237. package/dist/utils/lazyDownload.js +175 -0
  238. package/dist/utils/lazyDownload.js.map +1 -0
  239. package/dist/utils/moduleResolution.d.ts +134 -0
  240. package/dist/utils/moduleResolution.d.ts.map +1 -0
  241. package/dist/utils/moduleResolution.js +189 -0
  242. package/dist/utils/moduleResolution.js.map +1 -0
  243. package/dist/utils/resolveNodeFile.d.ts +13 -0
  244. package/dist/utils/resolveNodeFile.d.ts.map +1 -0
  245. package/dist/utils/resolveNodeFile.js +18 -0
  246. package/dist/utils/resolveNodeFile.js.map +1 -0
  247. package/dist/utils/startRfdbServer.d.ts +63 -0
  248. package/dist/utils/startRfdbServer.d.ts.map +1 -0
  249. package/dist/utils/startRfdbServer.js +142 -0
  250. package/dist/utils/startRfdbServer.js.map +1 -0
  251. package/dist/validation/PathValidator.d.ts +80 -0
  252. package/dist/validation/PathValidator.d.ts.map +1 -0
  253. package/dist/validation/PathValidator.js +252 -0
  254. package/dist/validation/PathValidator.js.map +1 -0
  255. package/dist/version.d.ts +11 -0
  256. package/dist/version.d.ts.map +1 -0
  257. package/dist/version.js +26 -0
  258. package/dist/version.js.map +1 -0
  259. package/package.json +50 -0
  260. package/src/api/GraphAPI.ts +307 -0
  261. package/src/api/GuaranteeAPI.ts +402 -0
  262. package/src/config/ConfigLoader.ts +653 -0
  263. package/src/config/index.ts +13 -0
  264. package/src/core/CoverageAnalyzer.ts +243 -0
  265. package/src/core/FileExplainer.ts +179 -0
  266. package/src/core/FileOverview.ts +397 -0
  267. package/src/core/GrafemaUri.ts +216 -0
  268. package/src/core/GraphBackend.ts +266 -0
  269. package/src/core/GraphFreshnessChecker.ts +145 -0
  270. package/src/core/GuaranteeManager.ts +684 -0
  271. package/src/core/HashUtils.ts +48 -0
  272. package/src/core/IncrementalReanalyzer.ts +106 -0
  273. package/src/core/ResourceRegistry.ts +39 -0
  274. package/src/core/SemanticId.ts +423 -0
  275. package/src/core/VersionManager.ts +405 -0
  276. package/src/core/brandNodeInternal.ts +16 -0
  277. package/src/core/nodes/GuaranteeNode.ts +162 -0
  278. package/src/core/nodes/IssueNode.ts +177 -0
  279. package/src/core/nodes/NodeKind.ts +192 -0
  280. package/src/diagnostics/DiagnosticCollector.ts +170 -0
  281. package/src/diagnostics/DiagnosticReporter.ts +395 -0
  282. package/src/diagnostics/DiagnosticWriter.ts +50 -0
  283. package/src/diagnostics/categories.ts +104 -0
  284. package/src/diagnostics/index.ts +30 -0
  285. package/src/errors/GrafemaError.ts +297 -0
  286. package/src/index.ts +261 -0
  287. package/src/instructions/index.ts +21 -0
  288. package/src/instructions/onboarding.md +133 -0
  289. package/src/knowledge/KnowledgeBase.ts +486 -0
  290. package/src/knowledge/SemanticAddressResolver.ts +191 -0
  291. package/src/knowledge/git-ingest.ts +402 -0
  292. package/src/knowledge/git-queries.ts +269 -0
  293. package/src/knowledge/index.ts +29 -0
  294. package/src/knowledge/parser.ts +294 -0
  295. package/src/knowledge/types.ts +146 -0
  296. package/src/logging/Logger.ts +303 -0
  297. package/src/notation/archetypes.ts +189 -0
  298. package/src/notation/fold.ts +696 -0
  299. package/src/notation/index.ts +27 -0
  300. package/src/notation/lodExtractor.ts +177 -0
  301. package/src/notation/nameShortener.ts +24 -0
  302. package/src/notation/perspectives.ts +18 -0
  303. package/src/notation/renderer.ts +394 -0
  304. package/src/notation/traceRenderer.ts +458 -0
  305. package/src/notation/types.ts +79 -0
  306. package/src/queries/NodeContext.ts +280 -0
  307. package/src/queries/findCallsInFunction.ts +249 -0
  308. package/src/queries/findContainingFunction.ts +124 -0
  309. package/src/queries/index.ts +44 -0
  310. package/src/queries/traceDataflow.ts +838 -0
  311. package/src/queries/traceValues.ts +531 -0
  312. package/src/queries/types.ts +191 -0
  313. package/src/schema/GraphSchemaExtractor.ts +177 -0
  314. package/src/schema/InterfaceSchemaExtractor.ts +173 -0
  315. package/src/schema/index.ts +5 -0
  316. package/src/storage/backends/RFDBServerBackend.ts +895 -0
  317. package/src/storage/backends/typeValidation.ts +154 -0
  318. package/src/utils/findRfdbBinary.ts +288 -0
  319. package/src/utils/lazyDownload.ts +206 -0
  320. package/src/utils/moduleResolution.ts +271 -0
  321. package/src/utils/resolveNodeFile.ts +18 -0
  322. package/src/utils/startRfdbServer.ts +197 -0
  323. package/src/validation/PathValidator.ts +334 -0
  324. package/src/version.ts +28 -0
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Diagnostic Categories - Single source of truth for category/code mappings
3
+ *
4
+ * This module defines diagnostic categories once and derives both mapping
5
+ * directions:
6
+ * - DIAGNOSTIC_CATEGORIES: category → codes (used by CLI check command)
7
+ * - CODE_TO_CATEGORY: code → category metadata (used by DiagnosticReporter)
8
+ *
9
+ * Adding a new diagnostic code requires updating only this file.
10
+ */
11
+ /**
12
+ * Category definition with human-readable metadata and associated codes
13
+ */
14
+ export interface DiagnosticCategory {
15
+ /** Human-readable name for display */
16
+ readonly name: string;
17
+ /** Description of what this category checks */
18
+ readonly description: string;
19
+ /** Diagnostic codes that belong to this category */
20
+ readonly codes: readonly string[];
21
+ }
22
+ /**
23
+ * Valid category keys
24
+ */
25
+ export type DiagnosticCategoryKey = 'connectivity' | 'calls' | 'dataflow' | 'imports';
26
+ /**
27
+ * Canonical definition of all diagnostic categories
28
+ *
29
+ * This is the SINGLE SOURCE OF TRUTH for category mappings.
30
+ * Both CLI and DiagnosticReporter derive their mappings from this.
31
+ */
32
+ export declare const DIAGNOSTIC_CATEGORIES: Record<DiagnosticCategoryKey, DiagnosticCategory>;
33
+ /**
34
+ * Metadata for code-to-category lookup (used by DiagnosticReporter)
35
+ */
36
+ export interface CodeCategoryInfo {
37
+ /** Human-readable name for the issue type */
38
+ name: string;
39
+ /** CLI command to check this category */
40
+ checkCommand: string;
41
+ }
42
+ /**
43
+ * Derived mapping: code → category metadata
44
+ *
45
+ * Auto-generated from DIAGNOSTIC_CATEGORIES.
46
+ * Used by DiagnosticReporter to show actionable commands.
47
+ */
48
+ export declare const CODE_TO_CATEGORY: Record<string, CodeCategoryInfo>;
49
+ /**
50
+ * Get category for a diagnostic code
51
+ */
52
+ export declare function getCategoryForCode(code: string): CodeCategoryInfo | undefined;
53
+ /**
54
+ * Get all codes for a category
55
+ */
56
+ export declare function getCodesForCategory(category: DiagnosticCategoryKey): readonly string[];
57
+ //# sourceMappingURL=categories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categories.d.ts","sourceRoot":"","sources":["../../src/diagnostics/categories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,cAAc,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;AAEtF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,qBAAqB,EAAE,kBAAkB,CAqBnF,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAgB1D,CAAC;AAEL;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAE7E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,SAAS,MAAM,EAAE,CAEtF"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Diagnostic Categories - Single source of truth for category/code mappings
3
+ *
4
+ * This module defines diagnostic categories once and derives both mapping
5
+ * directions:
6
+ * - DIAGNOSTIC_CATEGORIES: category → codes (used by CLI check command)
7
+ * - CODE_TO_CATEGORY: code → category metadata (used by DiagnosticReporter)
8
+ *
9
+ * Adding a new diagnostic code requires updating only this file.
10
+ */
11
+ /**
12
+ * Canonical definition of all diagnostic categories
13
+ *
14
+ * This is the SINGLE SOURCE OF TRUTH for category mappings.
15
+ * Both CLI and DiagnosticReporter derive their mappings from this.
16
+ */
17
+ export const DIAGNOSTIC_CATEGORIES = {
18
+ connectivity: {
19
+ name: 'Graph Connectivity',
20
+ description: 'Check for disconnected nodes in the graph',
21
+ codes: ['ERR_DISCONNECTED_NODES', 'ERR_DISCONNECTED_NODE'],
22
+ },
23
+ calls: {
24
+ name: 'Call Resolution',
25
+ description: 'Check for unresolved function calls',
26
+ codes: ['ERR_UNRESOLVED_CALL'],
27
+ },
28
+ dataflow: {
29
+ name: 'Data Flow',
30
+ description: 'Check for missing assignments and broken references',
31
+ codes: ['ERR_MISSING_ASSIGNMENT', 'ERR_BROKEN_REFERENCE', 'ERR_NO_LEAF_NODE'],
32
+ },
33
+ imports: {
34
+ name: 'Import Validation',
35
+ description: 'Check for broken imports and undefined symbols',
36
+ codes: ['ERR_BROKEN_IMPORT', 'ERR_UNDEFINED_SYMBOL'],
37
+ },
38
+ };
39
+ /**
40
+ * Derived mapping: code → category metadata
41
+ *
42
+ * Auto-generated from DIAGNOSTIC_CATEGORIES.
43
+ * Used by DiagnosticReporter to show actionable commands.
44
+ */
45
+ export const CODE_TO_CATEGORY = (() => {
46
+ const result = {};
47
+ for (const [categoryKey, category] of Object.entries(DIAGNOSTIC_CATEGORIES)) {
48
+ // Generate human-readable name from category name (lowercase, plural)
49
+ const issueName = category.name.toLowerCase().replace('graph ', '');
50
+ for (const code of category.codes) {
51
+ result[code] = {
52
+ name: issueName,
53
+ checkCommand: `grafema check ${categoryKey}`,
54
+ };
55
+ }
56
+ }
57
+ return result;
58
+ })();
59
+ /**
60
+ * Get category for a diagnostic code
61
+ */
62
+ export function getCategoryForCode(code) {
63
+ return CODE_TO_CATEGORY[code];
64
+ }
65
+ /**
66
+ * Get all codes for a category
67
+ */
68
+ export function getCodesForCategory(category) {
69
+ return DIAGNOSTIC_CATEGORIES[category].codes;
70
+ }
71
+ //# sourceMappingURL=categories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categories.js","sourceRoot":"","sources":["../../src/diagnostics/categories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAmBH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsD;IACtF,YAAY,EAAE;QACZ,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,2CAA2C;QACxD,KAAK,EAAE,CAAC,wBAAwB,EAAE,uBAAuB,CAAC;KAC3D;IACD,KAAK,EAAE;QACL,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,qCAAqC;QAClD,KAAK,EAAE,CAAC,qBAAqB,CAAC;KAC/B;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,qDAAqD;QAClE,KAAK,EAAE,CAAC,wBAAwB,EAAE,sBAAsB,EAAE,kBAAkB,CAAC;KAC9E;IACD,OAAO,EAAE;QACP,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,gDAAgD;QAC7D,KAAK,EAAE,CAAC,mBAAmB,EAAE,sBAAsB,CAAC;KACrD;CACF,CAAC;AAYF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAqC,CAAC,GAAG,EAAE;IACtE,MAAM,MAAM,GAAqC,EAAE,CAAC;IAEpD,KAAK,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC;QAC5E,sEAAsE;QACtE,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAEpE,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YAClC,MAAM,CAAC,IAAI,CAAC,GAAG;gBACb,IAAI,EAAE,SAAS;gBACf,YAAY,EAAE,iBAAiB,WAAW,EAAE;aAC7C,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC,EAAE,CAAC;AAEL;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAA+B;IACjE,OAAO,qBAAqB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Diagnostics - Error collection, reporting, and logging
3
+ *
4
+ * This module provides the diagnostics infrastructure for Grafema:
5
+ * - DiagnosticCollector: Collects errors from plugin execution
6
+ * - DiagnosticReporter: Formats diagnostics for output (text/json/csv)
7
+ * - DiagnosticWriter: Writes diagnostics.log file
8
+ * - categories: Single source of truth for diagnostic category mappings
9
+ */
10
+ export { DiagnosticCollector } from './DiagnosticCollector.js';
11
+ export type { Diagnostic, DiagnosticInput } from './DiagnosticCollector.js';
12
+ export { DiagnosticReporter } from './DiagnosticReporter.js';
13
+ export type { ReportOptions, SummaryStats, CategoryCount, CategorizedSummaryStats } from './DiagnosticReporter.js';
14
+ export { DiagnosticWriter } from './DiagnosticWriter.js';
15
+ export { DIAGNOSTIC_CATEGORIES, CODE_TO_CATEGORY, getCategoryForCode, getCodesForCategory, } from './categories.js';
16
+ export type { DiagnosticCategory, DiagnosticCategoryKey, CodeCategoryInfo, } from './categories.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEnH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Diagnostics - Error collection, reporting, and logging
3
+ *
4
+ * This module provides the diagnostics infrastructure for Grafema:
5
+ * - DiagnosticCollector: Collects errors from plugin execution
6
+ * - DiagnosticReporter: Formats diagnostics for output (text/json/csv)
7
+ * - DiagnosticWriter: Writes diagnostics.log file
8
+ * - categories: Single source of truth for diagnostic category mappings
9
+ */
10
+ export { DiagnosticCollector } from './DiagnosticCollector.js';
11
+ export { DiagnosticReporter } from './DiagnosticReporter.js';
12
+ export { DiagnosticWriter } from './DiagnosticWriter.js';
13
+ // Category mappings (single source of truth)
14
+ export { DIAGNOSTIC_CATEGORIES, CODE_TO_CATEGORY, getCategoryForCode, getCodesForCategory, } from './categories.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,6CAA6C;AAC7C,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,200 @@
1
+ /**
2
+ * GrafemaError - Error hierarchy for Grafema
3
+ *
4
+ * All errors extend the native JavaScript Error class for compatibility
5
+ * with PluginResult.errors[] (Error[]).
6
+ *
7
+ * Error types:
8
+ * - ConfigError: Configuration parsing/validation errors (fatal)
9
+ * - FileAccessError: File system access errors (error)
10
+ * - LanguageError: Unsupported language/parsing errors (warning)
11
+ * - DatabaseError: RFDB database errors (fatal)
12
+ * - PluginError: Plugin execution errors (error)
13
+ * - AnalysisError: Analysis/timeout errors (error)
14
+ */
15
+ import type { PluginPhase } from '@grafema/types';
16
+ import type { Diagnostic } from '../diagnostics/DiagnosticCollector.js';
17
+ /**
18
+ * Context for error reporting
19
+ */
20
+ export interface ErrorContext {
21
+ filePath?: string;
22
+ lineNumber?: number;
23
+ phase?: PluginPhase;
24
+ plugin?: string;
25
+ [key: string]: unknown;
26
+ }
27
+ /**
28
+ * JSON representation of GrafemaError
29
+ */
30
+ export interface GrafemaErrorJSON {
31
+ code: string;
32
+ severity: 'fatal' | 'error' | 'warning';
33
+ message: string;
34
+ context: ErrorContext;
35
+ suggestion?: string;
36
+ }
37
+ /**
38
+ * Abstract base class for all Grafema errors.
39
+ *
40
+ * Extends native Error for compatibility with PluginResult.errors[].
41
+ */
42
+ export declare abstract class GrafemaError extends Error {
43
+ abstract readonly code: string;
44
+ abstract readonly severity: 'fatal' | 'error' | 'warning';
45
+ readonly context: ErrorContext;
46
+ readonly suggestion?: string;
47
+ constructor(message: string, context?: ErrorContext, suggestion?: string);
48
+ /**
49
+ * Serialize error to JSON for diagnostics.log
50
+ */
51
+ toJSON(): GrafemaErrorJSON;
52
+ }
53
+ /**
54
+ * Configuration error - config.json parsing, validation, missing required fields
55
+ *
56
+ * Severity: fatal (always)
57
+ * Codes: ERR_CONFIG_INVALID, ERR_CONFIG_MISSING_FIELD
58
+ */
59
+ export declare class ConfigError extends GrafemaError {
60
+ readonly code: string;
61
+ readonly severity: "fatal";
62
+ constructor(message: string, code: string, context?: ErrorContext, suggestion?: string);
63
+ }
64
+ /**
65
+ * File access error - unreadable files, missing git, permissions
66
+ *
67
+ * Severity: error (default)
68
+ * Codes: ERR_FILE_UNREADABLE, ERR_GIT_NOT_FOUND, ERR_GIT_ACCESS_DENIED
69
+ */
70
+ export declare class FileAccessError extends GrafemaError {
71
+ readonly code: string;
72
+ readonly severity: "error";
73
+ constructor(message: string, code: string, context?: ErrorContext, suggestion?: string);
74
+ }
75
+ /**
76
+ * Language error - unsupported file type, unparseable syntax
77
+ *
78
+ * Severity: warning (always)
79
+ * Codes: ERR_UNSUPPORTED_LANG, ERR_PARSE_FAILURE
80
+ */
81
+ export declare class LanguageError extends GrafemaError {
82
+ readonly code: string;
83
+ readonly severity: "warning";
84
+ constructor(message: string, code: string, context?: ErrorContext, suggestion?: string);
85
+ }
86
+ /**
87
+ * Database error - RFDB connection, corruption, lock
88
+ *
89
+ * Severity: fatal (always)
90
+ * Codes: ERR_DATABASE_LOCKED, ERR_DATABASE_CORRUPTED
91
+ */
92
+ export declare class DatabaseError extends GrafemaError {
93
+ readonly code: string;
94
+ readonly severity: "fatal";
95
+ constructor(message: string, code: string, context?: ErrorContext, suggestion?: string);
96
+ }
97
+ /**
98
+ * Plugin error - plugin execution failed, dependency missing
99
+ *
100
+ * Severity: error (default)
101
+ * Codes: ERR_PLUGIN_FAILED, ERR_PLUGIN_DEPENDENCY_MISSING
102
+ */
103
+ export declare class PluginError extends GrafemaError {
104
+ readonly code: string;
105
+ readonly severity: "error";
106
+ constructor(message: string, code: string, context?: ErrorContext, suggestion?: string);
107
+ }
108
+ /**
109
+ * Analysis error - internal analyzer failure, timeout
110
+ *
111
+ * Severity: error (default)
112
+ * Codes: ERR_ANALYSIS_TIMEOUT, ERR_ANALYSIS_INTERNAL
113
+ */
114
+ export declare class AnalysisError extends GrafemaError {
115
+ readonly code: string;
116
+ readonly severity: "error";
117
+ constructor(message: string, code: string, context?: ErrorContext, suggestion?: string);
118
+ }
119
+ /**
120
+ * Validation error - issues found by validators during VALIDATION phase
121
+ *
122
+ * Unlike other error classes, ValidationError has CONFIGURABLE severity because
123
+ * validators report issues of varying importance:
124
+ * - warning: informational issues (unresolved calls, missing assignments)
125
+ * - error: problems that may indicate bugs (broken references)
126
+ * - fatal: critical issues that should fail the analysis
127
+ *
128
+ * Codes:
129
+ * - ERR_UNRESOLVED_CALL: function call doesn't resolve to definition
130
+ * - ERR_DISCONNECTED_NODES: graph nodes not connected to root
131
+ * - ERR_DISCONNECTED_NODE: individual disconnected node
132
+ * - ERR_MISSING_ASSIGNMENT: variable has no ASSIGNED_FROM edge
133
+ * - ERR_BROKEN_REFERENCE: reference to non-existent node
134
+ * - ERR_NO_LEAF_NODE: data flow doesn't reach leaf node
135
+ */
136
+ export declare class ValidationError extends GrafemaError {
137
+ readonly code: string;
138
+ readonly severity: 'fatal' | 'error' | 'warning';
139
+ constructor(message: string, code: string, context?: ErrorContext, suggestion?: string, severity?: 'fatal' | 'error' | 'warning');
140
+ }
141
+ /**
142
+ * Strict mode error - reported when strictMode=true and an enricher
143
+ * cannot resolve a reference.
144
+ *
145
+ * Unlike other errors, StrictModeError is used to collect issues that
146
+ * would normally be silently skipped. All collected StrictModeErrors
147
+ * cause analysis to fail after the ENRICHMENT phase completes.
148
+ *
149
+ * Severity: fatal (always)
150
+ * Codes:
151
+ * - STRICT_UNRESOLVED_METHOD: Method call cannot be resolved to definition
152
+ * - STRICT_UNRESOLVED_CALL: Function call cannot be resolved to definition
153
+ * - STRICT_UNRESOLVED_ARGUMENT: Argument cannot be linked to parameter
154
+ * - STRICT_ALIAS_DEPTH_EXCEEDED: Alias chain too deep (potential cycle)
155
+ * - STRICT_BROKEN_IMPORT: Import/re-export chain broken
156
+ */
157
+ export declare class StrictModeError extends GrafemaError {
158
+ readonly code: string;
159
+ readonly severity: "fatal";
160
+ constructor(message: string, code: string, context?: ErrorContext, suggestion?: string);
161
+ }
162
+ /**
163
+ * A step in the resolution chain showing what was resolved before failure.
164
+ * Used by StrictModeError to provide context-aware error messages (REG-332).
165
+ */
166
+ export interface ResolutionStep {
167
+ /** Description of what was resolved, e.g., "getUser() return" */
168
+ step: string;
169
+ /** Result of resolution, e.g., "unknown" or "User class" */
170
+ result: string;
171
+ /** File where this step occurred */
172
+ file?: string;
173
+ /** Line number */
174
+ line?: number;
175
+ }
176
+ /**
177
+ * Reasons why resolution can fail.
178
+ * Used by StrictModeError for context-aware suggestions (REG-332).
179
+ */
180
+ export type ResolutionFailureReason = 'unknown_object_type' | 'class_not_imported' | 'method_not_found' | 'external_dependency' | 'circular_reference' | 'builtin_method' | 'unknown';
181
+ /**
182
+ * StrictModeFailure - thrown when strict mode stops analysis due to fatal errors.
183
+ *
184
+ * Unlike other errors, this carries a reference to the fatal diagnostic(s)
185
+ * rather than duplicating the message. The CLI formats output from
186
+ * the diagnostic, not from error.message.
187
+ *
188
+ * This prevents the duplication issue where both error.message and
189
+ * DiagnosticReporter show the same error (REG-332).
190
+ */
191
+ export declare class StrictModeFailure extends Error {
192
+ /** The fatal diagnostics that caused the failure */
193
+ readonly diagnostics: Diagnostic[];
194
+ /** Error count for summary */
195
+ readonly count: number;
196
+ /** REG-332: Number of errors suppressed by grafema-ignore comments */
197
+ readonly suppressedCount: number;
198
+ constructor(diagnostics: Diagnostic[], suppressedCount?: number);
199
+ }
200
+ //# sourceMappingURL=GrafemaError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GrafemaError.d.ts","sourceRoot":"","sources":["../../src/errors/GrafemaError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,8BAAsB,YAAa,SAAQ,KAAK;IAC9C,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;IAC1D,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE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M,uBAAuB,GAC/B,qBAAqB,GACrB,oBAAoB,GACpB,kBAAkB,GAClB,qBAAqB,GACrB,oBAAoB,GACpB,gBAAgB,GAChB,SAAS,CAAC;AAEd;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,oDAAoD;IACpD,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAC;IACnC,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;gBAErB,WAAW,EAAE,UAAU,EAAE,EAAE,eAAe,GAAE,MAAU;CASnE"}
@@ -0,0 +1,209 @@
1
+ /**
2
+ * GrafemaError - Error hierarchy for Grafema
3
+ *
4
+ * All errors extend the native JavaScript Error class for compatibility
5
+ * with PluginResult.errors[] (Error[]).
6
+ *
7
+ * Error types:
8
+ * - ConfigError: Configuration parsing/validation errors (fatal)
9
+ * - FileAccessError: File system access errors (error)
10
+ * - LanguageError: Unsupported language/parsing errors (warning)
11
+ * - DatabaseError: RFDB database errors (fatal)
12
+ * - PluginError: Plugin execution errors (error)
13
+ * - AnalysisError: Analysis/timeout errors (error)
14
+ */
15
+ /**
16
+ * Abstract base class for all Grafema errors.
17
+ *
18
+ * Extends native Error for compatibility with PluginResult.errors[].
19
+ */
20
+ export class GrafemaError extends Error {
21
+ context;
22
+ suggestion;
23
+ constructor(message, context = {}, suggestion) {
24
+ super(message);
25
+ this.name = this.constructor.name;
26
+ this.context = context;
27
+ this.suggestion = suggestion;
28
+ // Ensure proper prototype chain for instanceof checks
29
+ Object.setPrototypeOf(this, new.target.prototype);
30
+ // Capture stack trace (V8 specific)
31
+ if (Error.captureStackTrace) {
32
+ Error.captureStackTrace(this, this.constructor);
33
+ }
34
+ }
35
+ /**
36
+ * Serialize error to JSON for diagnostics.log
37
+ */
38
+ toJSON() {
39
+ return {
40
+ code: this.code,
41
+ severity: this.severity,
42
+ message: this.message,
43
+ context: this.context,
44
+ suggestion: this.suggestion,
45
+ };
46
+ }
47
+ }
48
+ /**
49
+ * Configuration error - config.json parsing, validation, missing required fields
50
+ *
51
+ * Severity: fatal (always)
52
+ * Codes: ERR_CONFIG_INVALID, ERR_CONFIG_MISSING_FIELD
53
+ */
54
+ export class ConfigError extends GrafemaError {
55
+ code;
56
+ severity = 'fatal';
57
+ constructor(message, code, context = {}, suggestion) {
58
+ super(message, context, suggestion);
59
+ this.code = code;
60
+ }
61
+ }
62
+ /**
63
+ * File access error - unreadable files, missing git, permissions
64
+ *
65
+ * Severity: error (default)
66
+ * Codes: ERR_FILE_UNREADABLE, ERR_GIT_NOT_FOUND, ERR_GIT_ACCESS_DENIED
67
+ */
68
+ export class FileAccessError extends GrafemaError {
69
+ code;
70
+ severity = 'error';
71
+ constructor(message, code, context = {}, suggestion) {
72
+ super(message, context, suggestion);
73
+ this.code = code;
74
+ }
75
+ }
76
+ /**
77
+ * Language error - unsupported file type, unparseable syntax
78
+ *
79
+ * Severity: warning (always)
80
+ * Codes: ERR_UNSUPPORTED_LANG, ERR_PARSE_FAILURE
81
+ */
82
+ export class LanguageError extends GrafemaError {
83
+ code;
84
+ severity = 'warning';
85
+ constructor(message, code, context = {}, suggestion) {
86
+ super(message, context, suggestion);
87
+ this.code = code;
88
+ }
89
+ }
90
+ /**
91
+ * Database error - RFDB connection, corruption, lock
92
+ *
93
+ * Severity: fatal (always)
94
+ * Codes: ERR_DATABASE_LOCKED, ERR_DATABASE_CORRUPTED
95
+ */
96
+ export class DatabaseError extends GrafemaError {
97
+ code;
98
+ severity = 'fatal';
99
+ constructor(message, code, context = {}, suggestion) {
100
+ super(message, context, suggestion);
101
+ this.code = code;
102
+ }
103
+ }
104
+ /**
105
+ * Plugin error - plugin execution failed, dependency missing
106
+ *
107
+ * Severity: error (default)
108
+ * Codes: ERR_PLUGIN_FAILED, ERR_PLUGIN_DEPENDENCY_MISSING
109
+ */
110
+ export class PluginError extends GrafemaError {
111
+ code;
112
+ severity = 'error';
113
+ constructor(message, code, context = {}, suggestion) {
114
+ super(message, context, suggestion);
115
+ this.code = code;
116
+ }
117
+ }
118
+ /**
119
+ * Analysis error - internal analyzer failure, timeout
120
+ *
121
+ * Severity: error (default)
122
+ * Codes: ERR_ANALYSIS_TIMEOUT, ERR_ANALYSIS_INTERNAL
123
+ */
124
+ export class AnalysisError extends GrafemaError {
125
+ code;
126
+ severity = 'error';
127
+ constructor(message, code, context = {}, suggestion) {
128
+ super(message, context, suggestion);
129
+ this.code = code;
130
+ }
131
+ }
132
+ /**
133
+ * Validation error - issues found by validators during VALIDATION phase
134
+ *
135
+ * Unlike other error classes, ValidationError has CONFIGURABLE severity because
136
+ * validators report issues of varying importance:
137
+ * - warning: informational issues (unresolved calls, missing assignments)
138
+ * - error: problems that may indicate bugs (broken references)
139
+ * - fatal: critical issues that should fail the analysis
140
+ *
141
+ * Codes:
142
+ * - ERR_UNRESOLVED_CALL: function call doesn't resolve to definition
143
+ * - ERR_DISCONNECTED_NODES: graph nodes not connected to root
144
+ * - ERR_DISCONNECTED_NODE: individual disconnected node
145
+ * - ERR_MISSING_ASSIGNMENT: variable has no ASSIGNED_FROM edge
146
+ * - ERR_BROKEN_REFERENCE: reference to non-existent node
147
+ * - ERR_NO_LEAF_NODE: data flow doesn't reach leaf node
148
+ */
149
+ export class ValidationError extends GrafemaError {
150
+ code;
151
+ severity;
152
+ constructor(message, code, context = {}, suggestion, severity = 'warning') {
153
+ super(message, context, suggestion);
154
+ this.code = code;
155
+ this.severity = severity;
156
+ }
157
+ }
158
+ /**
159
+ * Strict mode error - reported when strictMode=true and an enricher
160
+ * cannot resolve a reference.
161
+ *
162
+ * Unlike other errors, StrictModeError is used to collect issues that
163
+ * would normally be silently skipped. All collected StrictModeErrors
164
+ * cause analysis to fail after the ENRICHMENT phase completes.
165
+ *
166
+ * Severity: fatal (always)
167
+ * Codes:
168
+ * - STRICT_UNRESOLVED_METHOD: Method call cannot be resolved to definition
169
+ * - STRICT_UNRESOLVED_CALL: Function call cannot be resolved to definition
170
+ * - STRICT_UNRESOLVED_ARGUMENT: Argument cannot be linked to parameter
171
+ * - STRICT_ALIAS_DEPTH_EXCEEDED: Alias chain too deep (potential cycle)
172
+ * - STRICT_BROKEN_IMPORT: Import/re-export chain broken
173
+ */
174
+ export class StrictModeError extends GrafemaError {
175
+ code;
176
+ severity = 'fatal';
177
+ constructor(message, code, context = {}, suggestion) {
178
+ super(message, context, suggestion);
179
+ this.code = code;
180
+ }
181
+ }
182
+ /**
183
+ * StrictModeFailure - thrown when strict mode stops analysis due to fatal errors.
184
+ *
185
+ * Unlike other errors, this carries a reference to the fatal diagnostic(s)
186
+ * rather than duplicating the message. The CLI formats output from
187
+ * the diagnostic, not from error.message.
188
+ *
189
+ * This prevents the duplication issue where both error.message and
190
+ * DiagnosticReporter show the same error (REG-332).
191
+ */
192
+ export class StrictModeFailure extends Error {
193
+ /** The fatal diagnostics that caused the failure */
194
+ diagnostics;
195
+ /** Error count for summary */
196
+ count;
197
+ /** REG-332: Number of errors suppressed by grafema-ignore comments */
198
+ suppressedCount;
199
+ constructor(diagnostics, suppressedCount = 0) {
200
+ // Keep message minimal - CLI will format from diagnostics
201
+ super(`Strict mode: ${diagnostics.length} unresolved reference(s) found`);
202
+ this.name = 'StrictModeFailure';
203
+ this.diagnostics = diagnostics;
204
+ this.count = diagnostics.length;
205
+ this.suppressedCount = suppressedCount;
206
+ Object.setPrototypeOf(this, new.target.prototype);
207
+ }
208
+ }
209
+ //# sourceMappingURL=GrafemaError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GrafemaError.js","sourceRoot":"","sources":["../../src/errors/GrafemaError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA2BH;;;;GAIG;AACH,MAAM,OAAgB,YAAa,SAAQ,KAAK;IAGrC,OAAO,CAAe;IACtB,UAAU,CAAU;IAE7B,YAAY,OAAe,EAAE,UAAwB,EAAE,EAAE,UAAmB;QAC1E,KAAK,C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