@grafema/core 0.1.0-alpha.1
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.
- package/LICENSE +190 -0
- package/README.md +76 -0
- package/dist/Orchestrator.d.ts +142 -0
- package/dist/Orchestrator.d.ts.map +1 -0
- package/dist/Orchestrator.js +481 -0
- package/dist/api/GraphAPI.d.ts +87 -0
- package/dist/api/GraphAPI.d.ts.map +1 -0
- package/dist/api/GraphAPI.js +210 -0
- package/dist/api/GuaranteeAPI.d.ts +147 -0
- package/dist/api/GuaranteeAPI.d.ts.map +1 -0
- package/dist/api/GuaranteeAPI.js +288 -0
- package/dist/core/ASTWorker.d.ts +133 -0
- package/dist/core/ASTWorker.d.ts.map +1 -0
- package/dist/core/ASTWorker.js +352 -0
- package/dist/core/ASTWorkerPool.d.ts +85 -0
- package/dist/core/ASTWorkerPool.d.ts.map +1 -0
- package/dist/core/ASTWorkerPool.js +207 -0
- package/dist/core/AnalysisQueue.d.ts +104 -0
- package/dist/core/AnalysisQueue.d.ts.map +1 -0
- package/dist/core/AnalysisQueue.js +299 -0
- package/dist/core/AnalysisWorker.d.ts +14 -0
- package/dist/core/AnalysisWorker.d.ts.map +1 -0
- package/dist/core/AnalysisWorker.js +307 -0
- package/dist/core/GraphBackend.d.ts +156 -0
- package/dist/core/GraphBackend.d.ts.map +1 -0
- package/dist/core/GraphBackend.js +85 -0
- package/dist/core/GuaranteeManager.d.ts +230 -0
- package/dist/core/GuaranteeManager.d.ts.map +1 -0
- package/dist/core/GuaranteeManager.js +352 -0
- package/dist/core/ManifestStore.d.ts +71 -0
- package/dist/core/ManifestStore.d.ts.map +1 -0
- package/dist/core/ManifestStore.js +146 -0
- package/dist/core/NodeFactory.d.ts +160 -0
- package/dist/core/NodeFactory.d.ts.map +1 -0
- package/dist/core/NodeFactory.js +137 -0
- package/dist/core/NodeId.d.ts +88 -0
- package/dist/core/NodeId.d.ts.map +1 -0
- package/dist/core/NodeId.js +170 -0
- package/dist/core/ParallelAnalyzer.d.ts +120 -0
- package/dist/core/ParallelAnalyzer.d.ts.map +1 -0
- package/dist/core/ParallelAnalyzer.js +331 -0
- package/dist/core/PriorityQueue.d.ts +106 -0
- package/dist/core/PriorityQueue.d.ts.map +1 -0
- package/dist/core/PriorityQueue.js +168 -0
- package/dist/core/Profiler.d.ts +75 -0
- package/dist/core/Profiler.d.ts.map +1 -0
- package/dist/core/Profiler.js +149 -0
- package/dist/core/QueueWorker.d.ts +12 -0
- package/dist/core/QueueWorker.d.ts.map +1 -0
- package/dist/core/QueueWorker.js +567 -0
- package/dist/core/RFDBClient.d.ts +179 -0
- package/dist/core/RFDBClient.d.ts.map +1 -0
- package/dist/core/RFDBClient.js +429 -0
- package/dist/core/Task.d.ts +56 -0
- package/dist/core/Task.d.ts.map +1 -0
- package/dist/core/Task.js +85 -0
- package/dist/core/TaskTypes.d.ts +20 -0
- package/dist/core/TaskTypes.d.ts.map +1 -0
- package/dist/core/TaskTypes.js +10 -0
- package/dist/core/VersionManager.d.ts +166 -0
- package/dist/core/VersionManager.d.ts.map +1 -0
- package/dist/core/VersionManager.js +237 -0
- package/dist/core/WorkerPool.d.ts +82 -0
- package/dist/core/WorkerPool.d.ts.map +1 -0
- package/dist/core/WorkerPool.js +109 -0
- package/dist/core/nodes/CallSiteNode.d.ts +26 -0
- package/dist/core/nodes/CallSiteNode.d.ts.map +1 -0
- package/dist/core/nodes/CallSiteNode.js +44 -0
- package/dist/core/nodes/ClassNode.d.ts +25 -0
- package/dist/core/nodes/ClassNode.d.ts.map +1 -0
- package/dist/core/nodes/ClassNode.js +40 -0
- package/dist/core/nodes/ConstantNode.d.ts +24 -0
- package/dist/core/nodes/ConstantNode.d.ts.map +1 -0
- package/dist/core/nodes/ConstantNode.js +39 -0
- package/dist/core/nodes/DatabaseQueryNode.d.ts +22 -0
- package/dist/core/nodes/DatabaseQueryNode.d.ts.map +1 -0
- package/dist/core/nodes/DatabaseQueryNode.js +37 -0
- package/dist/core/nodes/EntrypointNode.d.ts +102 -0
- package/dist/core/nodes/EntrypointNode.d.ts.map +1 -0
- package/dist/core/nodes/EntrypointNode.js +119 -0
- package/dist/core/nodes/EventListenerNode.d.ts +25 -0
- package/dist/core/nodes/EventListenerNode.d.ts.map +1 -0
- package/dist/core/nodes/EventListenerNode.js +39 -0
- package/dist/core/nodes/ExportNode.d.ts +26 -0
- package/dist/core/nodes/ExportNode.d.ts.map +1 -0
- package/dist/core/nodes/ExportNode.js +40 -0
- package/dist/core/nodes/ExternalStdioNode.d.ts +17 -0
- package/dist/core/nodes/ExternalStdioNode.d.ts.map +1 -0
- package/dist/core/nodes/ExternalStdioNode.js +26 -0
- package/dist/core/nodes/FunctionNode.d.ts +27 -0
- package/dist/core/nodes/FunctionNode.d.ts.map +1 -0
- package/dist/core/nodes/FunctionNode.js +53 -0
- package/dist/core/nodes/GuaranteeNode.d.ts +76 -0
- package/dist/core/nodes/GuaranteeNode.d.ts.map +1 -0
- package/dist/core/nodes/GuaranteeNode.js +117 -0
- package/dist/core/nodes/HttpRequestNode.d.ts +24 -0
- package/dist/core/nodes/HttpRequestNode.d.ts.map +1 -0
- package/dist/core/nodes/HttpRequestNode.js +38 -0
- package/dist/core/nodes/ImportNode.d.ts +27 -0
- package/dist/core/nodes/ImportNode.d.ts.map +1 -0
- package/dist/core/nodes/ImportNode.js +43 -0
- package/dist/core/nodes/LiteralNode.d.ts +26 -0
- package/dist/core/nodes/LiteralNode.d.ts.map +1 -0
- package/dist/core/nodes/LiteralNode.js +40 -0
- package/dist/core/nodes/MethodCallNode.d.ts +29 -0
- package/dist/core/nodes/MethodCallNode.d.ts.map +1 -0
- package/dist/core/nodes/MethodCallNode.js +47 -0
- package/dist/core/nodes/MethodNode.d.ts +29 -0
- package/dist/core/nodes/MethodNode.d.ts.map +1 -0
- package/dist/core/nodes/MethodNode.js +44 -0
- package/dist/core/nodes/ModuleNode.d.ts +29 -0
- package/dist/core/nodes/ModuleNode.d.ts.map +1 -0
- package/dist/core/nodes/ModuleNode.js +49 -0
- package/dist/core/nodes/NodeKind.d.ts +91 -0
- package/dist/core/nodes/NodeKind.d.ts.map +1 -0
- package/dist/core/nodes/NodeKind.js +146 -0
- package/dist/core/nodes/ParameterNode.d.ts +26 -0
- package/dist/core/nodes/ParameterNode.d.ts.map +1 -0
- package/dist/core/nodes/ParameterNode.js +43 -0
- package/dist/core/nodes/ScopeNode.d.ts +32 -0
- package/dist/core/nodes/ScopeNode.d.ts.map +1 -0
- package/dist/core/nodes/ScopeNode.js +47 -0
- package/dist/core/nodes/ServiceNode.d.ts +44 -0
- package/dist/core/nodes/ServiceNode.d.ts.map +1 -0
- package/dist/core/nodes/ServiceNode.js +49 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts +22 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts.map +1 -0
- package/dist/core/nodes/VariableDeclarationNode.js +38 -0
- package/dist/core/nodes/index.d.ts +25 -0
- package/dist/core/nodes/index.d.ts.map +1 -0
- package/dist/core/nodes/index.js +30 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/plugins/Plugin.d.ts +44 -0
- package/dist/plugins/Plugin.d.ts.map +1 -0
- package/dist/plugins/Plugin.js +46 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts +23 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.js +260 -0
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts +19 -0
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ExpressAnalyzer.js +306 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts +17 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.js +308 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts +38 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/FetchAnalyzer.js +344 -0
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts +65 -0
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts.map +1 -0
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.js +472 -0
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts +84 -0
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/JSASTAnalyzer.js +1378 -0
- package/dist/plugins/analysis/ReactAnalyzer.d.ts +90 -0
- package/dist/plugins/analysis/ReactAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ReactAnalyzer.js +1153 -0
- package/dist/plugins/analysis/RustAnalyzer.d.ts +13 -0
- package/dist/plugins/analysis/RustAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/RustAnalyzer.js +259 -0
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts +21 -0
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/SQLiteAnalyzer.js +317 -0
- package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts +35 -0
- package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ServiceLayerAnalyzer.js +303 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts +33 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.js +283 -0
- package/dist/plugins/analysis/SystemDbAnalyzer.d.ts +27 -0
- package/dist/plugins/analysis/SystemDbAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/SystemDbAnalyzer.js +211 -0
- package/dist/plugins/analysis/ast/ConditionParser.d.ts +85 -0
- package/dist/plugins/analysis/ast/ConditionParser.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/ConditionParser.js +277 -0
- package/dist/plugins/analysis/ast/ExpressionEvaluator.d.ts +15 -0
- package/dist/plugins/analysis/ast/ExpressionEvaluator.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/ExpressionEvaluator.js +91 -0
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts +77 -0
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/GraphBuilder.js +1077 -0
- package/dist/plugins/analysis/ast/OxcAdapter.d.ts +41 -0
- package/dist/plugins/analysis/ast/OxcAdapter.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/OxcAdapter.js +40 -0
- package/dist/plugins/analysis/ast/types.d.ts +346 -0
- package/dist/plugins/analysis/ast/types.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/types.js +4 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts +93 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.js +24 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts +77 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.js +377 -0
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts +27 -0
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.js +232 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts +25 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.js +172 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts +29 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.js +180 -0
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts +14 -0
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.js +200 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts +45 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.js +150 -0
- package/dist/plugins/analysis/ast/visitors/index.d.ts +17 -0
- package/dist/plugins/analysis/ast/visitors/index.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/index.js +13 -0
- package/dist/plugins/discovery/DiscoveryPlugin.d.ts +34 -0
- package/dist/plugins/discovery/DiscoveryPlugin.d.ts.map +1 -0
- package/dist/plugins/discovery/DiscoveryPlugin.js +26 -0
- package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts +26 -0
- package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/MonorepoServiceDiscovery.js +79 -0
- package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts +14 -0
- package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/SimpleProjectDiscovery.js +65 -0
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts +19 -0
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/ZonServiceDiscovery.js +204 -0
- package/dist/plugins/enrichment/AliasTracker.d.ts +40 -0
- package/dist/plugins/enrichment/AliasTracker.d.ts.map +1 -0
- package/dist/plugins/enrichment/AliasTracker.js +290 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts +30 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts.map +1 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.js +135 -0
- package/dist/plugins/enrichment/ImportExportLinker.d.ts +30 -0
- package/dist/plugins/enrichment/ImportExportLinker.d.ts.map +1 -0
- package/dist/plugins/enrichment/ImportExportLinker.js +176 -0
- package/dist/plugins/enrichment/InstanceOfResolver.d.ts +21 -0
- package/dist/plugins/enrichment/InstanceOfResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/InstanceOfResolver.js +117 -0
- package/dist/plugins/enrichment/MethodCallResolver.d.ts +41 -0
- package/dist/plugins/enrichment/MethodCallResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/MethodCallResolver.js +252 -0
- package/dist/plugins/enrichment/MountPointResolver.d.ts +26 -0
- package/dist/plugins/enrichment/MountPointResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/MountPointResolver.js +189 -0
- package/dist/plugins/enrichment/PrefixEvaluator.d.ts +89 -0
- package/dist/plugins/enrichment/PrefixEvaluator.d.ts.map +1 -0
- package/dist/plugins/enrichment/PrefixEvaluator.js +415 -0
- package/dist/plugins/enrichment/RustFFIEnricher.d.ts +25 -0
- package/dist/plugins/enrichment/RustFFIEnricher.d.ts.map +1 -0
- package/dist/plugins/enrichment/RustFFIEnricher.js +170 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts +114 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts.map +1 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.js +464 -0
- package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts +27 -0
- package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts.map +1 -0
- package/dist/plugins/indexing/IncrementalModuleIndexer.js +238 -0
- package/dist/plugins/indexing/JSModuleIndexer.d.ts +33 -0
- package/dist/plugins/indexing/JSModuleIndexer.d.ts.map +1 -0
- package/dist/plugins/indexing/JSModuleIndexer.js +299 -0
- package/dist/plugins/indexing/RustModuleIndexer.d.ts +28 -0
- package/dist/plugins/indexing/RustModuleIndexer.d.ts.map +1 -0
- package/dist/plugins/indexing/RustModuleIndexer.js +140 -0
- package/dist/plugins/indexing/ServiceDetector.d.ts +46 -0
- package/dist/plugins/indexing/ServiceDetector.d.ts.map +1 -0
- package/dist/plugins/indexing/ServiceDetector.js +164 -0
- package/dist/plugins/validation/CallResolverValidator.d.ts +23 -0
- package/dist/plugins/validation/CallResolverValidator.d.ts.map +1 -0
- package/dist/plugins/validation/CallResolverValidator.js +108 -0
- package/dist/plugins/validation/DataFlowValidator.d.ts +24 -0
- package/dist/plugins/validation/DataFlowValidator.d.ts.map +1 -0
- package/dist/plugins/validation/DataFlowValidator.js +148 -0
- package/dist/plugins/validation/EvalBanValidator.d.ts +25 -0
- package/dist/plugins/validation/EvalBanValidator.d.ts.map +1 -0
- package/dist/plugins/validation/EvalBanValidator.js +123 -0
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts +11 -0
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts.map +1 -0
- package/dist/plugins/validation/GraphConnectivityValidator.js +135 -0
- package/dist/plugins/validation/SQLInjectionValidator.d.ts +43 -0
- package/dist/plugins/validation/SQLInjectionValidator.d.ts.map +1 -0
- package/dist/plugins/validation/SQLInjectionValidator.js +251 -0
- package/dist/plugins/validation/ShadowingDetector.d.ts +26 -0
- package/dist/plugins/validation/ShadowingDetector.d.ts.map +1 -0
- package/dist/plugins/validation/ShadowingDetector.js +119 -0
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts +21 -0
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts.map +1 -0
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.js +151 -0
- package/dist/plugins/vcs/GitPlugin.d.ts +84 -0
- package/dist/plugins/vcs/GitPlugin.d.ts.map +1 -0
- package/dist/plugins/vcs/GitPlugin.js +295 -0
- package/dist/plugins/vcs/VCSPlugin.d.ts +133 -0
- package/dist/plugins/vcs/VCSPlugin.d.ts.map +1 -0
- package/dist/plugins/vcs/VCSPlugin.js +82 -0
- package/dist/plugins/vcs/index.d.ts +10 -0
- package/dist/plugins/vcs/index.d.ts.map +1 -0
- package/dist/plugins/vcs/index.js +18 -0
- package/dist/storage/backends/RFDBServerBackend.d.ts +258 -0
- package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -0
- package/dist/storage/backends/RFDBServerBackend.js +565 -0
- package/dist/storage/backends/typeValidation.d.ts +47 -0
- package/dist/storage/backends/typeValidation.d.ts.map +1 -0
- package/dist/storage/backends/typeValidation.js +137 -0
- package/dist/validation/PathValidator.d.ts +81 -0
- package/dist/validation/PathValidator.d.ts.map +1 -0
- package/dist/validation/PathValidator.js +251 -0
- package/package.json +57 -0
- package/src/.rfguard/current-session.txt +1 -0
- package/src/Orchestrator.ts +673 -0
- package/src/api/GraphAPI.ts +305 -0
- package/src/api/GuaranteeAPI.ts +401 -0
- package/src/core/ASTWorker.ts +567 -0
- package/src/core/ASTWorkerPool.ts +299 -0
- package/src/core/AnalysisQueue.ts +447 -0
- package/src/core/AnalysisWorker.ts +410 -0
- package/src/core/GraphBackend.ts +265 -0
- package/src/core/GuaranteeManager.ts +581 -0
- package/src/core/ManifestStore.ts +196 -0
- package/src/core/NodeFactory.ts +274 -0
- package/src/core/NodeId.ts +257 -0
- package/src/core/ParallelAnalyzer.ts +476 -0
- package/src/core/PriorityQueue.ts +227 -0
- package/src/core/Profiler.ts +188 -0
- package/src/core/QueueWorker.ts +780 -0
- package/src/core/Task.ts +107 -0
- package/src/core/TaskTypes.ts +40 -0
- package/src/core/VersionManager.ts +404 -0
- package/src/core/WorkerPool.ts +180 -0
- package/src/core/nodes/CallSiteNode.ts +72 -0
- package/src/core/nodes/ClassNode.ts +69 -0
- package/src/core/nodes/ConstantNode.ts +63 -0
- package/src/core/nodes/DatabaseQueryNode.ts +60 -0
- package/src/core/nodes/EntrypointNode.ts +164 -0
- package/src/core/nodes/EventListenerNode.ts +64 -0
- package/src/core/nodes/ExportNode.ts +71 -0
- package/src/core/nodes/ExternalStdioNode.ts +36 -0
- package/src/core/nodes/FunctionNode.ts +78 -0
- package/src/core/nodes/GuaranteeNode.ts +162 -0
- package/src/core/nodes/HttpRequestNode.ts +63 -0
- package/src/core/nodes/ImportNode.ts +75 -0
- package/src/core/nodes/LiteralNode.ts +67 -0
- package/src/core/nodes/MethodCallNode.ts +79 -0
- package/src/core/nodes/MethodNode.ts +78 -0
- package/src/core/nodes/ModuleNode.ts +74 -0
- package/src/core/nodes/NodeKind.ts +171 -0
- package/src/core/nodes/ParameterNode.ts +73 -0
- package/src/core/nodes/ScopeNode.ts +80 -0
- package/src/core/nodes/ServiceNode.ts +86 -0
- package/src/core/nodes/VariableDeclarationNode.ts +60 -0
- package/src/core/nodes/index.ts +49 -0
- package/src/index.ts +93 -0
- package/src/plugins/Plugin.ts +74 -0
- package/src/plugins/analysis/DatabaseAnalyzer.ts +322 -0
- package/src/plugins/analysis/ExpressAnalyzer.ts +401 -0
- package/src/plugins/analysis/ExpressRouteAnalyzer.ts +414 -0
- package/src/plugins/analysis/FetchAnalyzer.ts +441 -0
- package/src/plugins/analysis/IncrementalAnalysisPlugin.ts +686 -0
- package/src/plugins/analysis/JSASTAnalyzer.ts +1680 -0
- package/src/plugins/analysis/ReactAnalyzer.ts +1368 -0
- package/src/plugins/analysis/RustAnalyzer.ts +438 -0
- package/src/plugins/analysis/SQLiteAnalyzer.ts +388 -0
- package/src/plugins/analysis/ServiceLayerAnalyzer.ts +429 -0
- package/src/plugins/analysis/SocketIOAnalyzer.ts +395 -0
- package/src/plugins/analysis/SystemDbAnalyzer.ts +284 -0
- package/src/plugins/analysis/ast/ConditionParser.ts +333 -0
- package/src/plugins/analysis/ast/ExpressionEvaluator.ts +117 -0
- package/src/plugins/analysis/ast/GraphBuilder.ts +1371 -0
- package/src/plugins/analysis/ast/OxcAdapter.ts +63 -0
- package/src/plugins/analysis/ast/types.ts +400 -0
- package/src/plugins/analysis/ast/visitors/ASTVisitor.ts +137 -0
- package/src/plugins/analysis/ast/visitors/CallExpressionVisitor.ts +528 -0
- package/src/plugins/analysis/ast/visitors/ClassVisitor.ts +339 -0
- package/src/plugins/analysis/ast/visitors/FunctionVisitor.ts +273 -0
- package/src/plugins/analysis/ast/visitors/ImportExportVisitor.ts +259 -0
- package/src/plugins/analysis/ast/visitors/TypeScriptVisitor.ts +235 -0
- package/src/plugins/analysis/ast/visitors/VariableVisitor.ts +268 -0
- package/src/plugins/analysis/ast/visitors/index.ts +36 -0
- package/src/plugins/discovery/DiscoveryPlugin.ts +50 -0
- package/src/plugins/discovery/MonorepoServiceDiscovery.ts +117 -0
- package/src/plugins/discovery/SimpleProjectDiscovery.ts +102 -0
- package/src/plugins/enrichment/AliasTracker.ts +399 -0
- package/src/plugins/enrichment/HTTPConnectionEnricher.ts +192 -0
- package/src/plugins/enrichment/ImportExportLinker.ts +221 -0
- package/src/plugins/enrichment/InstanceOfResolver.ts +165 -0
- package/src/plugins/enrichment/MethodCallResolver.ts +333 -0
- package/src/plugins/enrichment/MountPointResolver.ts +264 -0
- package/src/plugins/enrichment/PrefixEvaluator.ts +527 -0
- package/src/plugins/enrichment/RustFFIEnricher.ts +218 -0
- package/src/plugins/enrichment/ValueDomainAnalyzer.ts +682 -0
- package/src/plugins/indexing/IncrementalModuleIndexer.ts +287 -0
- package/src/plugins/indexing/JSModuleIndexer.ts +374 -0
- package/src/plugins/indexing/RustModuleIndexer.ts +160 -0
- package/src/plugins/indexing/ServiceDetector.ts +230 -0
- package/src/plugins/validation/CallResolverValidator.ts +170 -0
- package/src/plugins/validation/DataFlowValidator.ts +233 -0
- package/src/plugins/validation/EvalBanValidator.ts +175 -0
- package/src/plugins/validation/GraphConnectivityValidator.ts +201 -0
- package/src/plugins/validation/SQLInjectionValidator.ts +363 -0
- package/src/plugins/validation/ShadowingDetector.ts +173 -0
- package/src/plugins/validation/TypeScriptDeadCodeValidator.ts +203 -0
- package/src/plugins/vcs/GitPlugin.ts +344 -0
- package/src/plugins/vcs/VCSPlugin.ts +190 -0
- package/src/plugins/vcs/index.ts +32 -0
- package/src/storage/backends/RFDBServerBackend.ts +687 -0
- package/src/storage/backends/typeValidation.ts +151 -0
- package/src/validation/PathValidator.ts +342 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrator - управляет процессом анализа через фазы
|
|
3
|
+
* Полностью абстрактный - специфичная логика в плагинах
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, unlinkSync } from 'fs';
|
|
6
|
+
import { join, dirname, resolve } from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { spawn, execSync } from 'child_process';
|
|
9
|
+
import { setTimeout as sleep } from 'timers/promises';
|
|
10
|
+
import { SimpleProjectDiscovery } from './plugins/discovery/SimpleProjectDiscovery.js';
|
|
11
|
+
import { Profiler } from './core/Profiler.js';
|
|
12
|
+
import { AnalysisQueue } from './core/AnalysisQueue.js';
|
|
13
|
+
export class Orchestrator {
|
|
14
|
+
graph;
|
|
15
|
+
config;
|
|
16
|
+
plugins;
|
|
17
|
+
workerCount;
|
|
18
|
+
onProgress;
|
|
19
|
+
forceAnalysis;
|
|
20
|
+
serviceFilter;
|
|
21
|
+
indexOnly;
|
|
22
|
+
profiler;
|
|
23
|
+
parallelConfig;
|
|
24
|
+
analysisQueue;
|
|
25
|
+
rfdbServerProcess;
|
|
26
|
+
_serverWasExternal;
|
|
27
|
+
constructor(options = {}) {
|
|
28
|
+
this.graph = options.graph;
|
|
29
|
+
this.config = options;
|
|
30
|
+
this.plugins = options.plugins || [];
|
|
31
|
+
this.workerCount = options.workerCount || 10; // ГОРИЗОНТАЛЬНОЕ МАСШТАБИРОВАНИЕ
|
|
32
|
+
this.onProgress = options.onProgress || (() => { }); // Callback для прогресса
|
|
33
|
+
this.forceAnalysis = options.forceAnalysis || false; // Флаг для игнорирования кэша
|
|
34
|
+
this.serviceFilter = options.serviceFilter || null; // Фильтр для одного сервиса
|
|
35
|
+
this.indexOnly = options.indexOnly || false; // Только DISCOVERY + INDEXING (для coverage)
|
|
36
|
+
this.profiler = new Profiler('Orchestrator');
|
|
37
|
+
// Parallel/queue-based analysis config
|
|
38
|
+
this.parallelConfig = options.parallel || null;
|
|
39
|
+
this.analysisQueue = null;
|
|
40
|
+
this.rfdbServerProcess = null;
|
|
41
|
+
this._serverWasExternal = false;
|
|
42
|
+
// Auto-add default discovery if no discovery plugins provided
|
|
43
|
+
const hasDiscovery = this.plugins.some(p => p.metadata?.phase === 'DISCOVERY');
|
|
44
|
+
if (!hasDiscovery) {
|
|
45
|
+
this.plugins.unshift(new SimpleProjectDiscovery());
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Запустить анализ проекта
|
|
50
|
+
*/
|
|
51
|
+
async run(projectPath) {
|
|
52
|
+
const totalStartTime = Date.now();
|
|
53
|
+
// Resolve to absolute path
|
|
54
|
+
const absoluteProjectPath = projectPath.startsWith('/') ? projectPath : resolve(projectPath);
|
|
55
|
+
this.onProgress({ phase: 'discovery', currentPlugin: 'Starting discovery...', message: 'Discovering services...', totalFiles: 0, processedFiles: 0 });
|
|
56
|
+
// PHASE 0: DISCOVERY - запуск плагинов фазы DISCOVERY
|
|
57
|
+
this.profiler.start('DISCOVERY');
|
|
58
|
+
const manifest = await this.discover(absoluteProjectPath);
|
|
59
|
+
this.profiler.end('DISCOVERY');
|
|
60
|
+
const epCount = manifest.entrypoints?.length || 0;
|
|
61
|
+
const svcCount = manifest.services?.length || 0;
|
|
62
|
+
this.onProgress({
|
|
63
|
+
phase: 'discovery',
|
|
64
|
+
currentPlugin: 'Discovery complete',
|
|
65
|
+
message: `Found ${svcCount} service(s), ${epCount} entrypoint(s)`,
|
|
66
|
+
totalFiles: 0,
|
|
67
|
+
processedFiles: 0
|
|
68
|
+
});
|
|
69
|
+
console.log(`[Orchestrator] Discovery: ${svcCount} services, ${epCount} entrypoints`);
|
|
70
|
+
// Build unified list of indexing units from services AND entrypoints
|
|
71
|
+
const indexingUnits = this.buildIndexingUnits(manifest);
|
|
72
|
+
// Filter if specified
|
|
73
|
+
let unitsToProcess;
|
|
74
|
+
if (this.serviceFilter) {
|
|
75
|
+
unitsToProcess = indexingUnits.filter(u => u.name === this.serviceFilter ||
|
|
76
|
+
u.path === this.serviceFilter ||
|
|
77
|
+
u.name.includes(this.serviceFilter) ||
|
|
78
|
+
u.path.includes(this.serviceFilter));
|
|
79
|
+
console.log(`[Orchestrator] Filtering: ${this.serviceFilter} (found ${unitsToProcess.length} of ${indexingUnits.length})`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
unitsToProcess = indexingUnits;
|
|
83
|
+
}
|
|
84
|
+
console.log(`[Orchestrator] Processing ${unitsToProcess.length} indexing units (services + entrypoints)`);
|
|
85
|
+
console.log(`[Orchestrator] Strategy: Phase-by-phase with DFS dependency tree per entrypoint`);
|
|
86
|
+
// PHASE 1: INDEXING - каждый сервис строит своё дерево зависимостей от entrypoint
|
|
87
|
+
const indexingStart = Date.now();
|
|
88
|
+
this.profiler.start('INDEXING');
|
|
89
|
+
this.onProgress({
|
|
90
|
+
phase: 'indexing',
|
|
91
|
+
currentPlugin: 'Starting indexing...',
|
|
92
|
+
message: 'Building dependency trees...',
|
|
93
|
+
totalFiles: unitsToProcess.length,
|
|
94
|
+
processedFiles: 0
|
|
95
|
+
});
|
|
96
|
+
// Параллельная обработка units батчами
|
|
97
|
+
const BATCH_SIZE = this.workerCount;
|
|
98
|
+
let processedUnits = 0;
|
|
99
|
+
for (let batchStart = 0; batchStart < unitsToProcess.length; batchStart += BATCH_SIZE) {
|
|
100
|
+
const batch = unitsToProcess.slice(batchStart, batchStart + BATCH_SIZE);
|
|
101
|
+
this.onProgress({
|
|
102
|
+
phase: 'indexing',
|
|
103
|
+
currentPlugin: 'JSModuleIndexer',
|
|
104
|
+
message: `[${processedUnits + 1}-${processedUnits + batch.length}/${unitsToProcess.length}] Batch indexing...`,
|
|
105
|
+
totalFiles: unitsToProcess.length,
|
|
106
|
+
processedFiles: processedUnits
|
|
107
|
+
});
|
|
108
|
+
// Параллельно обрабатываем батч units
|
|
109
|
+
await Promise.all(batch.map(async (unit, idx) => {
|
|
110
|
+
const unitStart = Date.now();
|
|
111
|
+
const unitManifest = {
|
|
112
|
+
projectPath: manifest.projectPath,
|
|
113
|
+
service: {
|
|
114
|
+
...unit, // Pass all unit fields
|
|
115
|
+
id: unit.id,
|
|
116
|
+
name: unit.name,
|
|
117
|
+
path: unit.path
|
|
118
|
+
},
|
|
119
|
+
modules: []
|
|
120
|
+
};
|
|
121
|
+
await this.runPhase('INDEXING', { manifest: unitManifest, graph: this.graph, workerCount: 1 });
|
|
122
|
+
const unitTime = ((Date.now() - unitStart) / 1000).toFixed(2);
|
|
123
|
+
console.log(`[Orchestrator] ⏱️ INDEXING ${unit.name}: ${unitTime}s`);
|
|
124
|
+
this.onProgress({
|
|
125
|
+
phase: 'indexing',
|
|
126
|
+
currentPlugin: 'JSModuleIndexer',
|
|
127
|
+
message: `Indexed ${unit.name || unit.path} (${unitTime}s)`,
|
|
128
|
+
totalFiles: unitsToProcess.length,
|
|
129
|
+
processedFiles: processedUnits + idx + 1,
|
|
130
|
+
servicesAnalyzed: processedUnits + idx + 1
|
|
131
|
+
});
|
|
132
|
+
}));
|
|
133
|
+
processedUnits += batch.length;
|
|
134
|
+
}
|
|
135
|
+
this.profiler.end('INDEXING');
|
|
136
|
+
console.log(`[Orchestrator] ⏱️ INDEXING phase total: ${((Date.now() - indexingStart) / 1000).toFixed(2)}s`);
|
|
137
|
+
// Skip remaining phases if indexOnly mode (for coverage)
|
|
138
|
+
if (this.indexOnly) {
|
|
139
|
+
const totalTime = ((Date.now() - totalStartTime) / 1000).toFixed(2);
|
|
140
|
+
console.log(`[Orchestrator] ⏱️ indexOnly mode - skipping ANALYSIS/ENRICHMENT/VALIDATION`);
|
|
141
|
+
console.log(`[Orchestrator] ⏱️ Total time: ${totalTime}s for ${unitsToProcess.length} units`);
|
|
142
|
+
return manifest;
|
|
143
|
+
}
|
|
144
|
+
// PHASE 2: ANALYSIS - все units (параллельно батчами)
|
|
145
|
+
const analysisStart = Date.now();
|
|
146
|
+
this.profiler.start('ANALYSIS');
|
|
147
|
+
this.onProgress({
|
|
148
|
+
phase: 'analysis',
|
|
149
|
+
currentPlugin: 'Starting analysis...',
|
|
150
|
+
message: 'Analyzing all units...',
|
|
151
|
+
totalFiles: unitsToProcess.length,
|
|
152
|
+
processedFiles: 0
|
|
153
|
+
});
|
|
154
|
+
// Check if parallel analysis is enabled (new functionality under flag)
|
|
155
|
+
if (this.parallelConfig?.enabled) {
|
|
156
|
+
await this.runParallelAnalysis(manifest);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// BACKWARD COMPATIBLE: per-unit batch processing (как в JS baseline)
|
|
160
|
+
processedUnits = 0;
|
|
161
|
+
for (let batchStart = 0; batchStart < unitsToProcess.length; batchStart += BATCH_SIZE) {
|
|
162
|
+
const batch = unitsToProcess.slice(batchStart, batchStart + BATCH_SIZE);
|
|
163
|
+
this.onProgress({
|
|
164
|
+
phase: 'analysis',
|
|
165
|
+
currentPlugin: 'Analyzers',
|
|
166
|
+
message: `[${processedUnits + 1}-${processedUnits + batch.length}/${unitsToProcess.length}] Batch analyzing...`,
|
|
167
|
+
totalFiles: unitsToProcess.length,
|
|
168
|
+
processedFiles: processedUnits
|
|
169
|
+
});
|
|
170
|
+
// Параллельно анализируем батч units
|
|
171
|
+
await Promise.all(batch.map(async (unit, idx) => {
|
|
172
|
+
const unitStart = Date.now();
|
|
173
|
+
const unitManifest = {
|
|
174
|
+
projectPath: manifest.projectPath,
|
|
175
|
+
service: {
|
|
176
|
+
...unit,
|
|
177
|
+
id: unit.id,
|
|
178
|
+
name: unit.name,
|
|
179
|
+
path: unit.path
|
|
180
|
+
},
|
|
181
|
+
modules: []
|
|
182
|
+
};
|
|
183
|
+
await this.runPhase('ANALYSIS', { manifest: unitManifest, graph: this.graph, workerCount: 1 });
|
|
184
|
+
const unitTime = ((Date.now() - unitStart) / 1000).toFixed(2);
|
|
185
|
+
console.log(`[Orchestrator] ⏱️ ANALYSIS ${unit.name}: ${unitTime}s`);
|
|
186
|
+
this.onProgress({
|
|
187
|
+
phase: 'analysis',
|
|
188
|
+
currentPlugin: 'Analyzers',
|
|
189
|
+
message: `Analyzed ${unit.name || unit.path} (${unitTime}s)`,
|
|
190
|
+
totalFiles: unitsToProcess.length,
|
|
191
|
+
processedFiles: processedUnits + idx + 1,
|
|
192
|
+
servicesAnalyzed: processedUnits + idx + 1
|
|
193
|
+
});
|
|
194
|
+
}));
|
|
195
|
+
processedUnits += batch.length;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
this.profiler.end('ANALYSIS');
|
|
199
|
+
console.log(`[Orchestrator] ⏱️ ANALYSIS phase total: ${((Date.now() - analysisStart) / 1000).toFixed(2)}s`);
|
|
200
|
+
// PHASE 3: ENRICHMENT - post-processing, граф traversal, вычисления (глобально)
|
|
201
|
+
const enrichmentStart = Date.now();
|
|
202
|
+
this.profiler.start('ENRICHMENT');
|
|
203
|
+
this.onProgress({ phase: 'enrichment', currentPlugin: 'Starting enrichment...', message: 'Enriching graph data...', totalFiles: 0, processedFiles: 0 });
|
|
204
|
+
await this.runPhase('ENRICHMENT', { manifest, graph: this.graph, workerCount: this.workerCount });
|
|
205
|
+
this.profiler.end('ENRICHMENT');
|
|
206
|
+
console.log(`[Orchestrator] ⏱️ ENRICHMENT phase: ${((Date.now() - enrichmentStart) / 1000).toFixed(2)}s`);
|
|
207
|
+
// PHASE 4: VALIDATION - проверка корректности графа (глобально)
|
|
208
|
+
const validationStart = Date.now();
|
|
209
|
+
this.profiler.start('VALIDATION');
|
|
210
|
+
this.onProgress({ phase: 'validation', currentPlugin: 'Starting validation...', message: 'Validating graph structure...', totalFiles: 0, processedFiles: 0 });
|
|
211
|
+
await this.runPhase('VALIDATION', { manifest, graph: this.graph, workerCount: this.workerCount });
|
|
212
|
+
this.profiler.end('VALIDATION');
|
|
213
|
+
console.log(`[Orchestrator] ⏱️ VALIDATION phase: ${((Date.now() - validationStart) / 1000).toFixed(2)}s`);
|
|
214
|
+
// Flush graph to ensure all edges are persisted and queryable
|
|
215
|
+
if (this.graph.flush) {
|
|
216
|
+
await this.graph.flush();
|
|
217
|
+
}
|
|
218
|
+
const totalTime = ((Date.now() - totalStartTime) / 1000).toFixed(2);
|
|
219
|
+
console.log(`[Orchestrator] ⏱️ Total time: ${totalTime}s for ${unitsToProcess.length} units`);
|
|
220
|
+
// Print profiling summary
|
|
221
|
+
this.profiler.printSummary();
|
|
222
|
+
return manifest;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Build unified list of indexing units from services and entrypoints
|
|
226
|
+
* Each unit has: id, name, path, type, and original data
|
|
227
|
+
*/
|
|
228
|
+
buildIndexingUnits(manifest) {
|
|
229
|
+
const units = [];
|
|
230
|
+
const seenPaths = new Set();
|
|
231
|
+
// 1. Add services first (they have priority)
|
|
232
|
+
for (const service of manifest.services || []) {
|
|
233
|
+
const path = service.path || service.metadata?.entrypoint;
|
|
234
|
+
if (path && !seenPaths.has(path)) {
|
|
235
|
+
seenPaths.add(path);
|
|
236
|
+
units.push({
|
|
237
|
+
...service, // Spread first to allow overrides
|
|
238
|
+
id: service.id,
|
|
239
|
+
name: service.name,
|
|
240
|
+
path: path,
|
|
241
|
+
type: 'service',
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// 2. Add entrypoints that aren't already covered by services
|
|
246
|
+
for (const ep of manifest.entrypoints || []) {
|
|
247
|
+
const path = ep.file;
|
|
248
|
+
if (path && !seenPaths.has(path)) {
|
|
249
|
+
seenPaths.add(path);
|
|
250
|
+
units.push({
|
|
251
|
+
...ep, // Spread first to allow overrides
|
|
252
|
+
id: ep.id,
|
|
253
|
+
name: ep.name || ep.file.split('/').pop(),
|
|
254
|
+
path: path,
|
|
255
|
+
type: 'entrypoint',
|
|
256
|
+
entrypointType: ep.type,
|
|
257
|
+
trigger: ep.trigger,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
console.log(`[Orchestrator] Built ${units.length} indexing units (${units.filter(u => u.type === 'service').length} services, ${units.filter(u => u.type === 'entrypoint').length} standalone entrypoints)`);
|
|
262
|
+
return units;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* PHASE 0: Discovery - запуск плагинов DISCOVERY фазы
|
|
266
|
+
*/
|
|
267
|
+
async discover(projectPath) {
|
|
268
|
+
const context = {
|
|
269
|
+
projectPath,
|
|
270
|
+
graph: this.graph,
|
|
271
|
+
config: this.config,
|
|
272
|
+
phase: 'DISCOVERY'
|
|
273
|
+
};
|
|
274
|
+
// Фильтруем плагины для фазы DISCOVERY
|
|
275
|
+
const discoveryPlugins = this.plugins.filter(p => p.metadata.phase === 'DISCOVERY');
|
|
276
|
+
// Сортируем по приоритету
|
|
277
|
+
discoveryPlugins.sort((a, b) => (b.metadata.priority || 0) - (a.metadata.priority || 0));
|
|
278
|
+
const allServices = [];
|
|
279
|
+
const allEntrypoints = [];
|
|
280
|
+
// Выполняем каждый плагин
|
|
281
|
+
for (let i = 0; i < discoveryPlugins.length; i++) {
|
|
282
|
+
const plugin = discoveryPlugins[i];
|
|
283
|
+
this.onProgress({
|
|
284
|
+
phase: 'discovery',
|
|
285
|
+
currentPlugin: plugin.metadata.name,
|
|
286
|
+
message: `Running ${plugin.metadata.name}... (${i + 1}/${discoveryPlugins.length})`
|
|
287
|
+
});
|
|
288
|
+
const result = await plugin.execute(context);
|
|
289
|
+
if (result.success && result.metadata?.services) {
|
|
290
|
+
allServices.push(...result.metadata.services);
|
|
291
|
+
}
|
|
292
|
+
// Collect entrypoints from new-style plugins
|
|
293
|
+
if (result.success && result.metadata?.entrypoints) {
|
|
294
|
+
allEntrypoints.push(...result.metadata.entrypoints);
|
|
295
|
+
}
|
|
296
|
+
this.onProgress({
|
|
297
|
+
phase: 'discovery',
|
|
298
|
+
currentPlugin: plugin.metadata.name,
|
|
299
|
+
message: `✓ ${plugin.metadata.name} complete`
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
services: allServices,
|
|
304
|
+
entrypoints: allEntrypoints,
|
|
305
|
+
projectPath: projectPath
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Запустить плагины для конкретной фазы
|
|
310
|
+
*/
|
|
311
|
+
async runPhase(phaseName, context) {
|
|
312
|
+
// Фильтруем плагины для данной фазы
|
|
313
|
+
const phasePlugins = this.plugins.filter(plugin => plugin.metadata.phase === phaseName);
|
|
314
|
+
// Сортируем по priority (больше = раньше)
|
|
315
|
+
phasePlugins.sort((a, b) => (b.metadata.priority || 0) - (a.metadata.priority || 0));
|
|
316
|
+
// Выполняем плагины последовательно
|
|
317
|
+
for (let i = 0; i < phasePlugins.length; i++) {
|
|
318
|
+
const plugin = phasePlugins[i];
|
|
319
|
+
this.onProgress({
|
|
320
|
+
phase: phaseName.toLowerCase(),
|
|
321
|
+
currentPlugin: plugin.metadata.name,
|
|
322
|
+
message: `Running plugin ${i + 1}/${phasePlugins.length}: ${plugin.metadata.name}`
|
|
323
|
+
});
|
|
324
|
+
// Передаем onProgress и forceAnalysis в контекст для плагинов
|
|
325
|
+
const pluginContext = {
|
|
326
|
+
...context,
|
|
327
|
+
onProgress: this.onProgress,
|
|
328
|
+
forceAnalysis: this.forceAnalysis
|
|
329
|
+
};
|
|
330
|
+
await plugin.execute(pluginContext);
|
|
331
|
+
// Send completion for this plugin
|
|
332
|
+
this.onProgress({
|
|
333
|
+
phase: phaseName.toLowerCase(),
|
|
334
|
+
currentPlugin: plugin.metadata.name,
|
|
335
|
+
message: `✓ ${plugin.metadata.name} complete`
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Run queue-based parallel analysis using worker_threads and RFDB server
|
|
341
|
+
*
|
|
342
|
+
* Architecture:
|
|
343
|
+
* - Tasks are queued per-file with list of applicable plugins
|
|
344
|
+
* - Workers pick tasks, run plugins, write directly to RFDB
|
|
345
|
+
* - Barrier waits for all tasks before ENRICHMENT phase
|
|
346
|
+
*/
|
|
347
|
+
async runParallelAnalysis(manifest) {
|
|
348
|
+
const socketPath = this.parallelConfig.socketPath || '/tmp/rfdb.sock';
|
|
349
|
+
const maxWorkers = this.parallelConfig.maxWorkers || null;
|
|
350
|
+
// Get the database path from the main graph backend
|
|
351
|
+
const mainDbPath = this.graph.dbPath || join(manifest.projectPath, '.grafema', 'graph.rfdb');
|
|
352
|
+
console.log(`[Orchestrator] Starting queue-based parallel analysis...`);
|
|
353
|
+
console.log(`[Orchestrator] Using database: ${mainDbPath}`);
|
|
354
|
+
// Start RFDB server using the SAME database as main graph
|
|
355
|
+
await this.startRfdbServer(socketPath, mainDbPath);
|
|
356
|
+
// Get ANALYSIS plugins that should run in workers
|
|
357
|
+
const analysisPlugins = this.plugins
|
|
358
|
+
.filter(p => p.metadata?.phase === 'ANALYSIS')
|
|
359
|
+
.map(p => p.metadata.name);
|
|
360
|
+
console.log(`[Orchestrator] Analysis plugins: ${analysisPlugins.join(', ')}`);
|
|
361
|
+
// Create analysis queue
|
|
362
|
+
this.analysisQueue = new AnalysisQueue({
|
|
363
|
+
socketPath,
|
|
364
|
+
maxWorkers: maxWorkers || undefined,
|
|
365
|
+
plugins: analysisPlugins,
|
|
366
|
+
});
|
|
367
|
+
// Start workers
|
|
368
|
+
await this.analysisQueue.start();
|
|
369
|
+
// Get all MODULE nodes from graph and queue them
|
|
370
|
+
let moduleCount = 0;
|
|
371
|
+
for await (const node of this.graph.queryNodes({ type: 'MODULE' })) {
|
|
372
|
+
// Skip non-JS/TS files
|
|
373
|
+
if (!node.file?.match(/\.(js|jsx|ts|tsx|mjs|cjs)$/))
|
|
374
|
+
continue;
|
|
375
|
+
this.analysisQueue.addTask({
|
|
376
|
+
file: node.file,
|
|
377
|
+
moduleId: node.id,
|
|
378
|
+
moduleName: node.name,
|
|
379
|
+
plugins: analysisPlugins, // All plugins for now; workers filter by imports
|
|
380
|
+
});
|
|
381
|
+
moduleCount++;
|
|
382
|
+
}
|
|
383
|
+
console.log(`[Orchestrator] Queued ${moduleCount} modules for analysis...`);
|
|
384
|
+
// Subscribe to progress events
|
|
385
|
+
this.analysisQueue.on('taskCompleted', ({ file, stats, duration }) => {
|
|
386
|
+
this.onProgress({
|
|
387
|
+
phase: 'analysis',
|
|
388
|
+
currentPlugin: 'AnalysisQueue',
|
|
389
|
+
message: `${file.split('/').pop()} (${stats?.nodes || 0} nodes, ${duration}ms)`,
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
this.analysisQueue.on('taskFailed', ({ file, error }) => {
|
|
393
|
+
console.error(`[Orchestrator] Analysis failed for ${file}: ${error}`);
|
|
394
|
+
});
|
|
395
|
+
// Wait for all tasks to complete (barrier)
|
|
396
|
+
const stats = await this.analysisQueue.waitForCompletion();
|
|
397
|
+
console.log(`[Orchestrator] Queue complete: ${stats.nodesCreated} nodes, ${stats.edgesCreated} edges`);
|
|
398
|
+
console.log(`[Orchestrator] ${stats.tasksCompleted} succeeded, ${stats.tasksFailed} failed`);
|
|
399
|
+
// Stop workers and server
|
|
400
|
+
await this.analysisQueue.stop();
|
|
401
|
+
this.analysisQueue = null;
|
|
402
|
+
await this.stopRfdbServer();
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Start RFDB server process (or connect to existing one)
|
|
406
|
+
* @param socketPath - Unix socket path for the server
|
|
407
|
+
* @param dbPath - Database path (should be same as main graph)
|
|
408
|
+
*/
|
|
409
|
+
async startRfdbServer(socketPath, dbPath) {
|
|
410
|
+
// Check if server is already running (socket exists and is connectable)
|
|
411
|
+
if (existsSync(socketPath)) {
|
|
412
|
+
// Try to connect to existing server
|
|
413
|
+
try {
|
|
414
|
+
const { RFDBClient } = await import('@grafema/rfdb-client');
|
|
415
|
+
const testClient = new RFDBClient(socketPath);
|
|
416
|
+
await testClient.connect();
|
|
417
|
+
await testClient.ping();
|
|
418
|
+
await testClient.close();
|
|
419
|
+
console.log(`[Orchestrator] Using existing RFDB server at ${socketPath}`);
|
|
420
|
+
this.rfdbServerProcess = null; // Mark that we didn't start the server
|
|
421
|
+
this._serverWasExternal = true;
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
catch (e) {
|
|
425
|
+
// Socket exists but server not responding, remove stale socket
|
|
426
|
+
console.log(`[Orchestrator] Stale socket found, removing...`);
|
|
427
|
+
unlinkSync(socketPath);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
// Check if server binary exists
|
|
431
|
+
const projectRoot = join(dirname(fileURLToPath(import.meta.url)), '../..');
|
|
432
|
+
const serverBinary = join(projectRoot, 'rust-engine/target/release/rfdb-server');
|
|
433
|
+
const debugBinary = join(projectRoot, 'rust-engine/target/debug/rfdb-server');
|
|
434
|
+
let binaryPath = existsSync(serverBinary) ? serverBinary : debugBinary;
|
|
435
|
+
if (!existsSync(binaryPath)) {
|
|
436
|
+
console.log(`[Orchestrator] RFDB server binary not found at ${binaryPath}, building...`);
|
|
437
|
+
execSync('cargo build --bin rfdb-server', {
|
|
438
|
+
cwd: join(projectRoot, 'rust-engine'),
|
|
439
|
+
stdio: 'inherit',
|
|
440
|
+
});
|
|
441
|
+
binaryPath = debugBinary;
|
|
442
|
+
}
|
|
443
|
+
console.log(`[Orchestrator] Starting RFDB server: ${binaryPath} with db: ${dbPath}`);
|
|
444
|
+
this.rfdbServerProcess = spawn(binaryPath, [dbPath, '--socket', socketPath], {
|
|
445
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
446
|
+
});
|
|
447
|
+
this._serverWasExternal = false;
|
|
448
|
+
this.rfdbServerProcess.stderr?.on('data', (data) => {
|
|
449
|
+
const msg = data.toString().trim();
|
|
450
|
+
if (!msg.includes('FLUSH') && !msg.includes('WRITER')) {
|
|
451
|
+
console.log(`[rfdb-server] ${msg}`);
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
// Wait for server to start
|
|
455
|
+
let attempts = 0;
|
|
456
|
+
while (!existsSync(socketPath) && attempts < 30) {
|
|
457
|
+
await sleep(100);
|
|
458
|
+
attempts++;
|
|
459
|
+
}
|
|
460
|
+
if (!existsSync(socketPath)) {
|
|
461
|
+
throw new Error('RFDB server failed to start');
|
|
462
|
+
}
|
|
463
|
+
console.log(`[Orchestrator] RFDB server started on ${socketPath}`);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Stop RFDB server process (only if we started it)
|
|
467
|
+
*/
|
|
468
|
+
async stopRfdbServer() {
|
|
469
|
+
// Don't stop external server (started by MCP or another process)
|
|
470
|
+
if (this._serverWasExternal) {
|
|
471
|
+
console.log(`[Orchestrator] Leaving external RFDB server running`);
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (this.rfdbServerProcess) {
|
|
475
|
+
this.rfdbServerProcess.kill('SIGTERM');
|
|
476
|
+
await sleep(200);
|
|
477
|
+
this.rfdbServerProcess = null;
|
|
478
|
+
console.log(`[Orchestrator] RFDB server stopped`);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clean Graph API for visualization
|
|
3
|
+
* Reads everything directly from RFDB (no caches)
|
|
4
|
+
*/
|
|
5
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
6
|
+
/**
|
|
7
|
+
* Native node from engine
|
|
8
|
+
*/
|
|
9
|
+
interface NativeNode {
|
|
10
|
+
id: bigint;
|
|
11
|
+
kind: number;
|
|
12
|
+
exported: boolean;
|
|
13
|
+
version: number;
|
|
14
|
+
name_offset?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Native edge from engine
|
|
18
|
+
*/
|
|
19
|
+
interface NativeEdge {
|
|
20
|
+
src: bigint;
|
|
21
|
+
dst: bigint;
|
|
22
|
+
etype: number;
|
|
23
|
+
version: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Engine interface
|
|
27
|
+
*/
|
|
28
|
+
interface GraphEngine {
|
|
29
|
+
findByType(type: number): bigint[];
|
|
30
|
+
getNode(id: bigint): NativeNode | null;
|
|
31
|
+
nodeExists(id: bigint): boolean;
|
|
32
|
+
getOutgoingEdges(id: bigint, types: number[] | null): NativeEdge[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Backend interface
|
|
36
|
+
*/
|
|
37
|
+
interface GraphBackend {
|
|
38
|
+
engine: GraphEngine;
|
|
39
|
+
_bigIntToId(id: bigint): string;
|
|
40
|
+
_idToBigInt(id: string): bigint;
|
|
41
|
+
_numberToNodeType(kind: number): string;
|
|
42
|
+
_numberToEdgeType(etype: number): string;
|
|
43
|
+
}
|
|
44
|
+
export declare class GraphAPI {
|
|
45
|
+
private backend;
|
|
46
|
+
private port;
|
|
47
|
+
private server;
|
|
48
|
+
constructor(backend: GraphBackend, port?: number);
|
|
49
|
+
/**
|
|
50
|
+
* Start API server
|
|
51
|
+
*/
|
|
52
|
+
start(): this;
|
|
53
|
+
/**
|
|
54
|
+
* Stop server
|
|
55
|
+
*/
|
|
56
|
+
stop(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Handle HTTP request
|
|
59
|
+
*/
|
|
60
|
+
handleRequest(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* GET /api/services
|
|
63
|
+
* Returns all SERVICE nodes
|
|
64
|
+
*/
|
|
65
|
+
handleGetServices(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* GET /api/node/:id
|
|
68
|
+
* Returns single node by ID
|
|
69
|
+
*/
|
|
70
|
+
handleGetNode(req: IncomingMessage, res: ServerResponse, nodeId: string): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* GET /api/node/:id/children
|
|
73
|
+
* Returns children via CONTAINS edges
|
|
74
|
+
*/
|
|
75
|
+
handleGetChildren(req: IncomingMessage, res: ServerResponse, nodeId: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* GET /api/node/:id/edges
|
|
78
|
+
* Returns all outgoing edges from node
|
|
79
|
+
*/
|
|
80
|
+
handleGetEdges(req: IncomingMessage, res: ServerResponse, nodeId: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Get node name from name_offset (TODO: implement string table lookup)
|
|
83
|
+
*/
|
|
84
|
+
private getNodeName;
|
|
85
|
+
}
|
|
86
|
+
export {};
|
|
87
|
+
//# sourceMappingURL=GraphAPI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphAPI.d.ts","sourceRoot":"","sources":["../../src/api/GraphAPI.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAwB,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAmB7E;;GAEG;AACH,UAAU,UAAU;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,UAAU,WAAW;IACnB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACnC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;IACvC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,UAAU,EAAE,CAAC;CACpE;AAED;;GAEG;AACH,UAAU,YAAY;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACxC,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1C;AAuBD,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,MAAM,CAAgB;gBAElB,OAAO,EAAE,YAAY,EAAE,IAAI,GAAE,MAAa;IAMtD;;OAEG;IACH,KAAK,IAAI,IAAI;IAmBb;;OAEG;IACH,IAAI,IAAI,IAAI;IAOZ;;OAEG;IACG,aAAa,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6C7E;;;OAGG;IACG,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBjF;;;OAGG;IACG,aAAa,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB7F;;;OAGG;IACG,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkCjG;;;OAGG;IACG,cAAc,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4B9F;;OAEG;IACH,OAAO,CAAC,WAAW;CAKpB"}
|