/** * Multi-Jurisdiction Harmonization Engine * * Manages overlapping jurisdictions and creates unified rule interpretations * based on geographic, entity type, and regulatory hierarchy (Enhancement #6). */ import type { ArkaRule, RuleSeverity } from '@arka-protocol/types'; /** * Jurisdiction definition */ export interface Jurisdiction { /** Unique identifier (e.g., "US", "US-CA", "EU", "EU-DE") */ id: string; /** Human-readable name */ name: string; /** Parent jurisdiction (e.g., "US-CA" parent is "US") */ parentId?: string; /** Jurisdiction type */ type: 'FEDERAL' | 'STATE' | 'REGIONAL' | 'LOCAL' | 'INTERNATIONAL' | 'SUPRANATIONAL'; /** ISO country code if applicable */ countryCode?: string; /** Regulatory bodies in this jurisdiction */ regulatoryBodies: string[]; /** Priority when multiple jurisdictions conflict (higher = takes precedence) */ priority: number; /** Whether this jurisdiction is active */ active: boolean; /** Metadata */ metadata?: Record; } /** * Jurisdiction hierarchy node */ interface JurisdictionNode { jurisdiction: Jurisdiction; children: JurisdictionNode[]; parent?: JurisdictionNode; depth: number; } /** * Rule resolution result when jurisdictions overlap */ export interface JurisdictionResolution { /** Applicable jurisdictions (in priority order) */ applicableJurisdictions: Jurisdiction[]; /** Resolved rules after harmonization */ resolvedRules: ArkaRule[]; /** Conflicts detected */ conflicts: JurisdictionConflict[]; /** Resolution strategy used */ strategy: ResolutionStrategy; /** Audit trail */ auditTrail: ResolutionAuditEntry[]; } /** * Conflict between jurisdiction rules */ export interface JurisdictionConflict { /** Jurisdictions in conflict */ jurisdictions: string[]; /** Rules in conflict */ ruleIds: string[]; /** Type of conflict */ conflictType: 'CONTRADICTING' | 'OVERLAPPING' | 'AMBIGUOUS'; /** Description */ description: string; /** How it was resolved */ resolution: string; /** Severity of the conflict */ severity: RuleSeverity; } /** * Audit entry for resolution decisions */ export interface ResolutionAuditEntry { /** Timestamp */ timestamp: string; /** Action taken */ action: string; /** Reason for the action */ reason: string; /** Rules affected */ affectedRules: string[]; /** Jurisdictions involved */ jurisdictions: string[]; } /** * Resolution strategy options */ export type ResolutionStrategy = 'MOST_RESTRICTIVE' | 'LEAST_RESTRICTIVE' | 'HIERARCHY' | 'PRIORITY' | 'INTERSECTION' | 'UNION'; /** * Harmonization Engine options */ export interface HarmonizationOptions { /** Default resolution strategy */ defaultStrategy: ResolutionStrategy; /** Whether to include rules from parent jurisdictions */ includeParentRules: boolean; /** Whether to automatically resolve conflicts */ autoResolveConflicts: boolean; /** Minimum severity for conflict detection */ conflictThreshold: RuleSeverity; } /** * Multi-Jurisdiction Harmonization Engine */ export declare class JurisdictionHarmonizationEngine { private jurisdictions; private tree; private rules; private options; constructor(options?: Partial); /** * Register a jurisdiction */ registerJurisdiction(jurisdiction: Jurisdiction): void; /** * Register multiple jurisdictions */ registerJurisdictions(jurisdictions: Jurisdiction[]): void; /** * Register rules for a jurisdiction */ registerRules(jurisdictionId: string, rules: ArkaRule[]): void; /** * Get all rules for a jurisdiction (including parents if configured) */ getRulesForJurisdiction(jurisdictionId: string): ArkaRule[]; /** * Resolve rules for multiple overlapping jurisdictions */ resolveRules(jurisdictionIds: string[], strategy?: ResolutionStrategy): JurisdictionResolution; /** * Get applicable jurisdictions in priority order */ private getApplicableJurisdictions; /** * Detect conflict between rule versions */ private detectConflict; /** * Resolve conflict using the specified strategy */ private resolveConflict; /** * Select most restrictive rule (DENY > FLAG > ALLOW) */ private selectMostRestrictive; /** * Select least restrictive rule */ private selectLeastRestrictive; /** * Select by jurisdiction hierarchy (child overrides parent) */ private selectByHierarchy; /** * Select by jurisdiction priority */ private selectByPriority; /** * Get depth of a jurisdiction in the hierarchy */ private getDepth; /** * Get highest severity from a list */ private getHighestSeverity; /** * Rebuild jurisdiction hierarchy tree */ private rebuildTree; /** * Get jurisdiction hierarchy as tree structure */ getHierarchy(): JurisdictionNode[]; /** * Get all registered jurisdictions */ getAllJurisdictions(): Jurisdiction[]; /** * Get a specific jurisdiction */ getJurisdiction(id: string): Jurisdiction | undefined; /** * Check if a jurisdiction is a descendant of another */ isDescendantOf(childId: string, ancestorId: string): boolean; /** * Get common ancestors of multiple jurisdictions */ getCommonAncestors(jurisdictionIds: string[]): Jurisdiction[]; /** * Export configuration */ exportConfig(): { jurisdictions: Jurisdiction[]; rules: Array<{ jurisdictionId: string; rules: ArkaRule[]; }>; options: HarmonizationOptions; }; /** * Import configuration */ importConfig(config: { jurisdictions: Jurisdiction[]; rules: Array<{ jurisdictionId: string; rules: ArkaRule[]; }>; options?: Partial; }): void; } /** * Create a new harmonization engine */ export declare function createHarmonizationEngine(options?: Partial): JurisdictionHarmonizationEngine; /** * Pre-built jurisdiction definitions for common regions */ export declare const COMMON_JURISDICTIONS: Jurisdiction[]; export {}; //# sourceMappingURL=jurisdictionEngine.d.ts.map