agentic-qe 2.7.3 → 2.8.0
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/CHANGELOG.md +130 -0
- package/README.md +67 -2
- package/dist/agents/AccessibilityAllyAgent.d.ts +0 -7
- package/dist/agents/AccessibilityAllyAgent.d.ts.map +1 -1
- package/dist/agents/AccessibilityAllyAgent.js +0 -15
- package/dist/agents/AccessibilityAllyAgent.js.map +1 -1
- package/dist/agents/ApiContractValidatorAgent.js +4 -4
- package/dist/agents/ApiContractValidatorAgent.js.map +1 -1
- package/dist/agents/BaseAgent.d.ts +2 -0
- package/dist/agents/BaseAgent.d.ts.map +1 -1
- package/dist/agents/BaseAgent.js +43 -41
- package/dist/agents/BaseAgent.js.map +1 -1
- package/dist/agents/CodeComplexityAnalyzerAgent.d.ts +0 -8
- package/dist/agents/CodeComplexityAnalyzerAgent.d.ts.map +1 -1
- package/dist/agents/CodeComplexityAnalyzerAgent.js +0 -15
- package/dist/agents/CodeComplexityAnalyzerAgent.js.map +1 -1
- package/dist/agents/CodeIntelligenceAgent.d.ts +0 -1
- package/dist/agents/CodeIntelligenceAgent.d.ts.map +1 -1
- package/dist/agents/CodeIntelligenceAgent.js +0 -2
- package/dist/agents/CodeIntelligenceAgent.js.map +1 -1
- package/dist/agents/DeploymentReadinessAgent.d.ts.map +1 -1
- package/dist/agents/DeploymentReadinessAgent.js +30 -30
- package/dist/agents/DeploymentReadinessAgent.js.map +1 -1
- package/dist/agents/FlakyTestHunterAgent.d.ts +0 -10
- package/dist/agents/FlakyTestHunterAgent.d.ts.map +1 -1
- package/dist/agents/FlakyTestHunterAgent.js +10 -20
- package/dist/agents/FlakyTestHunterAgent.js.map +1 -1
- package/dist/agents/FleetCommanderAgent.d.ts.map +1 -1
- package/dist/agents/FleetCommanderAgent.js +28 -28
- package/dist/agents/FleetCommanderAgent.js.map +1 -1
- package/dist/agents/LearningAgent.js +1 -1
- package/dist/agents/LearningAgent.js.map +1 -1
- package/dist/agents/PerformanceTesterAgent.d.ts.map +1 -1
- package/dist/agents/PerformanceTesterAgent.js +25 -25
- package/dist/agents/PerformanceTesterAgent.js.map +1 -1
- package/dist/agents/ProductionIntelligenceAgent.d.ts.map +1 -1
- package/dist/agents/ProductionIntelligenceAgent.js +20 -20
- package/dist/agents/ProductionIntelligenceAgent.js.map +1 -1
- package/dist/agents/QXPartnerAgent.d.ts +0 -8
- package/dist/agents/QXPartnerAgent.d.ts.map +1 -1
- package/dist/agents/QXPartnerAgent.js +0 -15
- package/dist/agents/QXPartnerAgent.js.map +1 -1
- package/dist/agents/QualityAnalyzerAgent.d.ts +0 -7
- package/dist/agents/QualityAnalyzerAgent.d.ts.map +1 -1
- package/dist/agents/QualityAnalyzerAgent.js +0 -16
- package/dist/agents/QualityAnalyzerAgent.js.map +1 -1
- package/dist/agents/RegressionRiskAnalyzerAgent.d.ts.map +1 -1
- package/dist/agents/RegressionRiskAnalyzerAgent.js +18 -18
- package/dist/agents/RegressionRiskAnalyzerAgent.js.map +1 -1
- package/dist/agents/RequirementsValidatorAgent.d.ts.map +1 -1
- package/dist/agents/RequirementsValidatorAgent.js +21 -21
- package/dist/agents/RequirementsValidatorAgent.js.map +1 -1
- package/dist/agents/SecurityScannerAgent.d.ts.map +1 -1
- package/dist/agents/SecurityScannerAgent.js +38 -38
- package/dist/agents/SecurityScannerAgent.js.map +1 -1
- package/dist/agents/TestDataArchitectAgent.d.ts.map +1 -1
- package/dist/agents/TestDataArchitectAgent.js +29 -29
- package/dist/agents/TestDataArchitectAgent.js.map +1 -1
- package/dist/agents/TestExecutorAgent.d.ts +0 -7
- package/dist/agents/TestExecutorAgent.d.ts.map +1 -1
- package/dist/agents/TestExecutorAgent.js +35 -51
- package/dist/agents/TestExecutorAgent.js.map +1 -1
- package/dist/agents/TestGeneratorAgent.d.ts +0 -7
- package/dist/agents/TestGeneratorAgent.d.ts.map +1 -1
- package/dist/agents/TestGeneratorAgent.js +0 -16
- package/dist/agents/TestGeneratorAgent.js.map +1 -1
- package/dist/agents/adapters/AgentLLMAdapter.d.ts.map +1 -1
- package/dist/agents/adapters/AgentLLMAdapter.js +5 -4
- package/dist/agents/adapters/AgentLLMAdapter.js.map +1 -1
- package/dist/agents/adapters/CoordinatorAdapter.d.ts.map +1 -1
- package/dist/agents/adapters/CoordinatorAdapter.js +2 -1
- package/dist/agents/adapters/CoordinatorAdapter.js.map +1 -1
- package/dist/agents/n8n/N8nAPIClient.d.ts.map +1 -1
- package/dist/agents/n8n/N8nAPIClient.js +3 -2
- package/dist/agents/n8n/N8nAPIClient.js.map +1 -1
- package/dist/agents/n8n/N8nAuditPersistence.d.ts.map +1 -1
- package/dist/agents/n8n/N8nAuditPersistence.js +2 -1
- package/dist/agents/n8n/N8nAuditPersistence.js.map +1 -1
- package/dist/agents/n8n/N8nBaseAgent.js +1 -1
- package/dist/agents/n8n/N8nBaseAgent.js.map +1 -1
- package/dist/agents/n8n/N8nComplianceValidatorAgent.js +1 -1
- package/dist/agents/n8n/N8nComplianceValidatorAgent.js.map +1 -1
- package/dist/agents/n8n/N8nMonitoringValidatorAgent.js +1 -1
- package/dist/agents/n8n/N8nMonitoringValidatorAgent.js.map +1 -1
- package/dist/agents/n8n/N8nReplayabilityTesterAgent.js +1 -1
- package/dist/agents/n8n/N8nReplayabilityTesterAgent.js.map +1 -1
- package/dist/agents/n8n/N8nSecurityAuditorAgent.js +1 -1
- package/dist/agents/n8n/N8nSecurityAuditorAgent.js.map +1 -1
- package/dist/agents/pool/AgentPool.d.ts.map +1 -1
- package/dist/agents/pool/AgentPool.js +2 -1
- package/dist/agents/pool/AgentPool.js.map +1 -1
- package/dist/agents/pool/QEAgentPoolFactory.d.ts.map +1 -1
- package/dist/agents/pool/QEAgentPoolFactory.js +2 -1
- package/dist/agents/pool/QEAgentPoolFactory.js.map +1 -1
- package/dist/cli/commands/agent/spawn.d.ts +12 -1
- package/dist/cli/commands/agent/spawn.d.ts.map +1 -1
- package/dist/cli/commands/agent/spawn.js +95 -8
- package/dist/cli/commands/agent/spawn.js.map +1 -1
- package/dist/cli/index.js +91 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/core/memory/HNSWVectorMemory.js +1 -1
- package/dist/edge/adapters/BrowserHNSWAdapter.d.ts +134 -0
- package/dist/edge/adapters/BrowserHNSWAdapter.d.ts.map +1 -0
- package/dist/edge/adapters/BrowserHNSWAdapter.js +484 -0
- package/dist/edge/adapters/BrowserHNSWAdapter.js.map +1 -0
- package/dist/edge/adapters/IndexedDBStorage.d.ts +114 -0
- package/dist/edge/adapters/IndexedDBStorage.d.ts.map +1 -0
- package/dist/edge/adapters/IndexedDBStorage.js +478 -0
- package/dist/edge/adapters/IndexedDBStorage.js.map +1 -0
- package/dist/edge/adapters/index.d.ts +12 -0
- package/dist/edge/adapters/index.d.ts.map +1 -0
- package/dist/edge/adapters/index.js +22 -0
- package/dist/edge/adapters/index.js.map +1 -0
- package/dist/edge/browser/BrowserAgent.d.ts +241 -0
- package/dist/edge/browser/BrowserAgent.d.ts.map +1 -0
- package/dist/edge/browser/BrowserAgent.js +743 -0
- package/dist/edge/browser/BrowserAgent.js.map +1 -0
- package/dist/edge/index.d.ts +34 -0
- package/dist/edge/index.d.ts.map +1 -0
- package/dist/edge/index.js +114 -0
- package/dist/edge/index.js.map +1 -0
- package/dist/edge/p2p/coordination/CoordinationManager.d.ts +181 -0
- package/dist/edge/p2p/coordination/CoordinationManager.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/CoordinationManager.js +851 -0
- package/dist/edge/p2p/coordination/CoordinationManager.js.map +1 -0
- package/dist/edge/p2p/coordination/HealthMonitor.d.ts +143 -0
- package/dist/edge/p2p/coordination/HealthMonitor.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/HealthMonitor.js +432 -0
- package/dist/edge/p2p/coordination/HealthMonitor.js.map +1 -0
- package/dist/edge/p2p/coordination/SyncOrchestrator.d.ts +146 -0
- package/dist/edge/p2p/coordination/SyncOrchestrator.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/SyncOrchestrator.js +783 -0
- package/dist/edge/p2p/coordination/SyncOrchestrator.js.map +1 -0
- package/dist/edge/p2p/coordination/index.d.ts +70 -0
- package/dist/edge/p2p/coordination/index.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/index.js +107 -0
- package/dist/edge/p2p/coordination/index.js.map +1 -0
- package/dist/edge/p2p/coordination/types.d.ts +572 -0
- package/dist/edge/p2p/coordination/types.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/types.js +366 -0
- package/dist/edge/p2p/coordination/types.js.map +1 -0
- package/dist/edge/p2p/crdt/CRDTStore.d.ts +324 -0
- package/dist/edge/p2p/crdt/CRDTStore.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/CRDTStore.js +839 -0
- package/dist/edge/p2p/crdt/CRDTStore.js.map +1 -0
- package/dist/edge/p2p/crdt/GCounter.d.ts +173 -0
- package/dist/edge/p2p/crdt/GCounter.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/GCounter.js +394 -0
- package/dist/edge/p2p/crdt/GCounter.js.map +1 -0
- package/dist/edge/p2p/crdt/LWWRegister.d.ts +200 -0
- package/dist/edge/p2p/crdt/LWWRegister.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/LWWRegister.js +456 -0
- package/dist/edge/p2p/crdt/LWWRegister.js.map +1 -0
- package/dist/edge/p2p/crdt/ORSet.d.ts +232 -0
- package/dist/edge/p2p/crdt/ORSet.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/ORSet.js +723 -0
- package/dist/edge/p2p/crdt/ORSet.js.map +1 -0
- package/dist/edge/p2p/crdt/PatternCRDT.d.ts +366 -0
- package/dist/edge/p2p/crdt/PatternCRDT.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/PatternCRDT.js +838 -0
- package/dist/edge/p2p/crdt/PatternCRDT.js.map +1 -0
- package/dist/edge/p2p/crdt/VectorClock.d.ts +274 -0
- package/dist/edge/p2p/crdt/VectorClock.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/VectorClock.js +499 -0
- package/dist/edge/p2p/crdt/VectorClock.js.map +1 -0
- package/dist/edge/p2p/crdt/index.d.ts +87 -0
- package/dist/edge/p2p/crdt/index.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/index.js +120 -0
- package/dist/edge/p2p/crdt/index.js.map +1 -0
- package/dist/edge/p2p/crdt/types.d.ts +667 -0
- package/dist/edge/p2p/crdt/types.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/types.js +208 -0
- package/dist/edge/p2p/crdt/types.js.map +1 -0
- package/dist/edge/p2p/crypto/Identity.d.ts +139 -0
- package/dist/edge/p2p/crypto/Identity.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/Identity.js +449 -0
- package/dist/edge/p2p/crypto/Identity.js.map +1 -0
- package/dist/edge/p2p/crypto/KeyManager.d.ts +196 -0
- package/dist/edge/p2p/crypto/KeyManager.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/KeyManager.js +576 -0
- package/dist/edge/p2p/crypto/KeyManager.js.map +1 -0
- package/dist/edge/p2p/crypto/Signer.d.ts +164 -0
- package/dist/edge/p2p/crypto/Signer.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/Signer.js +357 -0
- package/dist/edge/p2p/crypto/Signer.js.map +1 -0
- package/dist/edge/p2p/crypto/index.d.ts +90 -0
- package/dist/edge/p2p/crypto/index.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/index.js +158 -0
- package/dist/edge/p2p/crypto/index.js.map +1 -0
- package/dist/edge/p2p/crypto/types.d.ts +217 -0
- package/dist/edge/p2p/crypto/types.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/types.js +42 -0
- package/dist/edge/p2p/crypto/types.js.map +1 -0
- package/dist/edge/p2p/federated/FederatedCoordinator.d.ts +270 -0
- package/dist/edge/p2p/federated/FederatedCoordinator.d.ts.map +1 -0
- package/dist/edge/p2p/federated/FederatedCoordinator.js +824 -0
- package/dist/edge/p2p/federated/FederatedCoordinator.js.map +1 -0
- package/dist/edge/p2p/federated/FederatedRound.d.ts +295 -0
- package/dist/edge/p2p/federated/FederatedRound.d.ts.map +1 -0
- package/dist/edge/p2p/federated/FederatedRound.js +819 -0
- package/dist/edge/p2p/federated/FederatedRound.js.map +1 -0
- package/dist/edge/p2p/federated/GradientAggregator.d.ts +226 -0
- package/dist/edge/p2p/federated/GradientAggregator.d.ts.map +1 -0
- package/dist/edge/p2p/federated/GradientAggregator.js +826 -0
- package/dist/edge/p2p/federated/GradientAggregator.js.map +1 -0
- package/dist/edge/p2p/federated/ModelManager.d.ts +248 -0
- package/dist/edge/p2p/federated/ModelManager.d.ts.map +1 -0
- package/dist/edge/p2p/federated/ModelManager.js +724 -0
- package/dist/edge/p2p/federated/ModelManager.js.map +1 -0
- package/dist/edge/p2p/federated/index.d.ts +65 -0
- package/dist/edge/p2p/federated/index.d.ts.map +1 -0
- package/dist/edge/p2p/federated/index.js +110 -0
- package/dist/edge/p2p/federated/index.js.map +1 -0
- package/dist/edge/p2p/federated/types.d.ts +905 -0
- package/dist/edge/p2p/federated/types.d.ts.map +1 -0
- package/dist/edge/p2p/federated/types.js +339 -0
- package/dist/edge/p2p/federated/types.js.map +1 -0
- package/dist/edge/p2p/index.d.ts +156 -0
- package/dist/edge/p2p/index.d.ts.map +1 -0
- package/dist/edge/p2p/index.js +242 -0
- package/dist/edge/p2p/index.js.map +1 -0
- package/dist/edge/p2p/nat/ConnectivityTester.d.ts +128 -0
- package/dist/edge/p2p/nat/ConnectivityTester.d.ts.map +1 -0
- package/dist/edge/p2p/nat/ConnectivityTester.js +560 -0
- package/dist/edge/p2p/nat/ConnectivityTester.js.map +1 -0
- package/dist/edge/p2p/nat/HolePuncher.d.ts +159 -0
- package/dist/edge/p2p/nat/HolePuncher.d.ts.map +1 -0
- package/dist/edge/p2p/nat/HolePuncher.js +569 -0
- package/dist/edge/p2p/nat/HolePuncher.js.map +1 -0
- package/dist/edge/p2p/nat/NATDetector.d.ts +109 -0
- package/dist/edge/p2p/nat/NATDetector.d.ts.map +1 -0
- package/dist/edge/p2p/nat/NATDetector.js +472 -0
- package/dist/edge/p2p/nat/NATDetector.js.map +1 -0
- package/dist/edge/p2p/nat/TURNManager.d.ts +158 -0
- package/dist/edge/p2p/nat/TURNManager.d.ts.map +1 -0
- package/dist/edge/p2p/nat/TURNManager.js +547 -0
- package/dist/edge/p2p/nat/TURNManager.js.map +1 -0
- package/dist/edge/p2p/nat/index.d.ts +74 -0
- package/dist/edge/p2p/nat/index.d.ts.map +1 -0
- package/dist/edge/p2p/nat/index.js +104 -0
- package/dist/edge/p2p/nat/index.js.map +1 -0
- package/dist/edge/p2p/nat/types.d.ts +583 -0
- package/dist/edge/p2p/nat/types.d.ts.map +1 -0
- package/dist/edge/p2p/nat/types.js +267 -0
- package/dist/edge/p2p/nat/types.js.map +1 -0
- package/dist/edge/p2p/protocol/AgentChannel.d.ts +333 -0
- package/dist/edge/p2p/protocol/AgentChannel.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/AgentChannel.js +914 -0
- package/dist/edge/p2p/protocol/AgentChannel.js.map +1 -0
- package/dist/edge/p2p/protocol/MessageEncoder.d.ts +147 -0
- package/dist/edge/p2p/protocol/MessageEncoder.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/MessageEncoder.js +738 -0
- package/dist/edge/p2p/protocol/MessageEncoder.js.map +1 -0
- package/dist/edge/p2p/protocol/MessageRouter.d.ts +266 -0
- package/dist/edge/p2p/protocol/MessageRouter.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/MessageRouter.js +808 -0
- package/dist/edge/p2p/protocol/MessageRouter.js.map +1 -0
- package/dist/edge/p2p/protocol/ProtocolHandler.d.ts +309 -0
- package/dist/edge/p2p/protocol/ProtocolHandler.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/ProtocolHandler.js +930 -0
- package/dist/edge/p2p/protocol/ProtocolHandler.js.map +1 -0
- package/dist/edge/p2p/protocol/index.d.ts +114 -0
- package/dist/edge/p2p/protocol/index.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/index.js +206 -0
- package/dist/edge/p2p/protocol/index.js.map +1 -0
- package/dist/edge/p2p/protocol/types.d.ts +737 -0
- package/dist/edge/p2p/protocol/types.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/types.js +490 -0
- package/dist/edge/p2p/protocol/types.js.map +1 -0
- package/dist/edge/p2p/sharing/PatternBroadcaster.d.ts +284 -0
- package/dist/edge/p2p/sharing/PatternBroadcaster.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/PatternBroadcaster.js +644 -0
- package/dist/edge/p2p/sharing/PatternBroadcaster.js.map +1 -0
- package/dist/edge/p2p/sharing/PatternIndex.d.ts +168 -0
- package/dist/edge/p2p/sharing/PatternIndex.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/PatternIndex.js +781 -0
- package/dist/edge/p2p/sharing/PatternIndex.js.map +1 -0
- package/dist/edge/p2p/sharing/PatternSerializer.d.ts +163 -0
- package/dist/edge/p2p/sharing/PatternSerializer.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/PatternSerializer.js +696 -0
- package/dist/edge/p2p/sharing/PatternSerializer.js.map +1 -0
- package/dist/edge/p2p/sharing/PatternSyncManager.d.ts +242 -0
- package/dist/edge/p2p/sharing/PatternSyncManager.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/PatternSyncManager.js +859 -0
- package/dist/edge/p2p/sharing/PatternSyncManager.js.map +1 -0
- package/dist/edge/p2p/sharing/index.d.ts +90 -0
- package/dist/edge/p2p/sharing/index.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/index.js +152 -0
- package/dist/edge/p2p/sharing/index.js.map +1 -0
- package/dist/edge/p2p/sharing/types.d.ts +796 -0
- package/dist/edge/p2p/sharing/types.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/types.js +264 -0
- package/dist/edge/p2p/sharing/types.js.map +1 -0
- package/dist/edge/p2p/webrtc/ConnectionPool.d.ts +218 -0
- package/dist/edge/p2p/webrtc/ConnectionPool.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/ConnectionPool.js +562 -0
- package/dist/edge/p2p/webrtc/ConnectionPool.js.map +1 -0
- package/dist/edge/p2p/webrtc/ICEManager.d.ts +171 -0
- package/dist/edge/p2p/webrtc/ICEManager.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/ICEManager.js +490 -0
- package/dist/edge/p2p/webrtc/ICEManager.js.map +1 -0
- package/dist/edge/p2p/webrtc/PeerConnectionManager.d.ts +159 -0
- package/dist/edge/p2p/webrtc/PeerConnectionManager.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/PeerConnectionManager.js +735 -0
- package/dist/edge/p2p/webrtc/PeerConnectionManager.js.map +1 -0
- package/dist/edge/p2p/webrtc/SignalingClient.d.ts +191 -0
- package/dist/edge/p2p/webrtc/SignalingClient.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/SignalingClient.js +608 -0
- package/dist/edge/p2p/webrtc/SignalingClient.js.map +1 -0
- package/dist/edge/p2p/webrtc/index.d.ts +158 -0
- package/dist/edge/p2p/webrtc/index.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/index.js +164 -0
- package/dist/edge/p2p/webrtc/index.js.map +1 -0
- package/dist/edge/p2p/webrtc/types.d.ts +665 -0
- package/dist/edge/p2p/webrtc/types.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/types.js +245 -0
- package/dist/edge/p2p/webrtc/types.js.map +1 -0
- package/dist/edge/server/AgentSpawnAPI.d.ts +98 -0
- package/dist/edge/server/AgentSpawnAPI.d.ts.map +1 -0
- package/dist/edge/server/AgentSpawnAPI.js +264 -0
- package/dist/edge/server/AgentSpawnAPI.js.map +1 -0
- package/dist/edge/server/SignalingServer.d.ts +71 -0
- package/dist/edge/server/SignalingServer.d.ts.map +1 -0
- package/dist/edge/server/SignalingServer.js +429 -0
- package/dist/edge/server/SignalingServer.js.map +1 -0
- package/dist/edge/server/index.d.ts +64 -0
- package/dist/edge/server/index.d.ts.map +1 -0
- package/dist/edge/server/index.js +318 -0
- package/dist/edge/server/index.js.map +1 -0
- package/dist/edge/types/browser-agent.types.d.ts +455 -0
- package/dist/edge/types/browser-agent.types.d.ts.map +1 -0
- package/dist/edge/types/browser-agent.types.js +116 -0
- package/dist/edge/types/browser-agent.types.js.map +1 -0
- package/dist/edge/types/index.d.ts +11 -0
- package/dist/edge/types/index.d.ts.map +1 -0
- package/dist/edge/types/index.js +17 -0
- package/dist/edge/types/index.js.map +1 -0
- package/dist/edge/types/storage.types.d.ts +207 -0
- package/dist/edge/types/storage.types.d.ts.map +1 -0
- package/dist/edge/types/storage.types.js +47 -0
- package/dist/edge/types/storage.types.js.map +1 -0
- package/dist/edge/wasm/shims.d.ts +224 -0
- package/dist/edge/wasm/shims.d.ts.map +1 -0
- package/dist/edge/wasm/shims.js +667 -0
- package/dist/edge/wasm/shims.js.map +1 -0
- package/dist/mcp/handlers/NewDomainToolsHandler.d.ts +33 -0
- package/dist/mcp/handlers/NewDomainToolsHandler.d.ts.map +1 -0
- package/dist/mcp/handlers/NewDomainToolsHandler.js +305 -0
- package/dist/mcp/handlers/NewDomainToolsHandler.js.map +1 -0
- package/dist/mcp/handlers/filtered/index.d.ts +15 -19
- package/dist/mcp/handlers/filtered/index.d.ts.map +1 -1
- package/dist/mcp/handlers/filtered/index.js +16 -27
- package/dist/mcp/handlers/filtered/index.js.map +1 -1
- package/dist/mcp/handlers/integration/index.d.ts +5 -4
- package/dist/mcp/handlers/integration/index.d.ts.map +1 -1
- package/dist/mcp/handlers/integration/index.js +7 -7
- package/dist/mcp/handlers/integration/index.js.map +1 -1
- package/dist/mcp/server-instructions.d.ts +1 -1
- package/dist/mcp/server-instructions.js +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +14 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts +8 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +412 -1
- package/dist/mcp/tools.js.map +1 -1
- package/dist/persistence/migrations/all-migrations.d.ts.map +1 -1
- package/dist/persistence/migrations/all-migrations.js +44 -1
- package/dist/persistence/migrations/all-migrations.js.map +1 -1
- package/dist/planning/GOAPPlanner.d.ts +1 -0
- package/dist/planning/GOAPPlanner.d.ts.map +1 -1
- package/dist/planning/GOAPPlanner.js +15 -2
- package/dist/planning/GOAPPlanner.js.map +1 -1
- package/dist/planning/PlanLearning.d.ts.map +1 -1
- package/dist/planning/PlanLearning.js +2 -1
- package/dist/planning/PlanLearning.js.map +1 -1
- package/dist/planning/PlanSimilarity.d.ts.map +1 -1
- package/dist/planning/PlanSimilarity.js +2 -1
- package/dist/planning/PlanSimilarity.js.map +1 -1
- package/package.json +29 -8
- package/dist/alerting/AlertManager.d.ts +0 -120
- package/dist/alerting/AlertManager.d.ts.map +0 -1
- package/dist/alerting/AlertManager.js +0 -345
- package/dist/alerting/AlertManager.js.map +0 -1
- package/dist/alerting/FeedbackRouter.d.ts +0 -98
- package/dist/alerting/FeedbackRouter.d.ts.map +0 -1
- package/dist/alerting/FeedbackRouter.js +0 -331
- package/dist/alerting/FeedbackRouter.js.map +0 -1
- package/dist/alerting/StrategyApplicator.d.ts +0 -120
- package/dist/alerting/StrategyApplicator.d.ts.map +0 -1
- package/dist/alerting/StrategyApplicator.js +0 -299
- package/dist/alerting/StrategyApplicator.js.map +0 -1
- package/dist/alerting/index.d.ts +0 -68
- package/dist/alerting/index.d.ts.map +0 -1
- package/dist/alerting/index.js +0 -112
- package/dist/alerting/index.js.map +0 -1
- package/dist/alerting/types.d.ts +0 -118
- package/dist/alerting/types.d.ts.map +0 -1
- package/dist/alerting/types.js +0 -11
- package/dist/alerting/types.js.map +0 -1
- package/dist/cli/commands/fleet/backup.d.ts +0 -49
- package/dist/cli/commands/fleet/backup.d.ts.map +0 -1
- package/dist/cli/commands/fleet/backup.js +0 -88
- package/dist/cli/commands/fleet/backup.js.map +0 -1
- package/dist/cli/commands/fleet/health.d.ts +0 -154
- package/dist/cli/commands/fleet/health.d.ts.map +0 -1
- package/dist/cli/commands/fleet/health.js +0 -483
- package/dist/cli/commands/fleet/health.js.map +0 -1
- package/dist/cli/commands/fleet/init.d.ts +0 -11
- package/dist/cli/commands/fleet/init.d.ts.map +0 -1
- package/dist/cli/commands/fleet/init.js +0 -91
- package/dist/cli/commands/fleet/init.js.map +0 -1
- package/dist/cli/commands/fleet/logs.d.ts +0 -21
- package/dist/cli/commands/fleet/logs.d.ts.map +0 -1
- package/dist/cli/commands/fleet/logs.js +0 -267
- package/dist/cli/commands/fleet/logs.js.map +0 -1
- package/dist/cli/commands/fleet/metrics.d.ts +0 -27
- package/dist/cli/commands/fleet/metrics.d.ts.map +0 -1
- package/dist/cli/commands/fleet/metrics.js +0 -369
- package/dist/cli/commands/fleet/metrics.js.map +0 -1
- package/dist/cli/commands/fleet/monitor.d.ts +0 -18
- package/dist/cli/commands/fleet/monitor.d.ts.map +0 -1
- package/dist/cli/commands/fleet/monitor.js +0 -237
- package/dist/cli/commands/fleet/monitor.js.map +0 -1
- package/dist/cli/commands/fleet/optimize.d.ts +0 -42
- package/dist/cli/commands/fleet/optimize.d.ts.map +0 -1
- package/dist/cli/commands/fleet/optimize.js +0 -135
- package/dist/cli/commands/fleet/optimize.js.map +0 -1
- package/dist/cli/commands/fleet/recover.d.ts +0 -22
- package/dist/cli/commands/fleet/recover.d.ts.map +0 -1
- package/dist/cli/commands/fleet/recover.js +0 -99
- package/dist/cli/commands/fleet/recover.js.map +0 -1
- package/dist/cli/commands/fleet/restart.d.ts +0 -18
- package/dist/cli/commands/fleet/restart.d.ts.map +0 -1
- package/dist/cli/commands/fleet/restart.js +0 -290
- package/dist/cli/commands/fleet/restart.js.map +0 -1
- package/dist/cli/commands/fleet/scale.d.ts +0 -9
- package/dist/cli/commands/fleet/scale.d.ts.map +0 -1
- package/dist/cli/commands/fleet/scale.js +0 -77
- package/dist/cli/commands/fleet/scale.js.map +0 -1
- package/dist/cli/commands/fleet/shutdown.d.ts +0 -19
- package/dist/cli/commands/fleet/shutdown.d.ts.map +0 -1
- package/dist/cli/commands/fleet/shutdown.js +0 -307
- package/dist/cli/commands/fleet/shutdown.js.map +0 -1
- package/dist/cli/commands/fleet/status.d.ts +0 -10
- package/dist/cli/commands/fleet/status.d.ts.map +0 -1
- package/dist/cli/commands/fleet/status.js +0 -97
- package/dist/cli/commands/fleet/status.js.map +0 -1
- package/dist/cli/commands/fleet/topology.d.ts +0 -23
- package/dist/cli/commands/fleet/topology.d.ts.map +0 -1
- package/dist/cli/commands/fleet/topology.js +0 -376
- package/dist/cli/commands/fleet/topology.js.map +0 -1
- package/dist/cli/commands/monitor/alerts.d.ts +0 -45
- package/dist/cli/commands/monitor/alerts.d.ts.map +0 -1
- package/dist/cli/commands/monitor/alerts.js +0 -168
- package/dist/cli/commands/monitor/alerts.js.map +0 -1
- package/dist/cli/commands/monitor/analyze.d.ts +0 -49
- package/dist/cli/commands/monitor/analyze.d.ts.map +0 -1
- package/dist/cli/commands/monitor/analyze.js +0 -209
- package/dist/cli/commands/monitor/analyze.js.map +0 -1
- package/dist/cli/commands/monitor/compare.d.ts +0 -38
- package/dist/cli/commands/monitor/compare.d.ts.map +0 -1
- package/dist/cli/commands/monitor/compare.js +0 -177
- package/dist/cli/commands/monitor/compare.js.map +0 -1
- package/dist/cli/commands/monitor/dashboard.d.ts +0 -34
- package/dist/cli/commands/monitor/dashboard.d.ts.map +0 -1
- package/dist/cli/commands/monitor/dashboard.js +0 -157
- package/dist/cli/commands/monitor/dashboard.js.map +0 -1
- package/dist/cli/commands/monitor/export.d.ts +0 -36
- package/dist/cli/commands/monitor/export.d.ts.map +0 -1
- package/dist/cli/commands/monitor/export.js +0 -157
- package/dist/cli/commands/monitor/export.js.map +0 -1
- package/dist/cli/commands/monitor/index.d.ts +0 -11
- package/dist/cli/commands/monitor/index.d.ts.map +0 -1
- package/dist/cli/commands/monitor/index.js +0 -14
- package/dist/cli/commands/monitor/index.js.map +0 -1
- package/dist/cli/commands/quality/baseline.d.ts +0 -27
- package/dist/cli/commands/quality/baseline.d.ts.map +0 -1
- package/dist/cli/commands/quality/baseline.js +0 -124
- package/dist/cli/commands/quality/baseline.js.map +0 -1
- package/dist/cli/commands/quality/compare.d.ts +0 -36
- package/dist/cli/commands/quality/compare.d.ts.map +0 -1
- package/dist/cli/commands/quality/compare.js +0 -136
- package/dist/cli/commands/quality/compare.js.map +0 -1
- package/dist/cli/commands/quality/decision.d.ts +0 -81
- package/dist/cli/commands/quality/decision.d.ts.map +0 -1
- package/dist/cli/commands/quality/decision.js +0 -319
- package/dist/cli/commands/quality/decision.js.map +0 -1
- package/dist/cli/commands/quality/gate.d.ts +0 -47
- package/dist/cli/commands/quality/gate.d.ts.map +0 -1
- package/dist/cli/commands/quality/gate.js +0 -205
- package/dist/cli/commands/quality/gate.js.map +0 -1
- package/dist/cli/commands/quality/index.d.ts +0 -17
- package/dist/cli/commands/quality/index.d.ts.map +0 -1
- package/dist/cli/commands/quality/index.js +0 -41
- package/dist/cli/commands/quality/index.js.map +0 -1
- package/dist/cli/commands/quality/policy.d.ts +0 -57
- package/dist/cli/commands/quality/policy.d.ts.map +0 -1
- package/dist/cli/commands/quality/policy.js +0 -359
- package/dist/cli/commands/quality/policy.js.map +0 -1
- package/dist/cli/commands/quality/risk.d.ts +0 -41
- package/dist/cli/commands/quality/risk.d.ts.map +0 -1
- package/dist/cli/commands/quality/risk.js +0 -255
- package/dist/cli/commands/quality/risk.js.map +0 -1
- package/dist/cli/commands/quality/trends.d.ts +0 -40
- package/dist/cli/commands/quality/trends.d.ts.map +0 -1
- package/dist/cli/commands/quality/trends.js +0 -122
- package/dist/cli/commands/quality/trends.js.map +0 -1
- package/dist/cli/commands/quality/validate.d.ts +0 -44
- package/dist/cli/commands/quality/validate.d.ts.map +0 -1
- package/dist/cli/commands/quality/validate.js +0 -234
- package/dist/cli/commands/quality/validate.js.map +0 -1
- package/dist/cli/commands/test/analyze-failures.d.ts +0 -39
- package/dist/cli/commands/test/analyze-failures.d.ts.map +0 -1
- package/dist/cli/commands/test/analyze-failures.js +0 -113
- package/dist/cli/commands/test/analyze-failures.js.map +0 -1
- package/dist/cli/commands/test/clean.d.ts +0 -3
- package/dist/cli/commands/test/clean.d.ts.map +0 -1
- package/dist/cli/commands/test/clean.js +0 -148
- package/dist/cli/commands/test/clean.js.map +0 -1
- package/dist/cli/commands/test/debug.d.ts +0 -3
- package/dist/cli/commands/test/debug.d.ts.map +0 -1
- package/dist/cli/commands/test/debug.js +0 -167
- package/dist/cli/commands/test/debug.js.map +0 -1
- package/dist/cli/commands/test/diff.d.ts +0 -3
- package/dist/cli/commands/test/diff.d.ts.map +0 -1
- package/dist/cli/commands/test/diff.js +0 -195
- package/dist/cli/commands/test/diff.js.map +0 -1
- package/dist/cli/commands/test/flakiness.d.ts +0 -32
- package/dist/cli/commands/test/flakiness.d.ts.map +0 -1
- package/dist/cli/commands/test/flakiness.js +0 -121
- package/dist/cli/commands/test/flakiness.js.map +0 -1
- package/dist/cli/commands/test/index.d.ts +0 -17
- package/dist/cli/commands/test/index.d.ts.map +0 -1
- package/dist/cli/commands/test/index.js +0 -45
- package/dist/cli/commands/test/index.js.map +0 -1
- package/dist/cli/commands/test/mutate.d.ts +0 -29
- package/dist/cli/commands/test/mutate.d.ts.map +0 -1
- package/dist/cli/commands/test/mutate.js +0 -163
- package/dist/cli/commands/test/mutate.js.map +0 -1
- package/dist/cli/commands/test/parallel.d.ts +0 -3
- package/dist/cli/commands/test/parallel.d.ts.map +0 -1
- package/dist/cli/commands/test/parallel.js +0 -117
- package/dist/cli/commands/test/parallel.js.map +0 -1
- package/dist/cli/commands/test/profile.d.ts +0 -3
- package/dist/cli/commands/test/profile.d.ts.map +0 -1
- package/dist/cli/commands/test/profile.js +0 -156
- package/dist/cli/commands/test/profile.js.map +0 -1
- package/dist/cli/commands/test/queue.d.ts +0 -3
- package/dist/cli/commands/test/queue.d.ts.map +0 -1
- package/dist/cli/commands/test/queue.js +0 -140
- package/dist/cli/commands/test/queue.js.map +0 -1
- package/dist/cli/commands/test/retry.d.ts +0 -3
- package/dist/cli/commands/test/retry.d.ts.map +0 -1
- package/dist/cli/commands/test/retry.js +0 -105
- package/dist/cli/commands/test/retry.js.map +0 -1
- package/dist/cli/commands/test/snapshot.d.ts +0 -3
- package/dist/cli/commands/test/snapshot.d.ts.map +0 -1
- package/dist/cli/commands/test/snapshot.js +0 -176
- package/dist/cli/commands/test/snapshot.js.map +0 -1
- package/dist/cli/commands/test/trace.d.ts +0 -3
- package/dist/cli/commands/test/trace.d.ts.map +0 -1
- package/dist/cli/commands/test/trace.js +0 -137
- package/dist/cli/commands/test/trace.js.map +0 -1
- package/dist/cli/commands/test/watch.d.ts +0 -3
- package/dist/cli/commands/test/watch.d.ts.map +0 -1
- package/dist/cli/commands/test/watch.js +0 -130
- package/dist/cli/commands/test/watch.js.map +0 -1
- package/dist/cli/index-spec.d.ts +0 -3
- package/dist/cli/index-spec.d.ts.map +0 -1
- package/dist/cli/index-spec.js +0 -154
- package/dist/cli/index-spec.js.map +0 -1
- package/dist/cli/index-working.d.ts +0 -7
- package/dist/cli/index-working.d.ts.map +0 -1
- package/dist/cli/index-working.js +0 -617
- package/dist/cli/index-working.js.map +0 -1
- package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.d.ts +0 -83
- package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.d.ts.map +0 -1
- package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.js +0 -130
- package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.js.map +0 -1
- package/dist/mcp/handlers/filtered/flaky-detector-filtered.d.ts +0 -58
- package/dist/mcp/handlers/filtered/flaky-detector-filtered.d.ts.map +0 -1
- package/dist/mcp/handlers/filtered/flaky-detector-filtered.js +0 -84
- package/dist/mcp/handlers/filtered/flaky-detector-filtered.js.map +0 -1
- package/dist/mcp/handlers/filtered/security-scanner-filtered.d.ts +0 -54
- package/dist/mcp/handlers/filtered/security-scanner-filtered.d.ts.map +0 -1
- package/dist/mcp/handlers/filtered/security-scanner-filtered.js +0 -73
- package/dist/mcp/handlers/filtered/security-scanner-filtered.js.map +0 -1
- package/dist/mcp/handlers/integration/contract-validate.d.ts +0 -10
- package/dist/mcp/handlers/integration/contract-validate.d.ts.map +0 -1
- package/dist/mcp/handlers/integration/contract-validate.js +0 -348
- package/dist/mcp/handlers/integration/contract-validate.js.map +0 -1
- package/dist/reporting/ResultAggregator.d.ts +0 -107
- package/dist/reporting/ResultAggregator.d.ts.map +0 -1
- package/dist/reporting/ResultAggregator.js +0 -435
- package/dist/reporting/ResultAggregator.js.map +0 -1
- package/dist/reporting/index.d.ts +0 -48
- package/dist/reporting/index.d.ts.map +0 -1
- package/dist/reporting/index.js +0 -154
- package/dist/reporting/index.js.map +0 -1
- package/dist/reporting/reporters/ControlLoopReporter.d.ts +0 -128
- package/dist/reporting/reporters/ControlLoopReporter.d.ts.map +0 -1
- package/dist/reporting/reporters/ControlLoopReporter.js +0 -417
- package/dist/reporting/reporters/ControlLoopReporter.js.map +0 -1
- package/dist/reporting/reporters/HumanReadableReporter.d.ts +0 -140
- package/dist/reporting/reporters/HumanReadableReporter.d.ts.map +0 -1
- package/dist/reporting/reporters/HumanReadableReporter.js +0 -524
- package/dist/reporting/reporters/HumanReadableReporter.js.map +0 -1
- package/dist/reporting/reporters/JSONReporter.d.ts +0 -251
- package/dist/reporting/reporters/JSONReporter.d.ts.map +0 -1
- package/dist/reporting/reporters/JSONReporter.js +0 -325
- package/dist/reporting/reporters/JSONReporter.js.map +0 -1
- package/dist/reporting/reporters/index.d.ts +0 -14
- package/dist/reporting/reporters/index.d.ts.map +0 -1
- package/dist/reporting/reporters/index.js +0 -19
- package/dist/reporting/reporters/index.js.map +0 -1
- package/dist/reporting/types.d.ts +0 -427
- package/dist/reporting/types.d.ts.map +0 -1
- package/dist/reporting/types.js +0 -12
- package/dist/reporting/types.js.map +0 -1
|
@@ -0,0 +1,839 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CRDT Store - Storage and Management for Multiple CRDTs
|
|
4
|
+
*
|
|
5
|
+
* Provides a centralized store for managing multiple CRDT instances,
|
|
6
|
+
* applying remote updates, generating deltas for synchronization,
|
|
7
|
+
* and garbage collecting tombstones.
|
|
8
|
+
*
|
|
9
|
+
* @module edge/p2p/crdt/CRDTStore
|
|
10
|
+
* @version 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.CRDTStore = void 0;
|
|
14
|
+
const types_1 = require("./types");
|
|
15
|
+
const VectorClock_1 = require("./VectorClock");
|
|
16
|
+
const GCounter_1 = require("./GCounter");
|
|
17
|
+
const LWWRegister_1 = require("./LWWRegister");
|
|
18
|
+
const ORSet_1 = require("./ORSet");
|
|
19
|
+
const PatternCRDT_1 = require("./PatternCRDT");
|
|
20
|
+
// ============================================
|
|
21
|
+
// CRDTStore Class
|
|
22
|
+
// ============================================
|
|
23
|
+
/**
|
|
24
|
+
* Store for managing multiple CRDT instances.
|
|
25
|
+
*
|
|
26
|
+
* Features:
|
|
27
|
+
* - Create and retrieve CRDTs by ID
|
|
28
|
+
* - Apply remote updates and merge states
|
|
29
|
+
* - Generate delta updates for synchronization
|
|
30
|
+
* - Automatic garbage collection of tombstones
|
|
31
|
+
* - Event emission for monitoring
|
|
32
|
+
* - Conflict tracking
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const store = new CRDTStore({
|
|
37
|
+
* replicaId: 'replica-1',
|
|
38
|
+
* autoGC: true,
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // Create CRDTs
|
|
42
|
+
* const counter = store.createGCounter('page-views');
|
|
43
|
+
* const tags = store.createORSet<string>('user-tags');
|
|
44
|
+
* const pattern = store.createPattern({
|
|
45
|
+
* id: 'pattern-1',
|
|
46
|
+
* content: '...',
|
|
47
|
+
* type: 'test',
|
|
48
|
+
* category: 'unit',
|
|
49
|
+
* domain: 'api',
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // Apply remote state
|
|
53
|
+
* store.applyState(remoteState);
|
|
54
|
+
*
|
|
55
|
+
* // Generate deltas for sync
|
|
56
|
+
* const deltas = store.generateDeltas(lastSyncClock);
|
|
57
|
+
*
|
|
58
|
+
* // Get stats
|
|
59
|
+
* const stats = store.getStats();
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
class CRDTStore {
|
|
63
|
+
/**
|
|
64
|
+
* Create a new CRDT store
|
|
65
|
+
*
|
|
66
|
+
* @param config - Store configuration
|
|
67
|
+
*/
|
|
68
|
+
constructor(config = {}) {
|
|
69
|
+
this.config = { ...types_1.DEFAULT_STORE_CONFIG, ...config };
|
|
70
|
+
if (!this.config.replicaId) {
|
|
71
|
+
throw new types_1.CRDTError('Replica ID is required for CRDTStore', types_1.CRDTErrorCode.InvalidState);
|
|
72
|
+
}
|
|
73
|
+
this.instances = new Map();
|
|
74
|
+
this.types = new Map();
|
|
75
|
+
this.vectorClock = new VectorClock_1.VectorClock(this.config.replicaId);
|
|
76
|
+
this.deltaBuffer = new Map();
|
|
77
|
+
this.conflicts = [];
|
|
78
|
+
this.eventHandlers = new Set();
|
|
79
|
+
// Start auto GC if enabled
|
|
80
|
+
if (this.config.autoGC) {
|
|
81
|
+
this.startAutoGC();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// ============================================
|
|
85
|
+
// CRDT Creation
|
|
86
|
+
// ============================================
|
|
87
|
+
/**
|
|
88
|
+
* Create a new G-Counter
|
|
89
|
+
*
|
|
90
|
+
* @param id - Counter identifier
|
|
91
|
+
* @param initialValue - Initial value
|
|
92
|
+
* @returns Created counter
|
|
93
|
+
*/
|
|
94
|
+
createGCounter(id, initialValue = 0) {
|
|
95
|
+
this.checkCapacity();
|
|
96
|
+
this.checkIdAvailable(id);
|
|
97
|
+
const counter = new GCounter_1.GCounter(this.config.replicaId, id, initialValue);
|
|
98
|
+
this.instances.set(id, counter);
|
|
99
|
+
this.types.set(id, types_1.CRDTType.GCounter);
|
|
100
|
+
this.vectorClock.increment();
|
|
101
|
+
this.emit({
|
|
102
|
+
type: types_1.CRDTEventType.Created,
|
|
103
|
+
crdtId: id,
|
|
104
|
+
crdtType: types_1.CRDTType.GCounter,
|
|
105
|
+
timestamp: Date.now(),
|
|
106
|
+
details: { initialValue },
|
|
107
|
+
});
|
|
108
|
+
return counter;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Create a new LWW-Register
|
|
112
|
+
*
|
|
113
|
+
* @param id - Register identifier
|
|
114
|
+
* @param initialValue - Initial value
|
|
115
|
+
* @returns Created register
|
|
116
|
+
*/
|
|
117
|
+
createLWWRegister(id, initialValue) {
|
|
118
|
+
this.checkCapacity();
|
|
119
|
+
this.checkIdAvailable(id);
|
|
120
|
+
const register = new LWWRegister_1.LWWRegister(this.config.replicaId, id, initialValue);
|
|
121
|
+
this.instances.set(id, register);
|
|
122
|
+
this.types.set(id, types_1.CRDTType.LWWRegister);
|
|
123
|
+
this.vectorClock.increment();
|
|
124
|
+
this.emit({
|
|
125
|
+
type: types_1.CRDTEventType.Created,
|
|
126
|
+
crdtId: id,
|
|
127
|
+
crdtType: types_1.CRDTType.LWWRegister,
|
|
128
|
+
timestamp: Date.now(),
|
|
129
|
+
details: { hasInitialValue: initialValue !== undefined },
|
|
130
|
+
});
|
|
131
|
+
return register;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Create a new OR-Set
|
|
135
|
+
*
|
|
136
|
+
* @param id - Set identifier
|
|
137
|
+
* @returns Created set
|
|
138
|
+
*/
|
|
139
|
+
createORSet(id) {
|
|
140
|
+
this.checkCapacity();
|
|
141
|
+
this.checkIdAvailable(id);
|
|
142
|
+
const set = new ORSet_1.ORSet(this.config.replicaId, id, {
|
|
143
|
+
tombstoneTtl: this.config.tombstoneTtl,
|
|
144
|
+
});
|
|
145
|
+
this.instances.set(id, set);
|
|
146
|
+
this.types.set(id, types_1.CRDTType.ORSet);
|
|
147
|
+
this.vectorClock.increment();
|
|
148
|
+
this.emit({
|
|
149
|
+
type: types_1.CRDTEventType.Created,
|
|
150
|
+
crdtId: id,
|
|
151
|
+
crdtType: types_1.CRDTType.ORSet,
|
|
152
|
+
timestamp: Date.now(),
|
|
153
|
+
details: {},
|
|
154
|
+
});
|
|
155
|
+
return set;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Create a new Pattern CRDT
|
|
159
|
+
*
|
|
160
|
+
* @param input - Pattern input data
|
|
161
|
+
* @returns Created PatternCRDT
|
|
162
|
+
*/
|
|
163
|
+
createPattern(input) {
|
|
164
|
+
this.checkCapacity();
|
|
165
|
+
this.checkIdAvailable(input.id);
|
|
166
|
+
const pattern = new PatternCRDT_1.PatternCRDT(this.config.replicaId, input);
|
|
167
|
+
this.instances.set(input.id, pattern);
|
|
168
|
+
this.types.set(input.id, types_1.CRDTType.PatternCRDT);
|
|
169
|
+
this.vectorClock.increment();
|
|
170
|
+
this.emit({
|
|
171
|
+
type: types_1.CRDTEventType.Created,
|
|
172
|
+
crdtId: input.id,
|
|
173
|
+
crdtType: types_1.CRDTType.PatternCRDT,
|
|
174
|
+
timestamp: Date.now(),
|
|
175
|
+
details: { type: input.type, category: input.category },
|
|
176
|
+
});
|
|
177
|
+
return pattern;
|
|
178
|
+
}
|
|
179
|
+
// ============================================
|
|
180
|
+
// CRDT Retrieval
|
|
181
|
+
// ============================================
|
|
182
|
+
/**
|
|
183
|
+
* Get a CRDT by ID
|
|
184
|
+
*
|
|
185
|
+
* @param id - CRDT identifier
|
|
186
|
+
* @returns CRDT instance or undefined
|
|
187
|
+
*/
|
|
188
|
+
get(id) {
|
|
189
|
+
return this.instances.get(id);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get a G-Counter by ID
|
|
193
|
+
*
|
|
194
|
+
* @param id - Counter identifier
|
|
195
|
+
* @returns Counter or undefined
|
|
196
|
+
*/
|
|
197
|
+
getGCounter(id) {
|
|
198
|
+
const instance = this.instances.get(id);
|
|
199
|
+
if (instance && this.types.get(id) === types_1.CRDTType.GCounter) {
|
|
200
|
+
return instance;
|
|
201
|
+
}
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Get an LWW-Register by ID
|
|
206
|
+
*
|
|
207
|
+
* @param id - Register identifier
|
|
208
|
+
* @returns Register or undefined
|
|
209
|
+
*/
|
|
210
|
+
getLWWRegister(id) {
|
|
211
|
+
const instance = this.instances.get(id);
|
|
212
|
+
if (instance && this.types.get(id) === types_1.CRDTType.LWWRegister) {
|
|
213
|
+
return instance;
|
|
214
|
+
}
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Get an OR-Set by ID
|
|
219
|
+
*
|
|
220
|
+
* @param id - Set identifier
|
|
221
|
+
* @returns Set or undefined
|
|
222
|
+
*/
|
|
223
|
+
getORSet(id) {
|
|
224
|
+
const instance = this.instances.get(id);
|
|
225
|
+
if (instance && this.types.get(id) === types_1.CRDTType.ORSet) {
|
|
226
|
+
return instance;
|
|
227
|
+
}
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Get a PatternCRDT by ID
|
|
232
|
+
*
|
|
233
|
+
* @param id - Pattern identifier
|
|
234
|
+
* @returns Pattern or undefined
|
|
235
|
+
*/
|
|
236
|
+
getPattern(id) {
|
|
237
|
+
const instance = this.instances.get(id);
|
|
238
|
+
if (instance && this.types.get(id) === types_1.CRDTType.PatternCRDT) {
|
|
239
|
+
return instance;
|
|
240
|
+
}
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Check if a CRDT exists
|
|
245
|
+
*
|
|
246
|
+
* @param id - CRDT identifier
|
|
247
|
+
* @returns True if exists
|
|
248
|
+
*/
|
|
249
|
+
has(id) {
|
|
250
|
+
return this.instances.has(id);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get all CRDT IDs
|
|
254
|
+
*
|
|
255
|
+
* @returns Array of IDs
|
|
256
|
+
*/
|
|
257
|
+
getIds() {
|
|
258
|
+
return Array.from(this.instances.keys());
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Get IDs by type
|
|
262
|
+
*
|
|
263
|
+
* @param type - CRDT type to filter by
|
|
264
|
+
* @returns Array of matching IDs
|
|
265
|
+
*/
|
|
266
|
+
getIdsByType(type) {
|
|
267
|
+
const ids = [];
|
|
268
|
+
for (const [id, t] of this.types) {
|
|
269
|
+
if (t === type) {
|
|
270
|
+
ids.push(id);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return ids;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Get the type of a CRDT
|
|
277
|
+
*
|
|
278
|
+
* @param id - CRDT identifier
|
|
279
|
+
* @returns CRDT type or undefined
|
|
280
|
+
*/
|
|
281
|
+
getType(id) {
|
|
282
|
+
return this.types.get(id);
|
|
283
|
+
}
|
|
284
|
+
// ============================================
|
|
285
|
+
// State Application
|
|
286
|
+
// ============================================
|
|
287
|
+
/**
|
|
288
|
+
* Apply a remote CRDT state
|
|
289
|
+
*
|
|
290
|
+
* If the CRDT doesn't exist locally, it will be created.
|
|
291
|
+
* If it exists, the states will be merged.
|
|
292
|
+
*
|
|
293
|
+
* @param state - Remote CRDT state
|
|
294
|
+
* @returns Merge result
|
|
295
|
+
*/
|
|
296
|
+
applyState(state) {
|
|
297
|
+
const startTime = Date.now();
|
|
298
|
+
let result;
|
|
299
|
+
const existing = this.instances.get(state.id);
|
|
300
|
+
if (existing) {
|
|
301
|
+
// Merge with existing
|
|
302
|
+
result = this.mergeExisting(state);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
// Create new from state
|
|
306
|
+
result = this.createFromState(state);
|
|
307
|
+
}
|
|
308
|
+
// Track conflicts
|
|
309
|
+
if (this.config.trackConflicts) {
|
|
310
|
+
this.addConflicts(result.conflicts);
|
|
311
|
+
}
|
|
312
|
+
// Emit event
|
|
313
|
+
if (result.localChanged) {
|
|
314
|
+
this.emit({
|
|
315
|
+
type: types_1.CRDTEventType.Merge,
|
|
316
|
+
crdtId: state.id,
|
|
317
|
+
crdtType: state.type,
|
|
318
|
+
timestamp: Date.now(),
|
|
319
|
+
details: {
|
|
320
|
+
origin: state.origin,
|
|
321
|
+
conflicts: result.conflicts.length,
|
|
322
|
+
duration: Date.now() - startTime,
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
this.vectorClock.increment();
|
|
327
|
+
return result;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Merge state with existing CRDT
|
|
331
|
+
*/
|
|
332
|
+
mergeExisting(state) {
|
|
333
|
+
const instance = this.instances.get(state.id);
|
|
334
|
+
const type = this.types.get(state.id);
|
|
335
|
+
if (type !== state.type) {
|
|
336
|
+
throw new types_1.CRDTError(`Type mismatch: local is ${type}, remote is ${state.type}`, types_1.CRDTErrorCode.InvalidType, state.id);
|
|
337
|
+
}
|
|
338
|
+
switch (type) {
|
|
339
|
+
case types_1.CRDTType.GCounter:
|
|
340
|
+
return instance.merge(state);
|
|
341
|
+
case types_1.CRDTType.LWWRegister:
|
|
342
|
+
return instance.merge(state);
|
|
343
|
+
case types_1.CRDTType.ORSet:
|
|
344
|
+
return instance.merge(state);
|
|
345
|
+
case types_1.CRDTType.PatternCRDT:
|
|
346
|
+
return instance.merge(state);
|
|
347
|
+
default:
|
|
348
|
+
throw new types_1.CRDTError(`Unknown CRDT type: ${type}`, types_1.CRDTErrorCode.InvalidType, state.id);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Create a new CRDT from remote state
|
|
353
|
+
*/
|
|
354
|
+
createFromState(state) {
|
|
355
|
+
this.checkCapacity();
|
|
356
|
+
let instance;
|
|
357
|
+
switch (state.type) {
|
|
358
|
+
case types_1.CRDTType.GCounter:
|
|
359
|
+
instance = GCounter_1.GCounter.fromState(state, this.config.replicaId);
|
|
360
|
+
break;
|
|
361
|
+
case types_1.CRDTType.LWWRegister:
|
|
362
|
+
instance = LWWRegister_1.LWWRegister.fromState(state, this.config.replicaId);
|
|
363
|
+
break;
|
|
364
|
+
case types_1.CRDTType.ORSet:
|
|
365
|
+
instance = ORSet_1.ORSet.fromState(state, this.config.replicaId);
|
|
366
|
+
break;
|
|
367
|
+
case types_1.CRDTType.PatternCRDT:
|
|
368
|
+
instance = PatternCRDT_1.PatternCRDT.fromState(state, this.config.replicaId);
|
|
369
|
+
break;
|
|
370
|
+
default:
|
|
371
|
+
throw new types_1.CRDTError(`Unknown CRDT type: ${state.type}`, types_1.CRDTErrorCode.InvalidType, state.id);
|
|
372
|
+
}
|
|
373
|
+
this.instances.set(state.id, instance);
|
|
374
|
+
this.types.set(state.id, state.type);
|
|
375
|
+
this.emit({
|
|
376
|
+
type: types_1.CRDTEventType.Created,
|
|
377
|
+
crdtId: state.id,
|
|
378
|
+
crdtType: state.type,
|
|
379
|
+
timestamp: Date.now(),
|
|
380
|
+
details: { fromRemote: true, origin: state.origin },
|
|
381
|
+
});
|
|
382
|
+
return {
|
|
383
|
+
success: true,
|
|
384
|
+
mergedState: state,
|
|
385
|
+
localChanged: true,
|
|
386
|
+
conflicts: [],
|
|
387
|
+
stats: {
|
|
388
|
+
duration: 0,
|
|
389
|
+
entriesMerged: 1,
|
|
390
|
+
autoResolved: 0,
|
|
391
|
+
tombstonesProcessed: 0,
|
|
392
|
+
memoryDelta: 0,
|
|
393
|
+
},
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Apply a delta update
|
|
398
|
+
*
|
|
399
|
+
* @param delta - Delta to apply
|
|
400
|
+
* @returns True if applied successfully
|
|
401
|
+
*/
|
|
402
|
+
applyDelta(delta) {
|
|
403
|
+
const instance = this.instances.get(delta.crdtId);
|
|
404
|
+
if (!instance) {
|
|
405
|
+
// Buffer delta for later if CRDT doesn't exist yet
|
|
406
|
+
if (this.config.enableDeltas) {
|
|
407
|
+
this.bufferDelta(delta);
|
|
408
|
+
}
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
const type = this.types.get(delta.crdtId);
|
|
412
|
+
if (type !== delta.type) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
let applied = false;
|
|
416
|
+
switch (type) {
|
|
417
|
+
case types_1.CRDTType.GCounter:
|
|
418
|
+
applied = instance.applyDelta(delta);
|
|
419
|
+
break;
|
|
420
|
+
case types_1.CRDTType.LWWRegister:
|
|
421
|
+
applied = instance.applyDelta(delta);
|
|
422
|
+
break;
|
|
423
|
+
case types_1.CRDTType.ORSet:
|
|
424
|
+
applied = instance.applyDelta(delta);
|
|
425
|
+
break;
|
|
426
|
+
case types_1.CRDTType.PatternCRDT:
|
|
427
|
+
applied = instance.applyDelta(delta);
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
if (applied) {
|
|
431
|
+
this.vectorClock.increment();
|
|
432
|
+
this.emit({
|
|
433
|
+
type: types_1.CRDTEventType.Update,
|
|
434
|
+
crdtId: delta.crdtId,
|
|
435
|
+
crdtType: delta.type,
|
|
436
|
+
timestamp: Date.now(),
|
|
437
|
+
details: { deltaOrigin: delta.origin },
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
return applied;
|
|
441
|
+
}
|
|
442
|
+
// ============================================
|
|
443
|
+
// Delta Generation
|
|
444
|
+
// ============================================
|
|
445
|
+
/**
|
|
446
|
+
* Generate deltas for all CRDTs since a given clock
|
|
447
|
+
*
|
|
448
|
+
* @param since - Vector clock of last sync
|
|
449
|
+
* @returns Array of deltas
|
|
450
|
+
*/
|
|
451
|
+
generateDeltas(since) {
|
|
452
|
+
const deltas = [];
|
|
453
|
+
for (const [id, instance] of this.instances) {
|
|
454
|
+
const type = this.types.get(id);
|
|
455
|
+
let delta = null;
|
|
456
|
+
switch (type) {
|
|
457
|
+
case types_1.CRDTType.GCounter:
|
|
458
|
+
delta = instance.generateDelta(since);
|
|
459
|
+
break;
|
|
460
|
+
case types_1.CRDTType.LWWRegister:
|
|
461
|
+
delta = instance.generateDelta(since);
|
|
462
|
+
break;
|
|
463
|
+
case types_1.CRDTType.ORSet:
|
|
464
|
+
delta = instance.generateDelta(since);
|
|
465
|
+
break;
|
|
466
|
+
case types_1.CRDTType.PatternCRDT:
|
|
467
|
+
delta = instance.generateDelta(since);
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
if (delta) {
|
|
471
|
+
deltas.push(delta);
|
|
472
|
+
this.emit({
|
|
473
|
+
type: types_1.CRDTEventType.DeltaGenerated,
|
|
474
|
+
crdtId: id,
|
|
475
|
+
crdtType: type,
|
|
476
|
+
timestamp: Date.now(),
|
|
477
|
+
details: { sequenceNumber: delta.sequenceNumber },
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
this.lastSync = Date.now();
|
|
482
|
+
return deltas;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Get all states for full sync
|
|
486
|
+
*
|
|
487
|
+
* @returns Array of all CRDT states
|
|
488
|
+
*/
|
|
489
|
+
getAllStates() {
|
|
490
|
+
const states = [];
|
|
491
|
+
for (const [id, instance] of this.instances) {
|
|
492
|
+
const type = this.types.get(id);
|
|
493
|
+
switch (type) {
|
|
494
|
+
case types_1.CRDTType.GCounter:
|
|
495
|
+
states.push(instance.state());
|
|
496
|
+
break;
|
|
497
|
+
case types_1.CRDTType.LWWRegister:
|
|
498
|
+
states.push(instance.state());
|
|
499
|
+
break;
|
|
500
|
+
case types_1.CRDTType.ORSet:
|
|
501
|
+
states.push(instance.state());
|
|
502
|
+
break;
|
|
503
|
+
case types_1.CRDTType.PatternCRDT:
|
|
504
|
+
states.push(instance.state());
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return states;
|
|
509
|
+
}
|
|
510
|
+
// ============================================
|
|
511
|
+
// Delta Buffering
|
|
512
|
+
// ============================================
|
|
513
|
+
/**
|
|
514
|
+
* Buffer a delta for later application
|
|
515
|
+
*/
|
|
516
|
+
bufferDelta(delta) {
|
|
517
|
+
if (!this.deltaBuffer.has(delta.crdtId)) {
|
|
518
|
+
this.deltaBuffer.set(delta.crdtId, []);
|
|
519
|
+
}
|
|
520
|
+
const buffer = this.deltaBuffer.get(delta.crdtId);
|
|
521
|
+
// Check buffer size limit
|
|
522
|
+
if (buffer.length >= this.config.maxDeltaBuffer) {
|
|
523
|
+
buffer.shift(); // Remove oldest
|
|
524
|
+
}
|
|
525
|
+
buffer.push({
|
|
526
|
+
delta,
|
|
527
|
+
timestamp: Date.now(),
|
|
528
|
+
applied: false,
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Apply buffered deltas for a CRDT
|
|
533
|
+
*
|
|
534
|
+
* @param id - CRDT identifier
|
|
535
|
+
* @returns Number of deltas applied
|
|
536
|
+
*/
|
|
537
|
+
applyBufferedDeltas(id) {
|
|
538
|
+
const buffer = this.deltaBuffer.get(id);
|
|
539
|
+
if (!buffer || buffer.length === 0) {
|
|
540
|
+
return 0;
|
|
541
|
+
}
|
|
542
|
+
let applied = 0;
|
|
543
|
+
for (const entry of buffer) {
|
|
544
|
+
if (!entry.applied && this.applyDelta(entry.delta)) {
|
|
545
|
+
entry.applied = true;
|
|
546
|
+
applied++;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
// Clean up applied deltas
|
|
550
|
+
this.deltaBuffer.set(id, buffer.filter(e => !e.applied));
|
|
551
|
+
return applied;
|
|
552
|
+
}
|
|
553
|
+
// ============================================
|
|
554
|
+
// Garbage Collection
|
|
555
|
+
// ============================================
|
|
556
|
+
/**
|
|
557
|
+
* Run garbage collection on all ORSets
|
|
558
|
+
*
|
|
559
|
+
* @returns GC result
|
|
560
|
+
*/
|
|
561
|
+
gc() {
|
|
562
|
+
const startTime = Date.now();
|
|
563
|
+
let totalCollected = 0;
|
|
564
|
+
let totalRetained = 0;
|
|
565
|
+
for (const [id, instance] of this.instances) {
|
|
566
|
+
if (this.types.get(id) === types_1.CRDTType.ORSet) {
|
|
567
|
+
const orset = instance;
|
|
568
|
+
const collected = orset.gcTombstones();
|
|
569
|
+
totalCollected += collected;
|
|
570
|
+
totalRetained += orset.getTombstoneCount();
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
// Clean up old conflicts
|
|
574
|
+
const conflictCutoff = Date.now() - this.config.tombstoneTtl;
|
|
575
|
+
this.conflicts = this.conflicts.filter(c => c.detectedAt > conflictCutoff);
|
|
576
|
+
// Clean up old buffered deltas
|
|
577
|
+
for (const [id, buffer] of this.deltaBuffer) {
|
|
578
|
+
const freshDeltas = buffer.filter(e => e.timestamp > conflictCutoff);
|
|
579
|
+
if (freshDeltas.length !== buffer.length) {
|
|
580
|
+
this.deltaBuffer.set(id, freshDeltas);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
this.lastGC = Date.now();
|
|
584
|
+
const result = {
|
|
585
|
+
collected: totalCollected,
|
|
586
|
+
retained: totalRetained,
|
|
587
|
+
memoryFreed: totalCollected * 64, // Approximate
|
|
588
|
+
duration: Date.now() - startTime,
|
|
589
|
+
};
|
|
590
|
+
this.emit({
|
|
591
|
+
type: types_1.CRDTEventType.GarbageCollected,
|
|
592
|
+
crdtId: '*',
|
|
593
|
+
crdtType: types_1.CRDTType.ORSet,
|
|
594
|
+
timestamp: Date.now(),
|
|
595
|
+
details: result,
|
|
596
|
+
});
|
|
597
|
+
return result;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Start automatic garbage collection
|
|
601
|
+
*/
|
|
602
|
+
startAutoGC() {
|
|
603
|
+
if (this.gcIntervalHandle) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
this.gcIntervalHandle = setInterval(() => {
|
|
607
|
+
this.gc();
|
|
608
|
+
}, this.config.gcInterval);
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Stop automatic garbage collection
|
|
612
|
+
*/
|
|
613
|
+
stopAutoGC() {
|
|
614
|
+
if (this.gcIntervalHandle) {
|
|
615
|
+
clearInterval(this.gcIntervalHandle);
|
|
616
|
+
this.gcIntervalHandle = undefined;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
// ============================================
|
|
620
|
+
// Conflict Tracking
|
|
621
|
+
// ============================================
|
|
622
|
+
/**
|
|
623
|
+
* Add conflicts to history
|
|
624
|
+
*/
|
|
625
|
+
addConflicts(conflicts) {
|
|
626
|
+
for (const conflict of conflicts) {
|
|
627
|
+
this.conflicts.push(conflict);
|
|
628
|
+
// Trim if too many
|
|
629
|
+
if (this.conflicts.length > this.config.maxConflicts) {
|
|
630
|
+
this.conflicts.shift();
|
|
631
|
+
}
|
|
632
|
+
this.emit({
|
|
633
|
+
type: types_1.CRDTEventType.Conflict,
|
|
634
|
+
crdtId: conflict.crdtId,
|
|
635
|
+
crdtType: types_1.CRDTType.LWWRegister, // Generic
|
|
636
|
+
timestamp: Date.now(),
|
|
637
|
+
details: conflict,
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Get recent conflicts
|
|
643
|
+
*
|
|
644
|
+
* @param limit - Maximum conflicts to return
|
|
645
|
+
* @returns Array of conflicts
|
|
646
|
+
*/
|
|
647
|
+
getConflicts(limit) {
|
|
648
|
+
const l = limit ?? this.conflicts.length;
|
|
649
|
+
return this.conflicts.slice(-l);
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Clear conflict history
|
|
653
|
+
*/
|
|
654
|
+
clearConflicts() {
|
|
655
|
+
this.conflicts = [];
|
|
656
|
+
}
|
|
657
|
+
// ============================================
|
|
658
|
+
// CRDT Deletion
|
|
659
|
+
// ============================================
|
|
660
|
+
/**
|
|
661
|
+
* Delete a CRDT from the store
|
|
662
|
+
*
|
|
663
|
+
* @param id - CRDT identifier
|
|
664
|
+
* @returns True if deleted
|
|
665
|
+
*/
|
|
666
|
+
delete(id) {
|
|
667
|
+
const instance = this.instances.get(id);
|
|
668
|
+
if (!instance) {
|
|
669
|
+
return false;
|
|
670
|
+
}
|
|
671
|
+
const type = this.types.get(id);
|
|
672
|
+
this.instances.delete(id);
|
|
673
|
+
this.types.delete(id);
|
|
674
|
+
this.deltaBuffer.delete(id);
|
|
675
|
+
this.vectorClock.increment();
|
|
676
|
+
this.emit({
|
|
677
|
+
type: types_1.CRDTEventType.Deleted,
|
|
678
|
+
crdtId: id,
|
|
679
|
+
crdtType: type,
|
|
680
|
+
timestamp: Date.now(),
|
|
681
|
+
details: {},
|
|
682
|
+
});
|
|
683
|
+
return true;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Clear all CRDTs from the store
|
|
687
|
+
*/
|
|
688
|
+
clear() {
|
|
689
|
+
const ids = Array.from(this.instances.keys());
|
|
690
|
+
for (const id of ids) {
|
|
691
|
+
this.delete(id);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
// ============================================
|
|
695
|
+
// Events
|
|
696
|
+
// ============================================
|
|
697
|
+
/**
|
|
698
|
+
* Add an event handler
|
|
699
|
+
*
|
|
700
|
+
* @param handler - Event handler function
|
|
701
|
+
*/
|
|
702
|
+
on(handler) {
|
|
703
|
+
this.eventHandlers.add(handler);
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Remove an event handler
|
|
707
|
+
*
|
|
708
|
+
* @param handler - Handler to remove
|
|
709
|
+
*/
|
|
710
|
+
off(handler) {
|
|
711
|
+
this.eventHandlers.delete(handler);
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Emit an event
|
|
715
|
+
*/
|
|
716
|
+
emit(event) {
|
|
717
|
+
for (const handler of this.eventHandlers) {
|
|
718
|
+
try {
|
|
719
|
+
handler(event);
|
|
720
|
+
}
|
|
721
|
+
catch (error) {
|
|
722
|
+
console.error('CRDT event handler error:', error);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
// ============================================
|
|
727
|
+
// Validation
|
|
728
|
+
// ============================================
|
|
729
|
+
/**
|
|
730
|
+
* Check if store has capacity for new CRDT
|
|
731
|
+
*/
|
|
732
|
+
checkCapacity() {
|
|
733
|
+
if (this.instances.size >= this.config.maxInstances) {
|
|
734
|
+
throw new types_1.CRDTError(`Store is full (max ${this.config.maxInstances} instances)`, types_1.CRDTErrorCode.StoreFull);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Check if ID is available
|
|
739
|
+
*/
|
|
740
|
+
checkIdAvailable(id) {
|
|
741
|
+
if (this.instances.has(id)) {
|
|
742
|
+
throw new types_1.CRDTError(`CRDT with ID '${id}' already exists`, types_1.CRDTErrorCode.InvalidState, id);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
// ============================================
|
|
746
|
+
// Statistics
|
|
747
|
+
// ============================================
|
|
748
|
+
/**
|
|
749
|
+
* Get store statistics
|
|
750
|
+
*
|
|
751
|
+
* @returns Store stats
|
|
752
|
+
*/
|
|
753
|
+
getStats() {
|
|
754
|
+
const byType = {
|
|
755
|
+
[types_1.CRDTType.GCounter]: 0,
|
|
756
|
+
[types_1.CRDTType.PNCounter]: 0,
|
|
757
|
+
[types_1.CRDTType.LWWRegister]: 0,
|
|
758
|
+
[types_1.CRDTType.ORSet]: 0,
|
|
759
|
+
[types_1.CRDTType.MVRegister]: 0,
|
|
760
|
+
[types_1.CRDTType.LWWMap]: 0,
|
|
761
|
+
[types_1.CRDTType.PatternCRDT]: 0,
|
|
762
|
+
};
|
|
763
|
+
let totalTombstones = 0;
|
|
764
|
+
let pendingDeltas = 0;
|
|
765
|
+
for (const [id, instance] of this.instances) {
|
|
766
|
+
const type = this.types.get(id);
|
|
767
|
+
byType[type]++;
|
|
768
|
+
if (type === types_1.CRDTType.ORSet) {
|
|
769
|
+
totalTombstones += instance.getTombstoneCount();
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
for (const buffer of this.deltaBuffer.values()) {
|
|
773
|
+
pendingDeltas += buffer.filter(e => !e.applied).length;
|
|
774
|
+
}
|
|
775
|
+
return {
|
|
776
|
+
totalInstances: this.instances.size,
|
|
777
|
+
byType,
|
|
778
|
+
totalTombstones,
|
|
779
|
+
pendingDeltas,
|
|
780
|
+
totalConflicts: this.conflicts.length,
|
|
781
|
+
memoryUsage: this.estimateMemoryUsage(),
|
|
782
|
+
lastGC: this.lastGC,
|
|
783
|
+
lastSync: this.lastSync,
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Estimate memory usage in bytes
|
|
788
|
+
*/
|
|
789
|
+
estimateMemoryUsage() {
|
|
790
|
+
let total = 0;
|
|
791
|
+
for (const [id, instance] of this.instances) {
|
|
792
|
+
const type = this.types.get(id);
|
|
793
|
+
switch (type) {
|
|
794
|
+
case types_1.CRDTType.GCounter:
|
|
795
|
+
total += 64 * instance.getReplicas().length;
|
|
796
|
+
break;
|
|
797
|
+
case types_1.CRDTType.LWWRegister:
|
|
798
|
+
total += 128; // Base + value estimate
|
|
799
|
+
break;
|
|
800
|
+
case types_1.CRDTType.ORSet:
|
|
801
|
+
total += 64 * instance.size();
|
|
802
|
+
total += 32 * instance.getTombstoneCount();
|
|
803
|
+
break;
|
|
804
|
+
case types_1.CRDTType.PatternCRDT:
|
|
805
|
+
total += 1024; // Rough estimate
|
|
806
|
+
break;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
return total;
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Get the replica ID
|
|
813
|
+
*
|
|
814
|
+
* @returns Replica ID
|
|
815
|
+
*/
|
|
816
|
+
getReplicaId() {
|
|
817
|
+
return this.config.replicaId;
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Get the vector clock
|
|
821
|
+
*
|
|
822
|
+
* @returns Vector clock copy
|
|
823
|
+
*/
|
|
824
|
+
getVectorClock() {
|
|
825
|
+
return this.vectorClock.clone();
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Dispose the store
|
|
829
|
+
*/
|
|
830
|
+
dispose() {
|
|
831
|
+
this.stopAutoGC();
|
|
832
|
+
this.clear();
|
|
833
|
+
this.eventHandlers.clear();
|
|
834
|
+
this.conflicts = [];
|
|
835
|
+
this.deltaBuffer.clear();
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
exports.CRDTStore = CRDTStore;
|
|
839
|
+
//# sourceMappingURL=CRDTStore.js.map
|