agentic-qe 2.7.4 → 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 +104 -0
- package/README.md +67 -2
- 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/planning/GOAPPlanner.d.ts +1 -0
- package/dist/planning/GOAPPlanner.d.ts.map +1 -1
- package/dist/planning/GOAPPlanner.js +12 -0
- package/dist/planning/GOAPPlanner.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,499 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vector Clock Implementation for Distributed Systems
|
|
4
|
+
*
|
|
5
|
+
* Provides causality tracking across distributed replicas using vector clocks.
|
|
6
|
+
* Enables detection of concurrent operations and proper merge ordering.
|
|
7
|
+
*
|
|
8
|
+
* @module edge/p2p/crdt/VectorClock
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.VectorClock = void 0;
|
|
13
|
+
const types_1 = require("./types");
|
|
14
|
+
// ============================================
|
|
15
|
+
// Vector Clock Class
|
|
16
|
+
// ============================================
|
|
17
|
+
/**
|
|
18
|
+
* Vector clock for tracking causality in distributed systems.
|
|
19
|
+
*
|
|
20
|
+
* A vector clock is a map from replica IDs to logical timestamps.
|
|
21
|
+
* It enables detection of happens-before relationships and concurrent events.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const clock = new VectorClock('replica-1');
|
|
26
|
+
* clock.increment();
|
|
27
|
+
* clock.increment();
|
|
28
|
+
*
|
|
29
|
+
* const otherClock = VectorClock.fromSerialized(remoteClock);
|
|
30
|
+
* const comparison = clock.compare(otherClock);
|
|
31
|
+
*
|
|
32
|
+
* if (comparison === VectorClockComparison.Concurrent) {
|
|
33
|
+
* // Handle concurrent modifications
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* clock.merge(otherClock);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
class VectorClock {
|
|
40
|
+
/**
|
|
41
|
+
* Create a new vector clock
|
|
42
|
+
*
|
|
43
|
+
* @param replicaId - Local replica identifier
|
|
44
|
+
* @param initial - Optional initial entries
|
|
45
|
+
*/
|
|
46
|
+
constructor(replicaId, initial) {
|
|
47
|
+
this.localReplicaId = replicaId;
|
|
48
|
+
this.entries = initial ? new Map(initial) : new Map();
|
|
49
|
+
this.lastModified = Date.now();
|
|
50
|
+
// Initialize local replica entry if not present
|
|
51
|
+
if (!this.entries.has(replicaId)) {
|
|
52
|
+
this.entries.set(replicaId, 0);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// ============================================
|
|
56
|
+
// Core Operations
|
|
57
|
+
// ============================================
|
|
58
|
+
/**
|
|
59
|
+
* Increment the clock for the local replica
|
|
60
|
+
*
|
|
61
|
+
* @returns The new timestamp for this replica
|
|
62
|
+
*/
|
|
63
|
+
increment() {
|
|
64
|
+
const current = this.entries.get(this.localReplicaId) ?? 0;
|
|
65
|
+
const next = current + 1;
|
|
66
|
+
this.entries.set(this.localReplicaId, next);
|
|
67
|
+
this.lastModified = Date.now();
|
|
68
|
+
return next;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Increment and return the updated clock (for chaining)
|
|
72
|
+
*
|
|
73
|
+
* @returns This clock instance
|
|
74
|
+
*/
|
|
75
|
+
tick() {
|
|
76
|
+
this.increment();
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the timestamp for a specific replica
|
|
81
|
+
*
|
|
82
|
+
* @param replicaId - Replica to query
|
|
83
|
+
* @returns Timestamp or 0 if replica unknown
|
|
84
|
+
*/
|
|
85
|
+
get(replicaId) {
|
|
86
|
+
return this.entries.get(replicaId) ?? 0;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the local replica's timestamp
|
|
90
|
+
*
|
|
91
|
+
* @returns Local timestamp
|
|
92
|
+
*/
|
|
93
|
+
getLocal() {
|
|
94
|
+
return this.get(this.localReplicaId);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Set the timestamp for a replica
|
|
98
|
+
*
|
|
99
|
+
* @param replicaId - Replica to update
|
|
100
|
+
* @param timestamp - New timestamp
|
|
101
|
+
*/
|
|
102
|
+
set(replicaId, timestamp) {
|
|
103
|
+
if (timestamp < 0) {
|
|
104
|
+
throw new types_1.CRDTError('Timestamp must be non-negative', types_1.CRDTErrorCode.ClockError);
|
|
105
|
+
}
|
|
106
|
+
this.entries.set(replicaId, timestamp);
|
|
107
|
+
this.lastModified = Date.now();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get all replica IDs in the clock
|
|
111
|
+
*
|
|
112
|
+
* @returns Array of replica IDs
|
|
113
|
+
*/
|
|
114
|
+
replicas() {
|
|
115
|
+
return Array.from(this.entries.keys());
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get the number of replicas tracked
|
|
119
|
+
*
|
|
120
|
+
* @returns Number of entries
|
|
121
|
+
*/
|
|
122
|
+
size() {
|
|
123
|
+
return this.entries.size;
|
|
124
|
+
}
|
|
125
|
+
// ============================================
|
|
126
|
+
// Comparison Operations
|
|
127
|
+
// ============================================
|
|
128
|
+
/**
|
|
129
|
+
* Compare this clock with another clock
|
|
130
|
+
*
|
|
131
|
+
* Returns:
|
|
132
|
+
* - Equal: Clocks are identical
|
|
133
|
+
* - Before: This clock happened before other
|
|
134
|
+
* - After: This clock happened after other
|
|
135
|
+
* - Concurrent: Clocks are incomparable (concurrent events)
|
|
136
|
+
*
|
|
137
|
+
* @param other - Clock to compare with
|
|
138
|
+
* @returns Comparison result
|
|
139
|
+
*/
|
|
140
|
+
compare(other) {
|
|
141
|
+
const allReplicas = new Set([
|
|
142
|
+
...this.entries.keys(),
|
|
143
|
+
...other.entries.keys(),
|
|
144
|
+
]);
|
|
145
|
+
let lessThan = false;
|
|
146
|
+
let greaterThan = false;
|
|
147
|
+
for (const replica of allReplicas) {
|
|
148
|
+
const thisTime = this.get(replica);
|
|
149
|
+
const otherTime = other.get(replica);
|
|
150
|
+
if (thisTime < otherTime) {
|
|
151
|
+
lessThan = true;
|
|
152
|
+
}
|
|
153
|
+
else if (thisTime > otherTime) {
|
|
154
|
+
greaterThan = true;
|
|
155
|
+
}
|
|
156
|
+
// Early exit if already concurrent
|
|
157
|
+
if (lessThan && greaterThan) {
|
|
158
|
+
return types_1.VectorClockComparison.Concurrent;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (!lessThan && !greaterThan) {
|
|
162
|
+
return types_1.VectorClockComparison.Equal;
|
|
163
|
+
}
|
|
164
|
+
else if (lessThan && !greaterThan) {
|
|
165
|
+
return types_1.VectorClockComparison.Before;
|
|
166
|
+
}
|
|
167
|
+
else if (!lessThan && greaterThan) {
|
|
168
|
+
return types_1.VectorClockComparison.After;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
return types_1.VectorClockComparison.Concurrent;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Check if this clock happened before another
|
|
176
|
+
*
|
|
177
|
+
* @param other - Clock to compare with
|
|
178
|
+
* @returns True if this happened before other
|
|
179
|
+
*/
|
|
180
|
+
happenedBefore(other) {
|
|
181
|
+
return this.compare(other) === types_1.VectorClockComparison.Before;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Check if this clock happened after another
|
|
185
|
+
*
|
|
186
|
+
* @param other - Clock to compare with
|
|
187
|
+
* @returns True if this happened after other
|
|
188
|
+
*/
|
|
189
|
+
happenedAfter(other) {
|
|
190
|
+
return this.compare(other) === types_1.VectorClockComparison.After;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Check if this clock is concurrent with another
|
|
194
|
+
*
|
|
195
|
+
* @param other - Clock to compare with
|
|
196
|
+
* @returns True if clocks are concurrent
|
|
197
|
+
*/
|
|
198
|
+
isConcurrent(other) {
|
|
199
|
+
return this.compare(other) === types_1.VectorClockComparison.Concurrent;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Check if clocks are equal
|
|
203
|
+
*
|
|
204
|
+
* @param other - Clock to compare with
|
|
205
|
+
* @returns True if clocks are equal
|
|
206
|
+
*/
|
|
207
|
+
equals(other) {
|
|
208
|
+
return this.compare(other) === types_1.VectorClockComparison.Equal;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Check if this clock descends from another (happened after or equal)
|
|
212
|
+
*
|
|
213
|
+
* @param other - Clock to compare with
|
|
214
|
+
* @returns True if this descends from other
|
|
215
|
+
*/
|
|
216
|
+
descendsFrom(other) {
|
|
217
|
+
const comparison = this.compare(other);
|
|
218
|
+
return (comparison === types_1.VectorClockComparison.After ||
|
|
219
|
+
comparison === types_1.VectorClockComparison.Equal);
|
|
220
|
+
}
|
|
221
|
+
// ============================================
|
|
222
|
+
// Merge Operations
|
|
223
|
+
// ============================================
|
|
224
|
+
/**
|
|
225
|
+
* Merge with another clock (element-wise maximum)
|
|
226
|
+
*
|
|
227
|
+
* The merge takes the maximum timestamp for each replica,
|
|
228
|
+
* ensuring the merged clock dominates both input clocks.
|
|
229
|
+
*
|
|
230
|
+
* @param other - Clock to merge with
|
|
231
|
+
* @returns This clock (mutated)
|
|
232
|
+
*/
|
|
233
|
+
merge(other) {
|
|
234
|
+
const allReplicas = new Set([
|
|
235
|
+
...this.entries.keys(),
|
|
236
|
+
...other.entries.keys(),
|
|
237
|
+
]);
|
|
238
|
+
for (const replica of allReplicas) {
|
|
239
|
+
const thisTime = this.get(replica);
|
|
240
|
+
const otherTime = other.get(replica);
|
|
241
|
+
this.entries.set(replica, Math.max(thisTime, otherTime));
|
|
242
|
+
}
|
|
243
|
+
this.lastModified = Date.now();
|
|
244
|
+
this.compact();
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Create a merged clock without modifying this clock
|
|
249
|
+
*
|
|
250
|
+
* @param other - Clock to merge with
|
|
251
|
+
* @returns New merged clock
|
|
252
|
+
*/
|
|
253
|
+
merged(other) {
|
|
254
|
+
return this.clone().merge(other);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Update this clock to receive a message from another replica
|
|
258
|
+
*
|
|
259
|
+
* This performs the standard vector clock receive operation:
|
|
260
|
+
* 1. Merge with the message's clock
|
|
261
|
+
* 2. Increment local replica's timestamp
|
|
262
|
+
*
|
|
263
|
+
* @param messageClock - Clock from received message
|
|
264
|
+
* @returns This clock (mutated)
|
|
265
|
+
*/
|
|
266
|
+
receive(messageClock) {
|
|
267
|
+
this.merge(messageClock);
|
|
268
|
+
this.increment();
|
|
269
|
+
return this;
|
|
270
|
+
}
|
|
271
|
+
// ============================================
|
|
272
|
+
// Compaction
|
|
273
|
+
// ============================================
|
|
274
|
+
/**
|
|
275
|
+
* Compact the clock by removing zero entries for non-local replicas
|
|
276
|
+
*
|
|
277
|
+
* @returns Number of entries removed
|
|
278
|
+
*/
|
|
279
|
+
compact() {
|
|
280
|
+
if (this.entries.size <= types_1.MAX_VECTOR_CLOCK_SIZE) {
|
|
281
|
+
return 0;
|
|
282
|
+
}
|
|
283
|
+
let removed = 0;
|
|
284
|
+
// Sort entries by timestamp (ascending) and remove lowest
|
|
285
|
+
const sortedEntries = Array.from(this.entries.entries())
|
|
286
|
+
.filter(([id]) => id !== this.localReplicaId)
|
|
287
|
+
.sort((a, b) => a[1] - b[1]);
|
|
288
|
+
const toRemove = this.entries.size - types_1.MAX_VECTOR_CLOCK_SIZE;
|
|
289
|
+
for (let i = 0; i < toRemove && i < sortedEntries.length; i++) {
|
|
290
|
+
const [id, timestamp] = sortedEntries[i];
|
|
291
|
+
// Only remove if timestamp is 0 or very old
|
|
292
|
+
if (timestamp === 0) {
|
|
293
|
+
this.entries.delete(id);
|
|
294
|
+
removed++;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return removed;
|
|
298
|
+
}
|
|
299
|
+
// ============================================
|
|
300
|
+
// Serialization
|
|
301
|
+
// ============================================
|
|
302
|
+
/**
|
|
303
|
+
* Convert to serializable format
|
|
304
|
+
*
|
|
305
|
+
* @returns Serialized vector clock
|
|
306
|
+
*/
|
|
307
|
+
serialize() {
|
|
308
|
+
const entries = {};
|
|
309
|
+
for (const [id, timestamp] of this.entries) {
|
|
310
|
+
entries[id] = timestamp;
|
|
311
|
+
}
|
|
312
|
+
return {
|
|
313
|
+
entries,
|
|
314
|
+
lastModified: this.lastModified,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Create a vector clock from serialized data
|
|
319
|
+
*
|
|
320
|
+
* @param serialized - Serialized clock data
|
|
321
|
+
* @param replicaId - Local replica ID
|
|
322
|
+
* @returns New vector clock
|
|
323
|
+
*/
|
|
324
|
+
static fromSerialized(serialized, replicaId) {
|
|
325
|
+
const entries = new Map();
|
|
326
|
+
for (const [id, timestamp] of Object.entries(serialized.entries)) {
|
|
327
|
+
entries.set(id, timestamp);
|
|
328
|
+
}
|
|
329
|
+
const clock = new VectorClock(replicaId, entries);
|
|
330
|
+
clock.lastModified = serialized.lastModified;
|
|
331
|
+
return clock;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Convert to JSON string
|
|
335
|
+
*
|
|
336
|
+
* @returns JSON representation
|
|
337
|
+
*/
|
|
338
|
+
toJSON() {
|
|
339
|
+
return JSON.stringify(this.serialize());
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Parse from JSON string
|
|
343
|
+
*
|
|
344
|
+
* @param json - JSON string
|
|
345
|
+
* @param replicaId - Local replica ID
|
|
346
|
+
* @returns Parsed vector clock
|
|
347
|
+
*/
|
|
348
|
+
static fromJSON(json, replicaId) {
|
|
349
|
+
try {
|
|
350
|
+
const parsed = JSON.parse(json);
|
|
351
|
+
return VectorClock.fromSerialized(parsed, replicaId);
|
|
352
|
+
}
|
|
353
|
+
catch (error) {
|
|
354
|
+
throw new types_1.CRDTError(`Failed to parse vector clock: ${error instanceof Error ? error.message : String(error)}`, types_1.CRDTErrorCode.DeserializationError);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
// ============================================
|
|
358
|
+
// Utility Methods
|
|
359
|
+
// ============================================
|
|
360
|
+
/**
|
|
361
|
+
* Create a deep copy of this clock
|
|
362
|
+
*
|
|
363
|
+
* @returns Cloned vector clock
|
|
364
|
+
*/
|
|
365
|
+
clone() {
|
|
366
|
+
const cloned = new VectorClock(this.localReplicaId, new Map(this.entries));
|
|
367
|
+
cloned.lastModified = this.lastModified;
|
|
368
|
+
return cloned;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Reset the clock to initial state
|
|
372
|
+
*/
|
|
373
|
+
reset() {
|
|
374
|
+
this.entries.clear();
|
|
375
|
+
this.entries.set(this.localReplicaId, 0);
|
|
376
|
+
this.lastModified = Date.now();
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Get the state of the clock
|
|
380
|
+
*
|
|
381
|
+
* @returns Internal state
|
|
382
|
+
*/
|
|
383
|
+
getState() {
|
|
384
|
+
return {
|
|
385
|
+
entries: new Map(this.entries),
|
|
386
|
+
lastModified: this.lastModified,
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Get the local replica ID
|
|
391
|
+
*
|
|
392
|
+
* @returns Replica ID
|
|
393
|
+
*/
|
|
394
|
+
getReplicaId() {
|
|
395
|
+
return this.localReplicaId;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Get the last modification timestamp
|
|
399
|
+
*
|
|
400
|
+
* @returns Wall timestamp
|
|
401
|
+
*/
|
|
402
|
+
getLastModified() {
|
|
403
|
+
return this.lastModified;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Create a string representation for debugging
|
|
407
|
+
*
|
|
408
|
+
* @returns Debug string
|
|
409
|
+
*/
|
|
410
|
+
toString() {
|
|
411
|
+
const pairs = Array.from(this.entries.entries())
|
|
412
|
+
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
413
|
+
.map(([id, ts]) => `${id}:${ts}`)
|
|
414
|
+
.join(', ');
|
|
415
|
+
return `VectorClock{${pairs}}`;
|
|
416
|
+
}
|
|
417
|
+
// ============================================
|
|
418
|
+
// Static Factory Methods
|
|
419
|
+
// ============================================
|
|
420
|
+
/**
|
|
421
|
+
* Create an empty vector clock
|
|
422
|
+
*
|
|
423
|
+
* @param replicaId - Local replica ID
|
|
424
|
+
* @returns New empty clock
|
|
425
|
+
*/
|
|
426
|
+
static empty(replicaId) {
|
|
427
|
+
return new VectorClock(replicaId);
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Create a vector clock with initial timestamp
|
|
431
|
+
*
|
|
432
|
+
* @param replicaId - Local replica ID
|
|
433
|
+
* @param initialTimestamp - Initial timestamp for local replica
|
|
434
|
+
* @returns New clock with initial timestamp
|
|
435
|
+
*/
|
|
436
|
+
static withTimestamp(replicaId, initialTimestamp) {
|
|
437
|
+
const clock = new VectorClock(replicaId);
|
|
438
|
+
clock.set(replicaId, initialTimestamp);
|
|
439
|
+
return clock;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Create a vector clock from a plain object
|
|
443
|
+
*
|
|
444
|
+
* @param replicaId - Local replica ID
|
|
445
|
+
* @param entries - Object mapping replica IDs to timestamps
|
|
446
|
+
* @returns New clock from entries
|
|
447
|
+
*/
|
|
448
|
+
static fromEntries(replicaId, entries) {
|
|
449
|
+
const map = new Map();
|
|
450
|
+
for (const [id, ts] of Object.entries(entries)) {
|
|
451
|
+
map.set(id, ts);
|
|
452
|
+
}
|
|
453
|
+
return new VectorClock(replicaId, map);
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Compute the maximum (join) of multiple clocks
|
|
457
|
+
*
|
|
458
|
+
* @param replicaId - Local replica ID for result
|
|
459
|
+
* @param clocks - Clocks to join
|
|
460
|
+
* @returns Joined clock
|
|
461
|
+
*/
|
|
462
|
+
static max(replicaId, ...clocks) {
|
|
463
|
+
if (clocks.length === 0) {
|
|
464
|
+
return VectorClock.empty(replicaId);
|
|
465
|
+
}
|
|
466
|
+
const result = clocks[0].clone();
|
|
467
|
+
for (let i = 1; i < clocks.length; i++) {
|
|
468
|
+
result.merge(clocks[i]);
|
|
469
|
+
}
|
|
470
|
+
return result;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Check if a serialized clock is valid
|
|
474
|
+
*
|
|
475
|
+
* @param serialized - Serialized clock to validate
|
|
476
|
+
* @returns True if valid
|
|
477
|
+
*/
|
|
478
|
+
static isValid(serialized) {
|
|
479
|
+
if (typeof serialized !== 'object' || serialized === null) {
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
const obj = serialized;
|
|
483
|
+
if (typeof obj.entries !== 'object' || obj.entries === null) {
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
if (typeof obj.lastModified !== 'number') {
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
const entries = obj.entries;
|
|
490
|
+
for (const value of Object.values(entries)) {
|
|
491
|
+
if (typeof value !== 'number' || value < 0) {
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return true;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
exports.VectorClock = VectorClock;
|
|
499
|
+
//# sourceMappingURL=VectorClock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VectorClock.js","sourceRoot":"","sources":["../../../../src/edge/p2p/crdt/VectorClock.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,mCAUiB;AAEjB,+CAA+C;AAC/C,qBAAqB;AACrB,+CAA+C;AAE/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,WAAW;IAUtB;;;;;OAKG;IACH,YAAY,SAAoB,EAAE,OAA0C;QAC1E,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;QACtD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE/B,gDAAgD;QAChD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC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@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CRDT Module for P2P Conflict Resolution
|
|
3
|
+
*
|
|
4
|
+
* Conflict-free Replicated Data Types (CRDTs) for automatic conflict
|
|
5
|
+
* resolution in distributed pattern storage. Enables eventual consistency
|
|
6
|
+
* without coordination between peers.
|
|
7
|
+
*
|
|
8
|
+
* CRDTs Included:
|
|
9
|
+
* - GCounter: Grow-only counter (increment only)
|
|
10
|
+
* - LWWRegister: Last-Writer-Wins register (timestamp-based)
|
|
11
|
+
* - ORSet: Observed-Remove set (add-wins semantics)
|
|
12
|
+
* - PatternCRDT: Composite CRDT for SharedPattern objects
|
|
13
|
+
*
|
|
14
|
+
* @module edge/p2p/crdt
|
|
15
|
+
* @version 1.0.0
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import {
|
|
20
|
+
* CRDTStore,
|
|
21
|
+
* GCounter,
|
|
22
|
+
* LWWRegister,
|
|
23
|
+
* ORSet,
|
|
24
|
+
* PatternCRDT,
|
|
25
|
+
* VectorClock,
|
|
26
|
+
* } from '@ruvector/edge/p2p/crdt';
|
|
27
|
+
*
|
|
28
|
+
* // Create a store
|
|
29
|
+
* const store = new CRDTStore({
|
|
30
|
+
* replicaId: 'agent-1',
|
|
31
|
+
* autoGC: true,
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* // Create CRDTs
|
|
35
|
+
* const counter = store.createGCounter('page-views');
|
|
36
|
+
* counter.increment();
|
|
37
|
+
*
|
|
38
|
+
* const tags = store.createORSet<string>('tags');
|
|
39
|
+
* tags.add('typescript');
|
|
40
|
+
* tags.add('testing');
|
|
41
|
+
*
|
|
42
|
+
* const pattern = store.createPattern({
|
|
43
|
+
* id: 'pattern-1',
|
|
44
|
+
* content: 'test code...',
|
|
45
|
+
* type: 'unit-test',
|
|
46
|
+
* category: 'test',
|
|
47
|
+
* domain: 'api',
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* // Merge remote state
|
|
51
|
+
* store.applyState(remoteState);
|
|
52
|
+
*
|
|
53
|
+
* // Generate deltas for sync
|
|
54
|
+
* const deltas = store.generateDeltas(lastSyncClock);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export * from './types';
|
|
58
|
+
export { VectorClock } from './VectorClock';
|
|
59
|
+
export { GCounter } from './GCounter';
|
|
60
|
+
export { LWWRegister } from './LWWRegister';
|
|
61
|
+
export { ORSet } from './ORSet';
|
|
62
|
+
export { PatternCRDT, type PatternInput, type PatternData, type ModificationEntry } from './PatternCRDT';
|
|
63
|
+
export { CRDTStore } from './CRDTStore';
|
|
64
|
+
/**
|
|
65
|
+
* CRDT module version
|
|
66
|
+
*/
|
|
67
|
+
export declare const CRDT_VERSION = "1.0.0";
|
|
68
|
+
/**
|
|
69
|
+
* CRDT module capabilities
|
|
70
|
+
*/
|
|
71
|
+
export declare const CRDT_CAPABILITIES: {
|
|
72
|
+
gCounter: boolean;
|
|
73
|
+
pnCounter: boolean;
|
|
74
|
+
lwwRegister: boolean;
|
|
75
|
+
mvRegister: boolean;
|
|
76
|
+
orSet: boolean;
|
|
77
|
+
twoPhaseSet: boolean;
|
|
78
|
+
lwwMap: boolean;
|
|
79
|
+
orMap: boolean;
|
|
80
|
+
patternCRDT: boolean;
|
|
81
|
+
vectorClocks: boolean;
|
|
82
|
+
deltaSync: boolean;
|
|
83
|
+
tombstoneGC: boolean;
|
|
84
|
+
conflictTracking: boolean;
|
|
85
|
+
eventEmission: boolean;
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/edge/p2p/crdt/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGzG,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,YAAY,UAAU,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;CA0B7B,CAAC"}
|