/** * Rule Graph Engine * * Builds and manages a directed graph of rules with dependencies, * computes execution order, and detects cycles/conflicts (Enhancement #4). */ import type { ArkaRuleWithGraph, RuleRelationship, RuleGraphAnalysis, RuleConflict } from '@arka-protocol/types'; /** * Rule Graph class for managing rule dependencies and execution order */ export declare class RuleGraph { private nodes; private edges; private relationships; /** * Create a new RuleGraph from a set of rules */ constructor(rules?: ArkaRuleWithGraph[]); /** * Add a rule to the graph */ addRule(rule: ArkaRuleWithGraph): void; /** * Remove a rule from the graph */ removeRule(ruleId: string): boolean; /** * Add a relationship between rules */ addRelationship(relationship: RuleRelationship): void; /** * Build edges from rule metadata (dependsOnRules, overridesRules) */ private buildEdgesFromMetadata; /** * Compute execution order using topological sort (Kahn's algorithm) */ computeExecutionOrder(): string[]; /** * Detect cycles in the graph using DFS */ detectCycles(): string[][]; /** * Detect conflicts between rules */ detectConflicts(): RuleConflict[]; /** * Check if two rules conflict */ private checkForConflict; /** * Check if two rules could apply to the same events */ private rulesOverlap; /** * Heuristic check if conditions might overlap */ private conditionsMightOverlap; /** * Extract field paths from a condition tree */ private extractFields; /** * Compute dependency levels for parallel execution */ computeLevels(): string[][]; /** * Get full analysis of the rule graph */ analyze(): RuleGraphAnalysis; /** * Get rules in execution order */ getRulesInOrder(): ArkaRuleWithGraph[]; /** * Get all rules */ getAllRules(): ArkaRuleWithGraph[]; /** * Get a rule by ID */ getRule(ruleId: string): ArkaRuleWithGraph | undefined; /** * Get rules that depend on a given rule */ getDependents(ruleId: string): ArkaRuleWithGraph[]; /** * Get rules that a given rule depends on */ getDependencies(ruleId: string): ArkaRuleWithGraph[]; /** * Validate the graph structure */ validate(): { valid: boolean; errors: string[]; }; /** * Export graph to DOT format for visualization */ toDot(): string; private getSeverityColor; /** * Serialize graph to JSON */ toJSON(): object; /** * Create graph from JSON */ static fromJSON(json: { nodes: Array<{ id: string; rule: ArkaRuleWithGraph; }>; relationships: RuleRelationship[]; }): RuleGraph; } /** * Create a rule graph from an array of rules */ export declare function createRuleGraph(rules: ArkaRuleWithGraph[]): RuleGraph; /** * Analyze rules and return execution plan */ export declare function analyzeRules(rules: ArkaRuleWithGraph[]): RuleGraphAnalysis; //# sourceMappingURL=RuleGraph.d.ts.map