agentic-qe 2.6.6 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -0
- package/README.md +1 -1
- package/dist/adapters/MemoryStoreAdapter.d.ts +14 -14
- package/dist/adapters/MemoryStoreAdapter.d.ts.map +1 -1
- package/dist/adapters/MemoryStoreAdapter.js.map +1 -1
- package/dist/agents/AccessibilityAllyAgent.d.ts.map +1 -1
- package/dist/agents/AccessibilityAllyAgent.js +24 -11
- package/dist/agents/AccessibilityAllyAgent.js.map +1 -1
- package/dist/agents/ApiContractValidatorAgent.d.ts +83 -56
- package/dist/agents/ApiContractValidatorAgent.d.ts.map +1 -1
- package/dist/agents/ApiContractValidatorAgent.js +97 -46
- package/dist/agents/ApiContractValidatorAgent.js.map +1 -1
- package/dist/agents/BaseAgent.d.ts +64 -13
- package/dist/agents/BaseAgent.d.ts.map +1 -1
- package/dist/agents/BaseAgent.js +5 -4
- package/dist/agents/BaseAgent.js.map +1 -1
- package/dist/agents/CodeComplexityAnalyzerAgent.d.ts +19 -12
- package/dist/agents/CodeComplexityAnalyzerAgent.d.ts.map +1 -1
- package/dist/agents/CodeComplexityAnalyzerAgent.js +37 -30
- package/dist/agents/CodeComplexityAnalyzerAgent.js.map +1 -1
- package/dist/agents/CodeIntelligenceAgent.d.ts.map +1 -1
- package/dist/agents/CodeIntelligenceAgent.js.map +1 -1
- package/dist/agents/CoverageAnalyzerAgent.d.ts +170 -41
- package/dist/agents/CoverageAnalyzerAgent.d.ts.map +1 -1
- package/dist/agents/CoverageAnalyzerAgent.js +7 -5
- package/dist/agents/CoverageAnalyzerAgent.js.map +1 -1
- package/dist/agents/DeploymentReadinessAgent.d.ts +56 -14
- package/dist/agents/DeploymentReadinessAgent.d.ts.map +1 -1
- package/dist/agents/DeploymentReadinessAgent.js +37 -35
- package/dist/agents/DeploymentReadinessAgent.js.map +1 -1
- package/dist/agents/FlakyTestHunterAgent.d.ts +57 -19
- package/dist/agents/FlakyTestHunterAgent.d.ts.map +1 -1
- package/dist/agents/FlakyTestHunterAgent.js +53 -53
- package/dist/agents/FlakyTestHunterAgent.js.map +1 -1
- package/dist/agents/FleetCommanderAgent.d.ts +167 -15
- package/dist/agents/FleetCommanderAgent.d.ts.map +1 -1
- package/dist/agents/FleetCommanderAgent.js +57 -46
- package/dist/agents/FleetCommanderAgent.js.map +1 -1
- package/dist/agents/LearningAgent.d.ts +29 -7
- package/dist/agents/LearningAgent.d.ts.map +1 -1
- package/dist/agents/LearningAgent.js +6 -4
- package/dist/agents/LearningAgent.js.map +1 -1
- package/dist/agents/NeuralAgentExtension.d.ts +46 -2
- package/dist/agents/NeuralAgentExtension.d.ts.map +1 -1
- package/dist/agents/NeuralAgentExtension.js +13 -11
- package/dist/agents/NeuralAgentExtension.js.map +1 -1
- package/dist/agents/PerformanceTesterAgent.d.ts +179 -14
- package/dist/agents/PerformanceTesterAgent.d.ts.map +1 -1
- package/dist/agents/PerformanceTesterAgent.js +77 -13
- package/dist/agents/PerformanceTesterAgent.js.map +1 -1
- package/dist/agents/ProductionIntelligenceAgent.d.ts +118 -16
- package/dist/agents/ProductionIntelligenceAgent.d.ts.map +1 -1
- package/dist/agents/ProductionIntelligenceAgent.js +76 -63
- package/dist/agents/ProductionIntelligenceAgent.js.map +1 -1
- package/dist/agents/QXPartnerAgent.d.ts.map +1 -1
- package/dist/agents/QXPartnerAgent.js +40 -30
- package/dist/agents/QXPartnerAgent.js.map +1 -1
- package/dist/agents/QualityAnalyzerAgent.d.ts +113 -6
- package/dist/agents/QualityAnalyzerAgent.d.ts.map +1 -1
- package/dist/agents/QualityAnalyzerAgent.js +30 -25
- package/dist/agents/QualityAnalyzerAgent.js.map +1 -1
- package/dist/agents/QualityGateAgent.d.ts +125 -4
- package/dist/agents/QualityGateAgent.d.ts.map +1 -1
- package/dist/agents/QualityGateAgent.js +13 -15
- package/dist/agents/QualityGateAgent.js.map +1 -1
- package/dist/agents/RegressionRiskAnalyzerAgent.d.ts +33 -14
- package/dist/agents/RegressionRiskAnalyzerAgent.d.ts.map +1 -1
- package/dist/agents/RegressionRiskAnalyzerAgent.js +49 -30
- package/dist/agents/RegressionRiskAnalyzerAgent.js.map +1 -1
- package/dist/agents/RequirementsValidatorAgent.d.ts +11 -14
- package/dist/agents/RequirementsValidatorAgent.d.ts.map +1 -1
- package/dist/agents/RequirementsValidatorAgent.js +41 -33
- package/dist/agents/RequirementsValidatorAgent.js.map +1 -1
- package/dist/agents/SecurityScannerAgent.d.ts +90 -15
- package/dist/agents/SecurityScannerAgent.d.ts.map +1 -1
- package/dist/agents/SecurityScannerAgent.js +64 -48
- package/dist/agents/SecurityScannerAgent.js.map +1 -1
- package/dist/agents/TestDataArchitectAgent.d.ts +140 -57
- package/dist/agents/TestDataArchitectAgent.d.ts.map +1 -1
- package/dist/agents/TestDataArchitectAgent.js +93 -54
- package/dist/agents/TestDataArchitectAgent.js.map +1 -1
- package/dist/agents/TestExecutorAgent.d.ts +43 -18
- package/dist/agents/TestExecutorAgent.d.ts.map +1 -1
- package/dist/agents/TestExecutorAgent.js +33 -25
- package/dist/agents/TestExecutorAgent.js.map +1 -1
- package/dist/agents/TestGeneratorAgent.d.ts +71 -23
- package/dist/agents/TestGeneratorAgent.d.ts.map +1 -1
- package/dist/agents/TestGeneratorAgent.js +117 -58
- package/dist/agents/TestGeneratorAgent.js.map +1 -1
- package/dist/agents/adapters/LearningEngineAdapter.d.ts.map +1 -1
- package/dist/agents/adapters/LearningEngineAdapter.js.map +1 -1
- package/dist/agents/adapters/MemoryServiceAdapter.d.ts.map +1 -1
- package/dist/agents/adapters/MemoryServiceAdapter.js +10 -6
- package/dist/agents/adapters/MemoryServiceAdapter.js.map +1 -1
- package/dist/agents/index.d.ts +36 -5
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +1 -1
- package/dist/agents/index.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.d.ts.map +1 -1
- package/dist/agents/n8n/N8nBaseAgent.js +2 -1
- package/dist/agents/n8n/N8nBaseAgent.js.map +1 -1
- package/dist/agents/n8n/N8nCIOrchestratorAgent.d.ts.map +1 -1
- package/dist/agents/n8n/N8nCIOrchestratorAgent.js +2 -1
- package/dist/agents/n8n/N8nCIOrchestratorAgent.js.map +1 -1
- package/dist/agents/n8n/N8nChaosTesterAgent.d.ts.map +1 -1
- package/dist/agents/n8n/N8nChaosTesterAgent.js +2 -1
- package/dist/agents/n8n/N8nChaosTesterAgent.js.map +1 -1
- package/dist/agents/n8n/N8nReplayabilityTesterAgent.d.ts.map +1 -1
- package/dist/agents/n8n/N8nReplayabilityTesterAgent.js +2 -1
- package/dist/agents/n8n/N8nReplayabilityTesterAgent.js.map +1 -1
- package/dist/agents/n8n/N8nTestHarness.d.ts.map +1 -1
- package/dist/agents/n8n/N8nTestHarness.js +7 -3
- package/dist/agents/n8n/N8nTestHarness.js.map +1 -1
- package/dist/cli/commands/agent/assign.d.ts.map +1 -1
- package/dist/cli/commands/agent/assign.js +4 -3
- package/dist/cli/commands/agent/assign.js.map +1 -1
- package/dist/cli/commands/analyze.d.ts.map +1 -1
- package/dist/cli/commands/analyze.js +221 -66
- package/dist/cli/commands/analyze.js.map +1 -1
- package/dist/cli/commands/constitution.d.ts.map +1 -1
- package/dist/cli/commands/constitution.js +4 -3
- package/dist/cli/commands/constitution.js.map +1 -1
- package/dist/cli/commands/fleet/backup.d.ts +4 -4
- package/dist/cli/commands/fleet/backup.d.ts.map +1 -1
- package/dist/cli/commands/fleet/backup.js +4 -4
- package/dist/cli/commands/fleet/backup.js.map +1 -1
- package/dist/cli/commands/fleet/health.d.ts +131 -1
- package/dist/cli/commands/fleet/health.d.ts.map +1 -1
- package/dist/cli/commands/fleet/health.js +204 -138
- package/dist/cli/commands/fleet/health.js.map +1 -1
- package/dist/cli/commands/fleet/metrics.d.ts.map +1 -1
- package/dist/cli/commands/fleet/metrics.js +1 -1
- package/dist/cli/commands/fleet/metrics.js.map +1 -1
- package/dist/cli/commands/fleet/monitor.d.ts.map +1 -1
- package/dist/cli/commands/fleet/monitor.js +2 -1
- package/dist/cli/commands/fleet/monitor.js.map +1 -1
- package/dist/cli/commands/fleet/restart.d.ts.map +1 -1
- package/dist/cli/commands/fleet/restart.js +1 -1
- package/dist/cli/commands/fleet/restart.js.map +1 -1
- package/dist/cli/commands/fleet/shutdown.d.ts.map +1 -1
- package/dist/cli/commands/fleet/shutdown.js.map +1 -1
- package/dist/cli/commands/fleet/status.d.ts.map +1 -1
- package/dist/cli/commands/fleet/status.js +1 -1
- package/dist/cli/commands/fleet/status.js.map +1 -1
- package/dist/cli/commands/fleet/topology.d.ts.map +1 -1
- package/dist/cli/commands/fleet/topology.js +9 -8
- package/dist/cli/commands/fleet/topology.js.map +1 -1
- package/dist/cli/commands/fleet.d.ts +8 -0
- package/dist/cli/commands/fleet.d.ts.map +1 -1
- package/dist/cli/commands/fleet.js +55 -21
- package/dist/cli/commands/fleet.js.map +1 -1
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +6 -2
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/improve/index.d.ts +2 -2
- package/dist/cli/commands/improve/index.d.ts.map +1 -1
- package/dist/cli/commands/improve/index.js +76 -38
- package/dist/cli/commands/improve/index.js.map +1 -1
- package/dist/cli/commands/learn/index.d.ts.map +1 -1
- package/dist/cli/commands/learn/index.js +57 -19
- package/dist/cli/commands/learn/index.js.map +1 -1
- package/dist/cli/commands/memory/index.d.ts +23 -4
- package/dist/cli/commands/memory/index.d.ts.map +1 -1
- package/dist/cli/commands/memory/index.js.map +1 -1
- package/dist/cli/commands/memory/stats.js +1 -1
- package/dist/cli/commands/memory/stats.js.map +1 -1
- package/dist/cli/commands/memory/vacuum.js +3 -3
- package/dist/cli/commands/memory/vacuum.js.map +1 -1
- package/dist/cli/commands/patterns/extract.d.ts.map +1 -1
- package/dist/cli/commands/patterns/extract.js +7 -5
- package/dist/cli/commands/patterns/extract.js.map +1 -1
- package/dist/cli/commands/patterns/index-new.d.ts +10 -1
- package/dist/cli/commands/patterns/index-new.d.ts.map +1 -1
- package/dist/cli/commands/patterns/index-new.js.map +1 -1
- package/dist/cli/commands/patterns/index.d.ts +2 -2
- package/dist/cli/commands/patterns/index.d.ts.map +1 -1
- package/dist/cli/commands/patterns/index.js +105 -19
- package/dist/cli/commands/patterns/index.js.map +1 -1
- package/dist/cli/commands/patterns/list.d.ts.map +1 -1
- package/dist/cli/commands/patterns/list.js +2 -1
- package/dist/cli/commands/patterns/list.js.map +1 -1
- package/dist/cli/commands/patterns/search.d.ts.map +1 -1
- package/dist/cli/commands/patterns/search.js +2 -1
- package/dist/cli/commands/patterns/search.js.map +1 -1
- package/dist/cli/commands/patterns/show.d.ts.map +1 -1
- package/dist/cli/commands/patterns/show.js +7 -6
- package/dist/cli/commands/patterns/show.js.map +1 -1
- package/dist/cli/commands/patterns/stats.d.ts.map +1 -1
- package/dist/cli/commands/patterns/stats.js +5 -4
- package/dist/cli/commands/patterns/stats.js.map +1 -1
- package/dist/cli/commands/quality/baseline.d.ts.map +1 -1
- package/dist/cli/commands/quality/baseline.js +2 -2
- package/dist/cli/commands/quality/baseline.js.map +1 -1
- package/dist/cli/commands/quality/compare.d.ts.map +1 -1
- package/dist/cli/commands/quality/compare.js +1 -1
- package/dist/cli/commands/quality/compare.js.map +1 -1
- package/dist/cli/commands/quality/trends.d.ts.map +1 -1
- package/dist/cli/commands/quality/trends.js.map +1 -1
- package/dist/cli/commands/routing/index.d.ts.map +1 -1
- package/dist/cli/commands/routing/index.js +90 -35
- package/dist/cli/commands/routing/index.js.map +1 -1
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +59 -33
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/workflow/cancel.d.ts +14 -7
- package/dist/cli/commands/workflow/cancel.d.ts.map +1 -1
- package/dist/cli/commands/workflow/cancel.js +23 -6
- package/dist/cli/commands/workflow/cancel.js.map +1 -1
- package/dist/cli/commands/workflow/list.d.ts.map +1 -1
- package/dist/cli/commands/workflow/list.js +46 -9
- package/dist/cli/commands/workflow/list.js.map +1 -1
- package/dist/cli/commands/workflow/pause.d.ts +1 -1
- package/dist/cli/commands/workflow/pause.d.ts.map +1 -1
- package/dist/cli/commands/workflow/pause.js +21 -4
- package/dist/cli/commands/workflow/pause.js.map +1 -1
- package/dist/cli/index-working.js +15 -17
- package/dist/cli/index-working.js.map +1 -1
- package/dist/core/ArtifactWorkflow.d.ts.map +1 -1
- package/dist/core/ArtifactWorkflow.js +130 -43
- package/dist/core/ArtifactWorkflow.js.map +1 -1
- package/dist/core/MemoryManager.d.ts +5 -5
- package/dist/core/MemoryManager.d.ts.map +1 -1
- package/dist/core/MemoryManager.js +4 -3
- package/dist/core/MemoryManager.js.map +1 -1
- package/dist/core/PatternDatabaseAdapter.d.ts +1 -1
- package/dist/core/PatternDatabaseAdapter.d.ts.map +1 -1
- package/dist/core/PatternDatabaseAdapter.js +12 -12
- package/dist/core/PatternDatabaseAdapter.js.map +1 -1
- package/dist/core/Task.d.ts +33 -9
- package/dist/core/Task.d.ts.map +1 -1
- package/dist/core/Task.js.map +1 -1
- package/dist/core/cache/BinaryMetadataCache.d.ts.map +1 -1
- package/dist/core/cache/BinaryMetadataCache.js +2 -1
- package/dist/core/cache/BinaryMetadataCache.js.map +1 -1
- package/dist/core/coordination/BlackboardCoordination.d.ts +2 -2
- package/dist/core/coordination/BlackboardCoordination.d.ts.map +1 -1
- package/dist/core/coordination/ConsensusGating.d.ts.map +1 -1
- package/dist/core/coordination/ConsensusGating.js +50 -9
- package/dist/core/coordination/ConsensusGating.js.map +1 -1
- package/dist/core/coordination/GOAPCoordination.d.ts +1 -1
- package/dist/core/coordination/GOAPCoordination.d.ts.map +1 -1
- package/dist/core/coordination/GOAPCoordination.js +70 -8
- package/dist/core/coordination/GOAPCoordination.js.map +1 -1
- package/dist/core/coordination/OODACoordination.d.ts +10 -10
- package/dist/core/coordination/OODACoordination.d.ts.map +1 -1
- package/dist/core/coordination/OODACoordination.js +48 -9
- package/dist/core/coordination/OODACoordination.js.map +1 -1
- package/dist/core/hooks/RollbackManager.d.ts +2 -2
- package/dist/core/hooks/RollbackManager.d.ts.map +1 -1
- package/dist/core/hooks/RollbackManager.js +41 -4
- package/dist/core/hooks/RollbackManager.js.map +1 -1
- package/dist/core/hooks/VerificationHookManager.d.ts +8 -8
- package/dist/core/hooks/VerificationHookManager.d.ts.map +1 -1
- package/dist/core/hooks/VerificationHookManager.js +12 -2
- package/dist/core/hooks/VerificationHookManager.js.map +1 -1
- package/dist/core/hooks/checkers/ConfigurationChecker.d.ts +1 -1
- package/dist/core/hooks/checkers/ConfigurationChecker.d.ts.map +1 -1
- package/dist/core/hooks/checkers/ConfigurationChecker.js.map +1 -1
- package/dist/core/hooks/validators/OutputValidator.d.ts +2 -2
- package/dist/core/hooks/validators/OutputValidator.d.ts.map +1 -1
- package/dist/core/hooks/validators/QualityValidator.d.ts +1 -1
- package/dist/core/hooks/validators/QualityValidator.d.ts.map +1 -1
- package/dist/core/memory/AgentDBIntegration.d.ts +88 -0
- package/dist/core/memory/AgentDBIntegration.d.ts.map +1 -1
- package/dist/core/memory/AgentDBIntegration.js +189 -3
- package/dist/core/memory/AgentDBIntegration.js.map +1 -1
- package/dist/core/memory/HNSWVectorMemory.js +1 -1
- package/dist/core/memory/MigrationTools.d.ts +2 -2
- package/dist/core/memory/MigrationTools.d.ts.map +1 -1
- package/dist/core/memory/MigrationTools.js +21 -17
- package/dist/core/memory/MigrationTools.js.map +1 -1
- package/dist/core/memory/NeuralEnhancement.d.ts.map +1 -1
- package/dist/core/memory/NeuralEnhancement.js +11 -8
- package/dist/core/memory/NeuralEnhancement.js.map +1 -1
- package/dist/core/memory/RealAgentDBAdapter.d.ts +6 -2
- package/dist/core/memory/RealAgentDBAdapter.d.ts.map +1 -1
- package/dist/core/memory/RealAgentDBAdapter.js +63 -47
- package/dist/core/memory/RealAgentDBAdapter.js.map +1 -1
- package/dist/core/memory/SwarmMemoryManager.d.ts +143 -37
- package/dist/core/memory/SwarmMemoryManager.d.ts.map +1 -1
- package/dist/core/memory/SwarmMemoryManager.js +28 -25
- package/dist/core/memory/SwarmMemoryManager.js.map +1 -1
- package/dist/core/memory/TieredCompression.d.ts +1 -0
- package/dist/core/memory/TieredCompression.d.ts.map +1 -1
- package/dist/core/memory/TieredCompression.js +4 -2
- package/dist/core/memory/TieredCompression.js.map +1 -1
- package/dist/core/memory/VersionHistory.d.ts +5 -5
- package/dist/core/memory/VersionHistory.d.ts.map +1 -1
- package/dist/core/memory/VersionHistory.js +37 -4
- package/dist/core/memory/VersionHistory.js.map +1 -1
- package/dist/core/memory/dao/BlackboardDAO.d.ts.map +1 -1
- package/dist/core/memory/dao/BlackboardDAO.js +2 -1
- package/dist/core/memory/dao/BlackboardDAO.js.map +1 -1
- package/dist/core/metrics/InferenceCostTracker.d.ts.map +1 -1
- package/dist/core/metrics/InferenceCostTracker.js +2 -1
- package/dist/core/metrics/InferenceCostTracker.js.map +1 -1
- package/dist/core/neural/NeuralTrainer.d.ts +12 -0
- package/dist/core/neural/NeuralTrainer.d.ts.map +1 -1
- package/dist/core/neural/NeuralTrainer.js +162 -18
- package/dist/core/neural/NeuralTrainer.js.map +1 -1
- package/dist/core/optimization/SwarmOptimizer.d.ts.map +1 -1
- package/dist/core/optimization/SwarmOptimizer.js +198 -26
- package/dist/core/optimization/SwarmOptimizer.js.map +1 -1
- package/dist/core/orchestration/WorkflowOrchestrator.d.ts +5 -1
- package/dist/core/orchestration/WorkflowOrchestrator.d.ts.map +1 -1
- package/dist/core/orchestration/WorkflowOrchestrator.js +60 -13
- package/dist/core/orchestration/WorkflowOrchestrator.js.map +1 -1
- package/dist/core/orchestration/types.d.ts +8 -8
- package/dist/core/orchestration/types.d.ts.map +1 -1
- package/dist/core/recovery/RetryStrategy.d.ts +2 -1
- package/dist/core/recovery/RetryStrategy.d.ts.map +1 -1
- package/dist/core/recovery/RetryStrategy.js +5 -2
- package/dist/core/recovery/RetryStrategy.js.map +1 -1
- package/dist/core/routing/AdaptiveModelRouter.d.ts +3 -3
- package/dist/core/routing/AdaptiveModelRouter.d.ts.map +1 -1
- package/dist/core/routing/AdaptiveModelRouter.js.map +1 -1
- package/dist/core/routing/CostTracker.d.ts +10 -2
- package/dist/core/routing/CostTracker.d.ts.map +1 -1
- package/dist/core/routing/CostTracker.js +36 -4
- package/dist/core/routing/CostTracker.js.map +1 -1
- package/dist/core/routing/FleetManagerIntegration.d.ts +1 -1
- package/dist/core/routing/types.d.ts +41 -4
- package/dist/core/routing/types.d.ts.map +1 -1
- package/dist/core/strategies/DefaultCoordinationStrategy.js +1 -1
- package/dist/core/strategies/DefaultCoordinationStrategy.js.map +1 -1
- package/dist/core/strategies/DefaultLearningStrategy.d.ts.map +1 -1
- package/dist/core/strategies/DefaultLearningStrategy.js +2 -1
- package/dist/core/strategies/DefaultLearningStrategy.js.map +1 -1
- package/dist/core/strategies/DefaultMemoryStrategy.d.ts.map +1 -1
- package/dist/core/strategies/DefaultMemoryStrategy.js +33 -1
- package/dist/core/strategies/DefaultMemoryStrategy.js.map +1 -1
- package/dist/learning/ExperienceReplayBuffer.d.ts.map +1 -1
- package/dist/learning/ExperienceReplayBuffer.js +3 -2
- package/dist/learning/ExperienceReplayBuffer.js.map +1 -1
- package/dist/learning/ExperienceSharingProtocol.d.ts.map +1 -1
- package/dist/learning/ExperienceSharingProtocol.js +2 -1
- package/dist/learning/ExperienceSharingProtocol.js.map +1 -1
- package/dist/learning/FederatedManager.d.ts.map +1 -1
- package/dist/learning/FederatedManager.js +6 -5
- package/dist/learning/FederatedManager.js.map +1 -1
- package/dist/learning/ImprovementLoop.d.ts +4 -4
- package/dist/learning/ImprovementLoop.d.ts.map +1 -1
- package/dist/learning/ImprovementLoop.js +108 -9
- package/dist/learning/ImprovementLoop.js.map +1 -1
- package/dist/learning/LearningEngine.d.ts +2 -2
- package/dist/learning/LearningEngine.d.ts.map +1 -1
- package/dist/learning/LearningEngine.js +72 -30
- package/dist/learning/LearningEngine.js.map +1 -1
- package/dist/learning/PerformanceTracker.d.ts.map +1 -1
- package/dist/learning/PerformanceTracker.js +40 -4
- package/dist/learning/PerformanceTracker.js.map +1 -1
- package/dist/learning/QLearningLegacy.d.ts.map +1 -1
- package/dist/learning/QLearningLegacy.js +4 -5
- package/dist/learning/QLearningLegacy.js.map +1 -1
- package/dist/learning/TransferLearningManager.d.ts +1 -1
- package/dist/learning/TransferLearningManager.d.ts.map +1 -1
- package/dist/learning/TransferLearningManager.js +143 -9
- package/dist/learning/TransferLearningManager.js.map +1 -1
- package/dist/learning/algorithms/AbstractRLLearner.d.ts.map +1 -1
- package/dist/learning/algorithms/AbstractRLLearner.js +4 -5
- package/dist/learning/algorithms/AbstractRLLearner.js.map +1 -1
- package/dist/learning/algorithms/ActorCriticLearner.d.ts.map +1 -1
- package/dist/learning/algorithms/ActorCriticLearner.js +4 -4
- package/dist/learning/algorithms/ActorCriticLearner.js.map +1 -1
- package/dist/learning/algorithms/MAMLMetaLearner.d.ts.map +1 -1
- package/dist/learning/algorithms/MAMLMetaLearner.js +2 -1
- package/dist/learning/algorithms/MAMLMetaLearner.js.map +1 -1
- package/dist/learning/algorithms/PPOLearner.d.ts.map +1 -1
- package/dist/learning/algorithms/PPOLearner.js +3 -2
- package/dist/learning/algorithms/PPOLearner.js.map +1 -1
- package/dist/learning/baselines/BaselineCollector.d.ts.map +1 -1
- package/dist/learning/baselines/BaselineCollector.js +5 -4
- package/dist/learning/baselines/BaselineCollector.js.map +1 -1
- package/dist/learning/baselines/StandardTaskSuite.d.ts.map +1 -1
- package/dist/learning/baselines/StandardTaskSuite.js +2 -1
- package/dist/learning/baselines/StandardTaskSuite.js.map +1 -1
- package/dist/learning/capture/ExperienceExtractor.d.ts.map +1 -1
- package/dist/learning/capture/ExperienceExtractor.js +8 -7
- package/dist/learning/capture/ExperienceExtractor.js.map +1 -1
- package/dist/learning/metrics/AlertManager.d.ts.map +1 -1
- package/dist/learning/metrics/AlertManager.js +20 -9
- package/dist/learning/metrics/AlertManager.js.map +1 -1
- package/dist/learning/metrics/LearningMetrics.d.ts.map +1 -1
- package/dist/learning/metrics/LearningMetrics.js +21 -21
- package/dist/learning/metrics/LearningMetrics.js.map +1 -1
- package/dist/learning/metrics/MetricsCollector.d.ts.map +1 -1
- package/dist/learning/metrics/MetricsCollector.js +20 -7
- package/dist/learning/metrics/MetricsCollector.js.map +1 -1
- package/dist/learning/metrics/MetricsStore.js +6 -6
- package/dist/learning/metrics/MetricsStore.js.map +1 -1
- package/dist/learning/synthesis/ClusteringEngine.d.ts.map +1 -1
- package/dist/learning/synthesis/ClusteringEngine.js +3 -2
- package/dist/learning/synthesis/ClusteringEngine.js.map +1 -1
- package/dist/learning/transfer/TransferValidator.d.ts.map +1 -1
- package/dist/learning/transfer/TransferValidator.js +2 -1
- package/dist/learning/transfer/TransferValidator.js.map +1 -1
- package/dist/mcp/handlers/base-handler.d.ts +8 -8
- package/dist/mcp/handlers/base-handler.d.ts.map +1 -1
- package/dist/mcp/handlers/base-handler.js +5 -4
- package/dist/mcp/handlers/base-handler.js.map +1 -1
- package/dist/mcp/handlers/coordination/event-emit.d.ts +2 -2
- package/dist/mcp/handlers/coordination/event-emit.d.ts.map +1 -1
- package/dist/mcp/handlers/coordination/event-emit.js.map +1 -1
- package/dist/mcp/handlers/coordination/event-subscribe.d.ts +2 -2
- package/dist/mcp/handlers/coordination/event-subscribe.d.ts.map +1 -1
- package/dist/mcp/handlers/coordination/event-subscribe.js +2 -1
- package/dist/mcp/handlers/coordination/event-subscribe.js.map +1 -1
- package/dist/mcp/handlers/coordination/task-status.d.ts.map +1 -1
- package/dist/mcp/handlers/coordination/task-status.js +40 -18
- package/dist/mcp/handlers/coordination/task-status.js.map +1 -1
- package/dist/mcp/handlers/coordination/workflow-checkpoint.d.ts +5 -5
- package/dist/mcp/handlers/coordination/workflow-checkpoint.d.ts.map +1 -1
- package/dist/mcp/handlers/coordination/workflow-checkpoint.js +64 -16
- package/dist/mcp/handlers/coordination/workflow-checkpoint.js.map +1 -1
- package/dist/mcp/handlers/coordination/workflow-create.d.ts +3 -3
- package/dist/mcp/handlers/coordination/workflow-create.d.ts.map +1 -1
- package/dist/mcp/handlers/coordination/workflow-execute.d.ts +3 -3
- package/dist/mcp/handlers/coordination/workflow-execute.d.ts.map +1 -1
- package/dist/mcp/handlers/coordination/workflow-execute.js +2 -2
- package/dist/mcp/handlers/coordination/workflow-execute.js.map +1 -1
- package/dist/mcp/handlers/coordination/workflow-resume.d.ts +2 -2
- package/dist/mcp/handlers/coordination/workflow-resume.d.ts.map +1 -1
- package/dist/mcp/handlers/coordination/workflow-resume.js +26 -6
- package/dist/mcp/handlers/coordination/workflow-resume.js.map +1 -1
- package/dist/mcp/handlers/learning/learning-query.d.ts.map +1 -1
- package/dist/mcp/handlers/learning/learning-query.js +1 -1
- package/dist/mcp/handlers/learning/learning-query.js.map +1 -1
- package/dist/mcp/handlers/learning/learning-store-pattern.d.ts.map +1 -1
- package/dist/mcp/handlers/learning/learning-store-pattern.js +2 -1
- package/dist/mcp/handlers/learning/learning-store-pattern.js.map +1 -1
- package/dist/mcp/handlers/phase2/Phase2Tools.d.ts +5 -4
- package/dist/mcp/handlers/phase2/Phase2Tools.d.ts.map +1 -1
- package/dist/mcp/handlers/phase2/Phase2Tools.js +6 -4
- package/dist/mcp/handlers/phase2/Phase2Tools.js.map +1 -1
- package/dist/mcp/handlers/phase3/Phase3DomainTools.d.ts +247 -31
- package/dist/mcp/handlers/phase3/Phase3DomainTools.d.ts.map +1 -1
- package/dist/mcp/handlers/phase3/Phase3DomainTools.js +3 -3
- package/dist/mcp/handlers/phase3/Phase3DomainTools.js.map +1 -1
- package/dist/mcp/handlers/task-orchestrate.d.ts +3 -3
- package/dist/mcp/handlers/task-orchestrate.d.ts.map +1 -1
- package/dist/mcp/handlers/task-orchestrate.js +3 -2
- package/dist/mcp/handlers/task-orchestrate.js.map +1 -1
- package/dist/mcp/handlers/test/generate-integration-tests.d.ts +15 -3
- package/dist/mcp/handlers/test/generate-integration-tests.d.ts.map +1 -1
- package/dist/mcp/handlers/test/generate-integration-tests.js +5 -5
- package/dist/mcp/handlers/test/generate-integration-tests.js.map +1 -1
- package/dist/mcp/handlers/test/generate-unit-tests.js.map +1 -1
- package/dist/mcp/handlers/test/test-coverage-detailed.d.ts.map +1 -1
- package/dist/mcp/handlers/test/test-coverage-detailed.js +1 -1
- package/dist/mcp/handlers/test/test-coverage-detailed.js.map +1 -1
- package/dist/mcp/handlers/test/test-execute-parallel.d.ts.map +1 -1
- package/dist/mcp/handlers/test/test-execute-parallel.js +9 -7
- package/dist/mcp/handlers/test/test-execute-parallel.js.map +1 -1
- package/dist/mcp/handlers/test/test-optimize-sublinear.d.ts +8 -1
- package/dist/mcp/handlers/test/test-optimize-sublinear.d.ts.map +1 -1
- package/dist/mcp/handlers/test/test-optimize-sublinear.js +1 -1
- package/dist/mcp/handlers/test/test-optimize-sublinear.js.map +1 -1
- package/dist/mcp/handlers/test/test-report-comprehensive.d.ts +14 -2
- package/dist/mcp/handlers/test/test-report-comprehensive.d.ts.map +1 -1
- package/dist/mcp/handlers/test/test-report-comprehensive.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 +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +11 -10
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/services/HookExecutor.js.map +1 -1
- package/dist/mcp/tools/qe/flaky-detection/stabilize-auto.d.ts.map +1 -1
- package/dist/mcp/tools/qe/flaky-detection/stabilize-auto.js +3 -2
- package/dist/mcp/tools/qe/flaky-detection/stabilize-auto.js.map +1 -1
- package/dist/mcp/tools/qe/fleet/index.d.ts.map +1 -1
- package/dist/mcp/tools/qe/fleet/index.js +20 -19
- package/dist/mcp/tools/qe/fleet/index.js.map +1 -1
- package/dist/mcp/tools/qe/performance/generate-report.d.ts.map +1 -1
- package/dist/mcp/tools/qe/performance/generate-report.js +2 -1
- package/dist/mcp/tools/qe/performance/generate-report.js.map +1 -1
- package/dist/mcp/tools/qe/performance/monitor-realtime.d.ts.map +1 -1
- package/dist/mcp/tools/qe/performance/monitor-realtime.js +8 -7
- package/dist/mcp/tools/qe/performance/monitor-realtime.js.map +1 -1
- package/dist/mcp/tools/qe/performance/run-benchmark.d.ts.map +1 -1
- package/dist/mcp/tools/qe/performance/run-benchmark.js +2 -2
- package/dist/mcp/tools/qe/performance/run-benchmark.js.map +1 -1
- package/dist/mcp/tools/qe/quality-gates/assess-deployment-risk.d.ts.map +1 -1
- package/dist/mcp/tools/qe/quality-gates/assess-deployment-risk.js +2 -1
- package/dist/mcp/tools/qe/quality-gates/assess-deployment-risk.js.map +1 -1
- package/dist/mcp/tools/qe/quality-gates/evaluate-quality-gate.d.ts.map +1 -1
- package/dist/mcp/tools/qe/quality-gates/evaluate-quality-gate.js +2 -1
- package/dist/mcp/tools/qe/quality-gates/evaluate-quality-gate.js.map +1 -1
- package/dist/mcp/tools/qe/quality-gates/generate-quality-report.d.ts.map +1 -1
- package/dist/mcp/tools/qe/quality-gates/generate-quality-report.js +2 -1
- package/dist/mcp/tools/qe/quality-gates/generate-quality-report.js.map +1 -1
- package/dist/mcp/tools/qe/quality-gates/validate-quality-metrics.d.ts.map +1 -1
- package/dist/mcp/tools/qe/quality-gates/validate-quality-metrics.js +2 -1
- package/dist/mcp/tools/qe/quality-gates/validate-quality-metrics.js.map +1 -1
- package/dist/mcp/tools/qe/regression/analyze-risk.d.ts.map +1 -1
- package/dist/mcp/tools/qe/regression/analyze-risk.js +2 -1
- package/dist/mcp/tools/qe/regression/analyze-risk.js.map +1 -1
- package/dist/mcp/tools/qe/regression/select-tests.d.ts.map +1 -1
- package/dist/mcp/tools/qe/regression/select-tests.js +3 -2
- package/dist/mcp/tools/qe/regression/select-tests.js.map +1 -1
- package/dist/mcp/tools/qe/requirements/generate-bdd-scenarios.d.ts.map +1 -1
- package/dist/mcp/tools/qe/requirements/generate-bdd-scenarios.js +2 -1
- package/dist/mcp/tools/qe/requirements/generate-bdd-scenarios.js.map +1 -1
- package/dist/mcp/tools/qe/requirements/index.d.ts.map +1 -1
- package/dist/mcp/tools/qe/requirements/index.js +2 -1
- package/dist/mcp/tools/qe/requirements/index.js.map +1 -1
- package/dist/mcp/tools/qe/requirements/validate-requirements.d.ts.map +1 -1
- package/dist/mcp/tools/qe/requirements/validate-requirements.js +2 -1
- package/dist/mcp/tools/qe/requirements/validate-requirements.js.map +1 -1
- package/dist/mcp/tools/qe/security/detect-vulnerabilities.d.ts.map +1 -1
- package/dist/mcp/tools/qe/security/detect-vulnerabilities.js +20 -19
- package/dist/mcp/tools/qe/security/detect-vulnerabilities.js.map +1 -1
- package/dist/mcp/tools/qe/security/validate-compliance.d.ts.map +1 -1
- package/dist/mcp/tools/qe/security/validate-compliance.js +4 -4
- package/dist/mcp/tools/qe/security/validate-compliance.js.map +1 -1
- package/dist/mcp/tools/qe/test-data/generate-test-data.d.ts +0 -38
- package/dist/mcp/tools/qe/test-data/generate-test-data.d.ts.map +1 -1
- package/dist/mcp/tools/qe/test-data/generate-test-data.js +2 -1
- package/dist/mcp/tools/qe/test-data/generate-test-data.js.map +1 -1
- package/dist/mcp/tools/qe/test-data/index.d.ts.map +1 -1
- package/dist/mcp/tools/qe/test-data/index.js +2 -1
- package/dist/mcp/tools/qe/test-data/index.js.map +1 -1
- package/dist/mcp/tools/qe/test-data/mask-sensitive-data.d.ts +2 -6
- package/dist/mcp/tools/qe/test-data/mask-sensitive-data.d.ts.map +1 -1
- package/dist/mcp/tools/qe/test-data/mask-sensitive-data.js +2 -1
- package/dist/mcp/tools/qe/test-data/mask-sensitive-data.js.map +1 -1
- package/dist/memory/PatternReplicationService.d.ts.map +1 -1
- package/dist/memory/PatternReplicationService.js +4 -2
- package/dist/memory/PatternReplicationService.js.map +1 -1
- package/dist/output/OutputFormatterImpl.d.ts.map +1 -1
- package/dist/output/OutputFormatterImpl.js +2 -1
- package/dist/output/OutputFormatterImpl.js.map +1 -1
- package/dist/providers/HybridRouterComplexityIntegration.d.ts.map +1 -1
- package/dist/providers/HybridRouterComplexityIntegration.js +2 -1
- package/dist/providers/HybridRouterComplexityIntegration.js.map +1 -1
- package/dist/providers/RuVectorPostgresAdapter.d.ts.map +1 -1
- package/dist/providers/RuVectorPostgresAdapter.js +2 -1
- package/dist/providers/RuVectorPostgresAdapter.js.map +1 -1
- package/dist/reasoning/CodeSignatureGenerator.d.ts +37 -1
- package/dist/reasoning/CodeSignatureGenerator.d.ts.map +1 -1
- package/dist/reasoning/CodeSignatureGenerator.js +113 -53
- package/dist/reasoning/CodeSignatureGenerator.js.map +1 -1
- package/dist/reasoning/PatternExtractor.d.ts +91 -10
- package/dist/reasoning/PatternExtractor.d.ts.map +1 -1
- package/dist/reasoning/PatternExtractor.js +104 -26
- package/dist/reasoning/PatternExtractor.js.map +1 -1
- package/dist/reasoning/PatternMemoryIntegration.d.ts.map +1 -1
- package/dist/reasoning/PatternMemoryIntegration.js +12 -3
- package/dist/reasoning/PatternMemoryIntegration.js.map +1 -1
- package/dist/reporting/reporters/JSONReporter.d.ts +67 -9
- package/dist/reporting/reporters/JSONReporter.d.ts.map +1 -1
- package/dist/reporting/reporters/JSONReporter.js +4 -3
- package/dist/reporting/reporters/JSONReporter.js.map +1 -1
- package/dist/types/hook.types.d.ts +628 -70
- package/dist/types/hook.types.d.ts.map +1 -1
- package/dist/types/index.d.ts +26 -26
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/memory-interfaces.d.ts +25 -14
- package/dist/types/memory-interfaces.d.ts.map +1 -1
- package/dist/utils/Config.d.ts +1 -1
- package/dist/utils/Config.d.ts.map +1 -1
- package/dist/utils/Database.d.ts +187 -44
- package/dist/utils/Database.d.ts.map +1 -1
- package/dist/utils/Database.js +24 -15
- package/dist/utils/Database.js.map +1 -1
- package/dist/utils/ErrorUtils.d.ts +43 -0
- package/dist/utils/ErrorUtils.d.ts.map +1 -0
- package/dist/utils/ErrorUtils.js +78 -0
- package/dist/utils/ErrorUtils.js.map +1 -0
- package/dist/utils/FakerDataGenerator.d.ts +28 -4
- package/dist/utils/FakerDataGenerator.d.ts.map +1 -1
- package/dist/utils/FakerDataGenerator.js +2 -2
- package/dist/utils/FakerDataGenerator.js.map +1 -1
- package/dist/utils/Logger.d.ts +6 -6
- package/dist/utils/Logger.d.ts.map +1 -1
- package/dist/utils/Logger.js +5 -5
- package/dist/utils/Logger.js.map +1 -1
- package/dist/utils/SecureValidation.d.ts +4 -4
- package/dist/utils/SecureValidation.d.ts.map +1 -1
- package/dist/utils/SecureValidation.js.map +1 -1
- package/dist/utils/SecurityScanner.d.ts +1 -0
- package/dist/utils/SecurityScanner.d.ts.map +1 -1
- package/dist/utils/SecurityScanner.js.map +1 -1
- package/dist/utils/SeededRandom.d.ts +297 -0
- package/dist/utils/SeededRandom.d.ts.map +1 -0
- package/dist/utils/SeededRandom.js +389 -0
- package/dist/utils/SeededRandom.js.map +1 -0
- package/dist/utils/TestFrameworkExecutor.d.ts.map +1 -1
- package/dist/utils/TestFrameworkExecutor.js +3 -3
- package/dist/utils/TestFrameworkExecutor.js.map +1 -1
- package/dist/utils/batch-operations.d.ts +2 -2
- package/dist/utils/batch-operations.d.ts.map +1 -1
- package/dist/utils/batch-operations.js.map +1 -1
- package/dist/utils/filtering.d.ts +1 -1
- package/dist/utils/filtering.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +5 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/visualization/api/RestEndpoints.d.ts.map +1 -1
- package/dist/visualization/api/RestEndpoints.js +2 -1
- package/dist/visualization/api/RestEndpoints.js.map +1 -1
- package/dist/visualization/api/WebSocketServer.d.ts.map +1 -1
- package/dist/visualization/api/WebSocketServer.js +2 -1
- package/dist/visualization/api/WebSocketServer.js.map +1 -1
- package/dist/visualization/core/DataTransformer.d.ts.map +1 -1
- package/dist/visualization/core/DataTransformer.js +5 -3
- package/dist/visualization/core/DataTransformer.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeded Random Number Generator
|
|
3
|
+
*
|
|
4
|
+
* Provides deterministic random number generation for testing purposes.
|
|
5
|
+
* Uses the Mulberry32 PRNG algorithm which is fast and has good statistical distribution.
|
|
6
|
+
*
|
|
7
|
+
* Purpose: Eliminates test flakiness caused by Math.random() by providing
|
|
8
|
+
* reproducible random sequences from a known seed.
|
|
9
|
+
*
|
|
10
|
+
* @module utils/SeededRandom
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* SeededRandom class providing deterministic pseudo-random number generation.
|
|
14
|
+
*
|
|
15
|
+
* Uses the Mulberry32 algorithm which is:
|
|
16
|
+
* - Fast (single 32-bit state)
|
|
17
|
+
* - Good statistical distribution
|
|
18
|
+
* - Deterministic for the same seed
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Create with specific seed for reproducible results
|
|
23
|
+
* const rng = new SeededRandom(12345);
|
|
24
|
+
*
|
|
25
|
+
* // Always produces the same sequence
|
|
26
|
+
* console.log(rng.random()); // 0.3745401...
|
|
27
|
+
* console.log(rng.random()); // 0.9507143...
|
|
28
|
+
*
|
|
29
|
+
* // Reset to reproduce the same sequence
|
|
30
|
+
* rng.reset();
|
|
31
|
+
* console.log(rng.random()); // 0.3745401... (same as before)
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare class SeededRandom {
|
|
35
|
+
private seed;
|
|
36
|
+
private initialSeed;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new SeededRandom instance.
|
|
39
|
+
*
|
|
40
|
+
* @param seed - The seed value for the PRNG. If not provided, uses
|
|
41
|
+
* TEST_RANDOM_SEED environment variable or defaults to 42.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // Explicit seed
|
|
46
|
+
* const rng1 = new SeededRandom(12345);
|
|
47
|
+
*
|
|
48
|
+
* // From environment (TEST_RANDOM_SEED=99999)
|
|
49
|
+
* const rng2 = new SeededRandom();
|
|
50
|
+
*
|
|
51
|
+
* // Default seed (42)
|
|
52
|
+
* const rng3 = new SeededRandom();
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
constructor(seed?: number);
|
|
56
|
+
/**
|
|
57
|
+
* Gets the seed from the TEST_RANDOM_SEED environment variable.
|
|
58
|
+
*
|
|
59
|
+
* @returns The parsed seed value or undefined if not set or invalid.
|
|
60
|
+
*/
|
|
61
|
+
private getEnvironmentSeed;
|
|
62
|
+
/**
|
|
63
|
+
* Mulberry32 PRNG algorithm.
|
|
64
|
+
*
|
|
65
|
+
* This is a high-quality 32-bit PRNG that produces a float in [0, 1).
|
|
66
|
+
* It has a period of 2^32 and passes common statistical tests.
|
|
67
|
+
*
|
|
68
|
+
* @returns A pseudo-random float in the range [0, 1).
|
|
69
|
+
*/
|
|
70
|
+
private mulberry32;
|
|
71
|
+
/**
|
|
72
|
+
* Generates a pseudo-random float in the range [0, 1), similar to Math.random().
|
|
73
|
+
*
|
|
74
|
+
* @returns A pseudo-random float in [0, 1).
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const rng = new SeededRandom(42);
|
|
79
|
+
* const value = rng.random(); // 0.3745401...
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
random(): number;
|
|
83
|
+
/**
|
|
84
|
+
* Generates a pseudo-random integer within an inclusive range.
|
|
85
|
+
*
|
|
86
|
+
* @param min - The minimum value (inclusive).
|
|
87
|
+
* @param max - The maximum value (inclusive).
|
|
88
|
+
* @returns A pseudo-random integer in [min, max].
|
|
89
|
+
* @throws {Error} If min > max.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const rng = new SeededRandom(42);
|
|
94
|
+
*
|
|
95
|
+
* // Dice roll (1-6)
|
|
96
|
+
* const roll = rng.randomInt(1, 6);
|
|
97
|
+
*
|
|
98
|
+
* // Random index (0-9)
|
|
99
|
+
* const index = rng.randomInt(0, 9);
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
randomInt(min: number, max: number): number;
|
|
103
|
+
/**
|
|
104
|
+
* Generates a pseudo-random float within a specified range.
|
|
105
|
+
*
|
|
106
|
+
* @param min - The minimum value (inclusive).
|
|
107
|
+
* @param max - The maximum value (exclusive).
|
|
108
|
+
* @returns A pseudo-random float in [min, max).
|
|
109
|
+
* @throws {Error} If min >= max.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const rng = new SeededRandom(42);
|
|
114
|
+
*
|
|
115
|
+
* // Temperature between 36.0 and 38.0
|
|
116
|
+
* const temp = rng.randomFloat(36.0, 38.0);
|
|
117
|
+
*
|
|
118
|
+
* // Probability weight
|
|
119
|
+
* const weight = rng.randomFloat(0.0, 1.0);
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
randomFloat(min: number, max: number): number;
|
|
123
|
+
/**
|
|
124
|
+
* Selects a random element from an array.
|
|
125
|
+
*
|
|
126
|
+
* @param array - The array to select from.
|
|
127
|
+
* @returns A randomly selected element.
|
|
128
|
+
* @throws {Error} If the array is empty.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const rng = new SeededRandom(42);
|
|
133
|
+
* const colors = ['red', 'green', 'blue'];
|
|
134
|
+
* const color = rng.randomElement(colors); // Deterministic selection
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
randomElement<T>(array: T[]): T;
|
|
138
|
+
/**
|
|
139
|
+
* Creates a deterministically shuffled copy of an array using Fisher-Yates algorithm.
|
|
140
|
+
*
|
|
141
|
+
* Note: This returns a new array and does not modify the original.
|
|
142
|
+
*
|
|
143
|
+
* @param array - The array to shuffle.
|
|
144
|
+
* @returns A new array with elements in random order.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const rng = new SeededRandom(42);
|
|
149
|
+
* const original = [1, 2, 3, 4, 5];
|
|
150
|
+
* const shuffled = rng.shuffle(original);
|
|
151
|
+
* // shuffled is deterministically ordered based on seed
|
|
152
|
+
* // original is unchanged
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
shuffle<T>(array: T[]): T[];
|
|
156
|
+
/**
|
|
157
|
+
* Generates a deterministic UUID-like string.
|
|
158
|
+
*
|
|
159
|
+
* Note: This is NOT a cryptographically secure UUID and should only be
|
|
160
|
+
* used for testing purposes where determinism is required.
|
|
161
|
+
*
|
|
162
|
+
* @returns A UUID-like string in format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const rng = new SeededRandom(42);
|
|
167
|
+
* const id = rng.randomUUID(); // "a1b2c3d4-e5f6-4a1b-8c2d-e3f4a5b6c7d8"
|
|
168
|
+
*
|
|
169
|
+
* // Reset and generate again - same UUID
|
|
170
|
+
* rng.reset();
|
|
171
|
+
* const sameId = rng.randomUUID(); // "a1b2c3d4-e5f6-4a1b-8c2d-e3f4a5b6c7d8"
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
randomUUID(): string;
|
|
175
|
+
/**
|
|
176
|
+
* Resets the PRNG to its initial state or a new seed.
|
|
177
|
+
*
|
|
178
|
+
* @param seed - Optional new seed. If not provided, resets to the original seed.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const rng = new SeededRandom(42);
|
|
183
|
+
* const v1 = rng.random();
|
|
184
|
+
* const v2 = rng.random();
|
|
185
|
+
*
|
|
186
|
+
* // Reset to original seed
|
|
187
|
+
* rng.reset();
|
|
188
|
+
* console.log(rng.random() === v1); // true
|
|
189
|
+
*
|
|
190
|
+
* // Reset with new seed
|
|
191
|
+
* rng.reset(99999);
|
|
192
|
+
* console.log(rng.random() !== v1); // true (different seed)
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
reset(seed?: number): void;
|
|
196
|
+
/**
|
|
197
|
+
* Gets the current seed value for reproduction.
|
|
198
|
+
*
|
|
199
|
+
* This can be logged during test failures to reproduce the exact sequence.
|
|
200
|
+
*
|
|
201
|
+
* @returns The initial seed used to create this instance.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const rng = new SeededRandom();
|
|
206
|
+
*
|
|
207
|
+
* // Log seed on test failure for reproduction
|
|
208
|
+
* try {
|
|
209
|
+
* runFlakyTest(rng);
|
|
210
|
+
* } catch (error) {
|
|
211
|
+
* console.log(`Test failed with seed: ${rng.getSeed()}`);
|
|
212
|
+
* throw error;
|
|
213
|
+
* }
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
getSeed(): number;
|
|
217
|
+
/**
|
|
218
|
+
* Generates a random boolean with optional probability.
|
|
219
|
+
*
|
|
220
|
+
* @param trueProbability - Probability of returning true (0.0-1.0, default: 0.5).
|
|
221
|
+
* @returns A pseudo-random boolean.
|
|
222
|
+
* @throws {Error} If probability is not in [0, 1].
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* const rng = new SeededRandom(42);
|
|
227
|
+
*
|
|
228
|
+
* // 50/50 chance
|
|
229
|
+
* const coinFlip = rng.randomBoolean();
|
|
230
|
+
*
|
|
231
|
+
* // 70% chance of true
|
|
232
|
+
* const biased = rng.randomBoolean(0.7);
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
randomBoolean(trueProbability?: number): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Selects multiple random elements from an array without replacement.
|
|
238
|
+
*
|
|
239
|
+
* @param array - The array to sample from.
|
|
240
|
+
* @param count - Number of elements to select.
|
|
241
|
+
* @returns A new array with randomly selected elements.
|
|
242
|
+
* @throws {Error} If count > array.length or count < 0.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* const rng = new SeededRandom(42);
|
|
247
|
+
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
248
|
+
* const sample = rng.sample(numbers, 3); // [7, 2, 9] (deterministic)
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
sample<T>(array: T[], count: number): T[];
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Global singleton instance of SeededRandom.
|
|
255
|
+
*
|
|
256
|
+
* Auto-seeded from TEST_RANDOM_SEED environment variable in test environments,
|
|
257
|
+
* or uses the default seed (42) otherwise.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* import { seededRandom } from './utils/SeededRandom';
|
|
262
|
+
*
|
|
263
|
+
* // Use in tests for deterministic behavior
|
|
264
|
+
* const randomValue = seededRandom.random();
|
|
265
|
+
* const shuffled = seededRandom.shuffle([1, 2, 3, 4, 5]);
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
export declare const seededRandom: SeededRandom;
|
|
269
|
+
/**
|
|
270
|
+
* Factory function to create a new SeededRandom instance with a specific seed.
|
|
271
|
+
*
|
|
272
|
+
* @param seed - The seed for the new PRNG instance.
|
|
273
|
+
* @returns A new SeededRandom instance.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* import { createSeededRandom } from './utils/SeededRandom';
|
|
278
|
+
*
|
|
279
|
+
* // Create instance with known seed for reproducible tests
|
|
280
|
+
* const rng = createSeededRandom(12345);
|
|
281
|
+
*
|
|
282
|
+
* // Each test can have its own isolated RNG
|
|
283
|
+
* describe('MyComponent', () => {
|
|
284
|
+
* let rng: SeededRandom;
|
|
285
|
+
*
|
|
286
|
+
* beforeEach(() => {
|
|
287
|
+
* rng = createSeededRandom(42);
|
|
288
|
+
* });
|
|
289
|
+
*
|
|
290
|
+
* it('should behave consistently', () => {
|
|
291
|
+
* const value = rng.random(); // Always the same
|
|
292
|
+
* });
|
|
293
|
+
* });
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
export declare function createSeededRandom(seed: number): SeededRandom;
|
|
297
|
+
//# sourceMappingURL=SeededRandom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeededRandom.d.ts","sourceRoot":"","sources":["../../src/utils/SeededRandom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,WAAW,CAAS;IAE5B;;;;;;;;;;;;;;;;;OAiBG;gBACS,IAAI,CAAC,EAAE,MAAM;IAKzB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAW1B;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU;IAOlB;;;;;;;;;;OAUG;IACH,MAAM,IAAI,MAAM;IAIhB;;;;;;;;;;;;;;;;;;OAkBG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAO3C;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAO7C;;;;;;;;;;;;;OAaG;IACH,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC;IAO/B;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE;IAS3B;;;;;;;;;;;;;;;;;OAiBG;IACH,UAAU,IAAI,MAAM;IAqBpB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAO1B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,IAAI,MAAM;IAIjB;;;;;;;;;;;;;;;;;OAiBG;IACH,aAAa,CAAC,eAAe,GAAE,MAAY,GAAG,OAAO;IAOrD;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,EAAE;CAW1C;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,cAAqB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAE7D"}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Seeded Random Number Generator
|
|
4
|
+
*
|
|
5
|
+
* Provides deterministic random number generation for testing purposes.
|
|
6
|
+
* Uses the Mulberry32 PRNG algorithm which is fast and has good statistical distribution.
|
|
7
|
+
*
|
|
8
|
+
* Purpose: Eliminates test flakiness caused by Math.random() by providing
|
|
9
|
+
* reproducible random sequences from a known seed.
|
|
10
|
+
*
|
|
11
|
+
* @module utils/SeededRandom
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.seededRandom = exports.SeededRandom = void 0;
|
|
15
|
+
exports.createSeededRandom = createSeededRandom;
|
|
16
|
+
/**
|
|
17
|
+
* Default seed used when no explicit seed is provided and TEST_RANDOM_SEED
|
|
18
|
+
* environment variable is not set.
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_SEED = 42;
|
|
21
|
+
/**
|
|
22
|
+
* SeededRandom class providing deterministic pseudo-random number generation.
|
|
23
|
+
*
|
|
24
|
+
* Uses the Mulberry32 algorithm which is:
|
|
25
|
+
* - Fast (single 32-bit state)
|
|
26
|
+
* - Good statistical distribution
|
|
27
|
+
* - Deterministic for the same seed
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // Create with specific seed for reproducible results
|
|
32
|
+
* const rng = new SeededRandom(12345);
|
|
33
|
+
*
|
|
34
|
+
* // Always produces the same sequence
|
|
35
|
+
* console.log(rng.random()); // 0.3745401...
|
|
36
|
+
* console.log(rng.random()); // 0.9507143...
|
|
37
|
+
*
|
|
38
|
+
* // Reset to reproduce the same sequence
|
|
39
|
+
* rng.reset();
|
|
40
|
+
* console.log(rng.random()); // 0.3745401... (same as before)
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
class SeededRandom {
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new SeededRandom instance.
|
|
46
|
+
*
|
|
47
|
+
* @param seed - The seed value for the PRNG. If not provided, uses
|
|
48
|
+
* TEST_RANDOM_SEED environment variable or defaults to 42.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* // Explicit seed
|
|
53
|
+
* const rng1 = new SeededRandom(12345);
|
|
54
|
+
*
|
|
55
|
+
* // From environment (TEST_RANDOM_SEED=99999)
|
|
56
|
+
* const rng2 = new SeededRandom();
|
|
57
|
+
*
|
|
58
|
+
* // Default seed (42)
|
|
59
|
+
* const rng3 = new SeededRandom();
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
constructor(seed) {
|
|
63
|
+
this.initialSeed = seed ?? this.getEnvironmentSeed() ?? DEFAULT_SEED;
|
|
64
|
+
this.seed = this.initialSeed;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Gets the seed from the TEST_RANDOM_SEED environment variable.
|
|
68
|
+
*
|
|
69
|
+
* @returns The parsed seed value or undefined if not set or invalid.
|
|
70
|
+
*/
|
|
71
|
+
getEnvironmentSeed() {
|
|
72
|
+
const envSeed = process.env.TEST_RANDOM_SEED;
|
|
73
|
+
if (envSeed !== undefined) {
|
|
74
|
+
const parsed = parseInt(envSeed, 10);
|
|
75
|
+
if (!isNaN(parsed)) {
|
|
76
|
+
return parsed;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Mulberry32 PRNG algorithm.
|
|
83
|
+
*
|
|
84
|
+
* This is a high-quality 32-bit PRNG that produces a float in [0, 1).
|
|
85
|
+
* It has a period of 2^32 and passes common statistical tests.
|
|
86
|
+
*
|
|
87
|
+
* @returns A pseudo-random float in the range [0, 1).
|
|
88
|
+
*/
|
|
89
|
+
mulberry32() {
|
|
90
|
+
let t = (this.seed += 0x6d2b79f5);
|
|
91
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
92
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
93
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Generates a pseudo-random float in the range [0, 1), similar to Math.random().
|
|
97
|
+
*
|
|
98
|
+
* @returns A pseudo-random float in [0, 1).
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const rng = new SeededRandom(42);
|
|
103
|
+
* const value = rng.random(); // 0.3745401...
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
random() {
|
|
107
|
+
return this.mulberry32();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Generates a pseudo-random integer within an inclusive range.
|
|
111
|
+
*
|
|
112
|
+
* @param min - The minimum value (inclusive).
|
|
113
|
+
* @param max - The maximum value (inclusive).
|
|
114
|
+
* @returns A pseudo-random integer in [min, max].
|
|
115
|
+
* @throws {Error} If min > max.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const rng = new SeededRandom(42);
|
|
120
|
+
*
|
|
121
|
+
* // Dice roll (1-6)
|
|
122
|
+
* const roll = rng.randomInt(1, 6);
|
|
123
|
+
*
|
|
124
|
+
* // Random index (0-9)
|
|
125
|
+
* const index = rng.randomInt(0, 9);
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
randomInt(min, max) {
|
|
129
|
+
if (min > max) {
|
|
130
|
+
throw new Error(`Invalid range: min (${min}) must be <= max (${max})`);
|
|
131
|
+
}
|
|
132
|
+
return Math.floor(this.mulberry32() * (max - min + 1)) + min;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Generates a pseudo-random float within a specified range.
|
|
136
|
+
*
|
|
137
|
+
* @param min - The minimum value (inclusive).
|
|
138
|
+
* @param max - The maximum value (exclusive).
|
|
139
|
+
* @returns A pseudo-random float in [min, max).
|
|
140
|
+
* @throws {Error} If min >= max.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const rng = new SeededRandom(42);
|
|
145
|
+
*
|
|
146
|
+
* // Temperature between 36.0 and 38.0
|
|
147
|
+
* const temp = rng.randomFloat(36.0, 38.0);
|
|
148
|
+
*
|
|
149
|
+
* // Probability weight
|
|
150
|
+
* const weight = rng.randomFloat(0.0, 1.0);
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
randomFloat(min, max) {
|
|
154
|
+
if (min >= max) {
|
|
155
|
+
throw new Error(`Invalid range: min (${min}) must be < max (${max})`);
|
|
156
|
+
}
|
|
157
|
+
return this.mulberry32() * (max - min) + min;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Selects a random element from an array.
|
|
161
|
+
*
|
|
162
|
+
* @param array - The array to select from.
|
|
163
|
+
* @returns A randomly selected element.
|
|
164
|
+
* @throws {Error} If the array is empty.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const rng = new SeededRandom(42);
|
|
169
|
+
* const colors = ['red', 'green', 'blue'];
|
|
170
|
+
* const color = rng.randomElement(colors); // Deterministic selection
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
randomElement(array) {
|
|
174
|
+
if (array.length === 0) {
|
|
175
|
+
throw new Error('Cannot select from an empty array');
|
|
176
|
+
}
|
|
177
|
+
return array[this.randomInt(0, array.length - 1)];
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Creates a deterministically shuffled copy of an array using Fisher-Yates algorithm.
|
|
181
|
+
*
|
|
182
|
+
* Note: This returns a new array and does not modify the original.
|
|
183
|
+
*
|
|
184
|
+
* @param array - The array to shuffle.
|
|
185
|
+
* @returns A new array with elements in random order.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* const rng = new SeededRandom(42);
|
|
190
|
+
* const original = [1, 2, 3, 4, 5];
|
|
191
|
+
* const shuffled = rng.shuffle(original);
|
|
192
|
+
* // shuffled is deterministically ordered based on seed
|
|
193
|
+
* // original is unchanged
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
shuffle(array) {
|
|
197
|
+
const result = [...array];
|
|
198
|
+
for (let i = result.length - 1; i > 0; i--) {
|
|
199
|
+
const j = this.randomInt(0, i);
|
|
200
|
+
[result[i], result[j]] = [result[j], result[i]];
|
|
201
|
+
}
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Generates a deterministic UUID-like string.
|
|
206
|
+
*
|
|
207
|
+
* Note: This is NOT a cryptographically secure UUID and should only be
|
|
208
|
+
* used for testing purposes where determinism is required.
|
|
209
|
+
*
|
|
210
|
+
* @returns A UUID-like string in format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const rng = new SeededRandom(42);
|
|
215
|
+
* const id = rng.randomUUID(); // "a1b2c3d4-e5f6-4a1b-8c2d-e3f4a5b6c7d8"
|
|
216
|
+
*
|
|
217
|
+
* // Reset and generate again - same UUID
|
|
218
|
+
* rng.reset();
|
|
219
|
+
* const sameId = rng.randomUUID(); // "a1b2c3d4-e5f6-4a1b-8c2d-e3f4a5b6c7d8"
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
randomUUID() {
|
|
223
|
+
const hex = '0123456789abcdef';
|
|
224
|
+
let uuid = '';
|
|
225
|
+
for (let i = 0; i < 36; i++) {
|
|
226
|
+
if (i === 8 || i === 13 || i === 18 || i === 23) {
|
|
227
|
+
uuid += '-';
|
|
228
|
+
}
|
|
229
|
+
else if (i === 14) {
|
|
230
|
+
// Version 4 UUID marker
|
|
231
|
+
uuid += '4';
|
|
232
|
+
}
|
|
233
|
+
else if (i === 19) {
|
|
234
|
+
// Variant bits (8, 9, a, or b)
|
|
235
|
+
uuid += hex[this.randomInt(8, 11)];
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
uuid += hex[this.randomInt(0, 15)];
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return uuid;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Resets the PRNG to its initial state or a new seed.
|
|
245
|
+
*
|
|
246
|
+
* @param seed - Optional new seed. If not provided, resets to the original seed.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```typescript
|
|
250
|
+
* const rng = new SeededRandom(42);
|
|
251
|
+
* const v1 = rng.random();
|
|
252
|
+
* const v2 = rng.random();
|
|
253
|
+
*
|
|
254
|
+
* // Reset to original seed
|
|
255
|
+
* rng.reset();
|
|
256
|
+
* console.log(rng.random() === v1); // true
|
|
257
|
+
*
|
|
258
|
+
* // Reset with new seed
|
|
259
|
+
* rng.reset(99999);
|
|
260
|
+
* console.log(rng.random() !== v1); // true (different seed)
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
reset(seed) {
|
|
264
|
+
if (seed !== undefined) {
|
|
265
|
+
this.initialSeed = seed;
|
|
266
|
+
}
|
|
267
|
+
this.seed = this.initialSeed;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Gets the current seed value for reproduction.
|
|
271
|
+
*
|
|
272
|
+
* This can be logged during test failures to reproduce the exact sequence.
|
|
273
|
+
*
|
|
274
|
+
* @returns The initial seed used to create this instance.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* const rng = new SeededRandom();
|
|
279
|
+
*
|
|
280
|
+
* // Log seed on test failure for reproduction
|
|
281
|
+
* try {
|
|
282
|
+
* runFlakyTest(rng);
|
|
283
|
+
* } catch (error) {
|
|
284
|
+
* console.log(`Test failed with seed: ${rng.getSeed()}`);
|
|
285
|
+
* throw error;
|
|
286
|
+
* }
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
getSeed() {
|
|
290
|
+
return this.initialSeed;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Generates a random boolean with optional probability.
|
|
294
|
+
*
|
|
295
|
+
* @param trueProbability - Probability of returning true (0.0-1.0, default: 0.5).
|
|
296
|
+
* @returns A pseudo-random boolean.
|
|
297
|
+
* @throws {Error} If probability is not in [0, 1].
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```typescript
|
|
301
|
+
* const rng = new SeededRandom(42);
|
|
302
|
+
*
|
|
303
|
+
* // 50/50 chance
|
|
304
|
+
* const coinFlip = rng.randomBoolean();
|
|
305
|
+
*
|
|
306
|
+
* // 70% chance of true
|
|
307
|
+
* const biased = rng.randomBoolean(0.7);
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
randomBoolean(trueProbability = 0.5) {
|
|
311
|
+
if (trueProbability < 0 || trueProbability > 1) {
|
|
312
|
+
throw new Error('Probability must be between 0 and 1');
|
|
313
|
+
}
|
|
314
|
+
return this.random() < trueProbability;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Selects multiple random elements from an array without replacement.
|
|
318
|
+
*
|
|
319
|
+
* @param array - The array to sample from.
|
|
320
|
+
* @param count - Number of elements to select.
|
|
321
|
+
* @returns A new array with randomly selected elements.
|
|
322
|
+
* @throws {Error} If count > array.length or count < 0.
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* const rng = new SeededRandom(42);
|
|
327
|
+
* const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
328
|
+
* const sample = rng.sample(numbers, 3); // [7, 2, 9] (deterministic)
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
sample(array, count) {
|
|
332
|
+
if (count > array.length) {
|
|
333
|
+
throw new Error('Sample size cannot exceed array length');
|
|
334
|
+
}
|
|
335
|
+
if (count < 0) {
|
|
336
|
+
throw new Error('Sample size must be non-negative');
|
|
337
|
+
}
|
|
338
|
+
const shuffled = this.shuffle(array);
|
|
339
|
+
return shuffled.slice(0, count);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
exports.SeededRandom = SeededRandom;
|
|
343
|
+
/**
|
|
344
|
+
* Global singleton instance of SeededRandom.
|
|
345
|
+
*
|
|
346
|
+
* Auto-seeded from TEST_RANDOM_SEED environment variable in test environments,
|
|
347
|
+
* or uses the default seed (42) otherwise.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```typescript
|
|
351
|
+
* import { seededRandom } from './utils/SeededRandom';
|
|
352
|
+
*
|
|
353
|
+
* // Use in tests for deterministic behavior
|
|
354
|
+
* const randomValue = seededRandom.random();
|
|
355
|
+
* const shuffled = seededRandom.shuffle([1, 2, 3, 4, 5]);
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
exports.seededRandom = new SeededRandom();
|
|
359
|
+
/**
|
|
360
|
+
* Factory function to create a new SeededRandom instance with a specific seed.
|
|
361
|
+
*
|
|
362
|
+
* @param seed - The seed for the new PRNG instance.
|
|
363
|
+
* @returns A new SeededRandom instance.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```typescript
|
|
367
|
+
* import { createSeededRandom } from './utils/SeededRandom';
|
|
368
|
+
*
|
|
369
|
+
* // Create instance with known seed for reproducible tests
|
|
370
|
+
* const rng = createSeededRandom(12345);
|
|
371
|
+
*
|
|
372
|
+
* // Each test can have its own isolated RNG
|
|
373
|
+
* describe('MyComponent', () => {
|
|
374
|
+
* let rng: SeededRandom;
|
|
375
|
+
*
|
|
376
|
+
* beforeEach(() => {
|
|
377
|
+
* rng = createSeededRandom(42);
|
|
378
|
+
* });
|
|
379
|
+
*
|
|
380
|
+
* it('should behave consistently', () => {
|
|
381
|
+
* const value = rng.random(); // Always the same
|
|
382
|
+
* });
|
|
383
|
+
* });
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
386
|
+
function createSeededRandom(seed) {
|
|
387
|
+
return new SeededRandom(seed);
|
|
388
|
+
}
|
|
389
|
+
//# sourceMappingURL=SeededRandom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeededRandom.js","sourceRoot":"","sources":["../../src/utils/SeededRandom.ts"],"names":[],"mappings":"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"}
|