@oneuptime/common 11.5.4 → 11.5.6
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/Models/DatabaseModels/AIAgentTaskPullRequest.ts +56 -45
- package/Models/DatabaseModels/AIInsight.ts +748 -0
- package/Models/DatabaseModels/AIRun.ts +262 -0
- package/Models/DatabaseModels/CodeRepository.ts +42 -0
- package/Models/DatabaseModels/GlobalConfig.ts +105 -0
- package/Models/DatabaseModels/Index.ts +4 -8
- package/Models/DatabaseModels/InstanceHealthLog.ts +277 -0
- package/Models/DatabaseModels/LlmLog.ts +33 -0
- package/Models/DatabaseModels/Project.ts +123 -6
- package/Models/DatabaseModels/Runbook.ts +1 -1
- package/Models/DatabaseModels/User.ts +47 -0
- package/Server/API/AIAgentDataAPI.ts +802 -140
- package/Server/API/AIAgentTaskAPI.ts +132 -69
- package/Server/API/AIAgentTaskLogAPI.ts +65 -41
- package/Server/API/AIAgentTaskPullRequestAPI.ts +41 -0
- package/Server/API/AIInsightAPI.ts +220 -0
- package/Server/API/AIInvestigationAPI.ts +363 -1
- package/Server/API/CodeFixRunAPI.ts +251 -0
- package/Server/API/GitHubAPI.ts +246 -3
- package/Server/API/TelemetryExceptionAPI.ts +193 -48
- package/Server/EnvironmentConfig.ts +1 -1
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783943300000-DropServiceCodeRepository.ts +26 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783947444597-CodeFixRunsOnAIRun.ts +73 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783950962813-AddCodeFixTaskType.ts +29 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783954040984-AddInstrumentationFixTasksFlag.ts +31 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783957160597-MigrationName.ts +51 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783958542237-AddTaskContextToAIRun.ts +25 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783965945957-AddInvestigationVerdictAndGrade.ts +47 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783970619301-AddFixGuardrailColumns.ts +53 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783970619302-DropLegacyAIAgentTaskTables.ts +31 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783977781677-AddCiStatusToFixPullRequests.ts +37 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783990000000-AddCompletionTokensToLlmLog.ts +25 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784010274993-AddSentinelInsight.ts +75 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784010274994-AddSentinelInsightFlags.ts +37 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784030612266-RenameSentinelToAI.ts +203 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784033837629-MigrationName.ts +163 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1784048917994-AddCreatedByUserToUser.ts +23 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +32 -0
- package/Server/Infrastructure/Queue.ts +82 -4
- package/Server/Infrastructure/Semaphore.ts +62 -1
- package/Server/Middleware/MasterAdminAuthorization.ts +37 -0
- package/Server/Middleware/ProjectAuthorization.ts +40 -15
- package/Server/Services/AIAgentService.ts +32 -0
- package/Server/Services/AIAgentTaskPullRequestService.ts +117 -0
- package/Server/Services/AIInsightService.ts +174 -0
- package/Server/Services/AIRunEventService.ts +63 -0
- package/Server/Services/AIRunService.ts +259 -1
- package/Server/Services/AIService.ts +249 -7
- package/Server/Services/AlertService.ts +4 -4
- package/Server/Services/CodeRepositoryService.ts +209 -0
- package/Server/Services/GlobalConfigService.ts +148 -0
- package/Server/Services/IncidentService.ts +183 -38
- package/Server/Services/IncidentStateTimelineService.ts +24 -4
- package/Server/Services/Index.ts +4 -4
- package/Server/Services/{AIAgentTaskLogService.ts → InstanceHealthLogService.ts} +1 -1
- package/Server/Services/LlmLogService.ts +27 -0
- package/Server/Services/LlmProviderService.ts +108 -0
- package/Server/Services/MetricBaselineService.ts +123 -0
- package/Server/Services/MonitorService.ts +15 -0
- package/Server/Services/TeamMemberService.ts +2 -0
- package/Server/Services/TelemetryExceptionService.ts +323 -116
- package/Server/Services/TraceAggregationService.ts +176 -0
- package/Server/Services/UserService.ts +10 -0
- package/Server/Types/Workflow/ComponentCode.ts +6 -0
- package/Server/Types/Workflow/Components/AI/GenerateText.ts +326 -0
- package/Server/Types/Workflow/Components/Index.ts +2 -0
- package/Server/Utils/AI/Chat/ObservabilityAssistant.ts +1 -1
- package/Server/Utils/AI/CodeFix/CodeAgentWorkspaceGuard.ts +71 -0
- package/Server/Utils/AI/CodeFix/CodeFixAgentCompletion.ts +243 -0
- package/Server/Utils/AI/CodeFix/CodeFixRunQueue.ts +131 -0
- package/Server/Utils/AI/CodeFix/FixRunBudget.ts +148 -0
- package/Server/Utils/AI/CodeFix/OpenPullRequestCap.ts +117 -0
- package/Server/Utils/AI/Eval/EvalCorpus.ts +369 -0
- package/Server/Utils/AI/Eval/EvalScores.ts +172 -0
- package/Server/Utils/AI/Eval/ReplayInvestigation.ts +87 -0
- package/Server/Utils/AI/PerfEvidence/SpanTreeAnalyzer.ts +676 -0
- package/Server/Utils/AI/{Sentinel/SentinelInvestigationEngine.ts → SRE/AIInvestigationEngine.ts} +58 -37
- package/Server/Utils/AI/{Sentinel/SentinelMemory.ts → SRE/AIMemory.ts} +3 -3
- package/Server/Utils/AI/{Sentinel → SRE}/AlertInvestigationRunner.ts +50 -20
- package/Server/Utils/AI/SRE/ConfidenceSignal.ts +293 -0
- package/Server/Utils/AI/SRE/FixFromIncidentTaskTrigger.ts +115 -0
- package/Server/Utils/AI/SRE/FixPerformanceTaskTrigger.ts +223 -0
- package/Server/Utils/AI/{Sentinel → SRE}/IncidentInvestigationRunner.ts +71 -21
- package/Server/Utils/AI/{Sentinel → SRE}/IncidentPostmortemRunner.ts +8 -8
- package/Server/Utils/AI/SRE/Insights/Detectors/ErrorLogSpikeDetector.ts +364 -0
- package/Server/Utils/AI/SRE/Insights/Detectors/ExceptionSpikeDetector.ts +317 -0
- package/Server/Utils/AI/SRE/Insights/Detectors/Index.ts +27 -0
- package/Server/Utils/AI/SRE/Insights/Detectors/MetricDriftDetector.ts +221 -0
- package/Server/Utils/AI/SRE/Insights/Detectors/NewExceptionDetector.ts +238 -0
- package/Server/Utils/AI/SRE/Insights/Detectors/TraceLatencyRegressionDetector.ts +521 -0
- package/Server/Utils/AI/SRE/Insights/FixRouting.ts +242 -0
- package/Server/Utils/AI/SRE/Insights/InsightScanner.ts +290 -0
- package/Server/Utils/AI/SRE/Insights/InsightStore.ts +283 -0
- package/Server/Utils/AI/SRE/Insights/InsightTriageRunner.ts +242 -0
- package/Server/Utils/AI/SRE/Insights/Triage.ts +162 -0
- package/Server/Utils/AI/SRE/Insights/Types.ts +49 -0
- package/Server/Utils/AI/SRE/InstrumentationTaskTrigger.ts +212 -0
- package/Server/Utils/AI/SRE/InvestigationGrader.ts +282 -0
- package/Server/Utils/AI/{Sentinel → SRE}/InvestigationQueue.ts +114 -19
- package/Server/Utils/AI/{Sentinel → SRE}/README.md +4 -4
- package/Server/Utils/AI/SRE/SubjectCodeFixRun.ts +172 -0
- package/Server/Utils/AI/Toolbox/{SentinelActionTools.ts → AIActionTools.ts} +22 -1
- package/Server/Utils/AI/Toolbox/Index.ts +2 -2
- package/Server/Utils/AnalyticsDatabase/ClickhouseCapacity.ts +526 -0
- package/Server/Utils/CodeRepository/GitHub/GitHub.ts +319 -1
- package/Server/Utils/CodeRepository/ServiceRepoLinkSuggester.ts +221 -0
- package/Server/Utils/CodeRepository/StackTraceRepoResolver.ts +571 -0
- package/Server/Utils/Execute.ts +2 -1
- package/Server/Utils/LLM/LLMService.ts +160 -30
- package/Server/Utils/Monitor/Criteria/SqlMonitorCriteria.ts +152 -0
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +29 -0
- package/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.ts +16 -6
- package/Server/Utils/Monitor/MonitorCriteriaMessageBuilder.ts +14 -0
- package/Server/Utils/Monitor/MonitorCriteriaMessageFormatter.ts +14 -3
- package/Server/Utils/Monitor/MonitorCriteriaObservationBuilder.ts +130 -12
- package/Tests/Server/Infrastructure/Queue.test.ts +227 -0
- package/Tests/Server/Infrastructure/SemaphorePermit.test.ts +159 -0
- package/Tests/Server/Services/AIAgentTaskPullRequestOutcomeStats.test.ts +154 -0
- package/Tests/Server/Services/AIInsightService.test.ts +324 -0
- package/Tests/Server/Services/AIRunCodeFixClaim.test.ts +401 -0
- package/Tests/Server/Services/AIRunHumanVerdict.test.ts +161 -0
- package/Tests/Server/Services/AIServiceDailyBudget.test.ts +95 -5
- package/Tests/Server/Services/AIServiceProjectAccess.test.ts +259 -0
- package/Tests/Server/Services/FixFromIncidentTaskTrigger.test.ts +249 -0
- package/Tests/Server/Services/FixPerformanceTaskTrigger.test.ts +274 -0
- package/Tests/Server/Services/GlobalConfigService.test.ts +80 -0
- package/Tests/Server/Services/IncidentInternalNoteAnnouncement.test.ts +1 -1
- package/Tests/Server/Services/InstrumentationTaskTrigger.test.ts +313 -0
- package/Tests/Server/Services/LlmProviderProjectOwned.test.ts +132 -0
- package/Tests/Server/Services/TelemetryExceptionAIFixReadiness.test.ts +405 -0
- package/Tests/Server/Services/TelemetryExceptionCodeFixRun.test.ts +322 -0
- package/Tests/Server/Services/TraceServiceLatencyProfile.test.ts +278 -0
- package/Tests/Server/Types/Workflow/Components/AIGenerateText.test.ts +722 -0
- package/Tests/Server/Utils/AI/{SentinelAlertGating.test.ts → AIAlertGating.test.ts} +19 -19
- package/Tests/Server/Utils/AI/AIConfidenceSignal.test.ts +362 -0
- package/Tests/Server/Utils/AI/{SentinelInvestigationQueue.test.ts → AIInvestigationQueue.test.ts} +19 -19
- package/Tests/Server/Utils/AI/CodeAgentWorkspaceGuard.test.ts +138 -0
- package/Tests/Server/Utils/AI/CodeFixAgentCompletion.test.ts +335 -0
- package/Tests/Server/Utils/AI/CodeFixRunQueue.test.ts +134 -0
- package/Tests/Server/Utils/AI/EvalCorpus.test.ts +209 -0
- package/Tests/Server/Utils/AI/EvalScores.test.ts +343 -0
- package/Tests/Server/Utils/AI/FixRunBudget.test.ts +218 -0
- package/Tests/Server/Utils/AI/Insights/ErrorLogSpikeDetector.test.ts +437 -0
- package/Tests/Server/Utils/AI/Insights/ExceptionSpikeDetector.test.ts +287 -0
- package/Tests/Server/Utils/AI/Insights/InsightDetectorsIndex.test.ts +34 -0
- package/Tests/Server/Utils/AI/Insights/InsightFixRouting.test.ts +572 -0
- package/Tests/Server/Utils/AI/Insights/InsightNeverThrowsHardening.test.ts +344 -0
- package/Tests/Server/Utils/AI/Insights/InsightScanner.test.ts +720 -0
- package/Tests/Server/Utils/AI/Insights/InsightStore.test.ts +467 -0
- package/Tests/Server/Utils/AI/Insights/InsightStoreHardening.test.ts +370 -0
- package/Tests/Server/Utils/AI/Insights/InsightTriage.test.ts +210 -0
- package/Tests/Server/Utils/AI/Insights/InsightTriageRunner.test.ts +221 -0
- package/Tests/Server/Utils/AI/Insights/InvestigationQueueInsightSubject.test.ts +328 -0
- package/Tests/Server/Utils/AI/Insights/MetricBaselineDrift.test.ts +182 -0
- package/Tests/Server/Utils/AI/Insights/MetricDriftDetector.test.ts +280 -0
- package/Tests/Server/Utils/AI/Insights/NewExceptionDetector.test.ts +259 -0
- package/Tests/Server/Utils/AI/Insights/TraceLatencyRegressionDetector.test.ts +770 -0
- package/Tests/Server/Utils/AI/InvestigationGrader.test.ts +343 -0
- package/Tests/Server/Utils/AI/LLMServiceRequestPolicy.test.ts +307 -0
- package/Tests/Server/Utils/AI/OpenPullRequestCap.test.ts +170 -0
- package/Tests/Server/Utils/AI/SpanTreeAnalyzer.test.ts +559 -0
- package/Tests/Server/Utils/AnalyticsDatabase/ClickhouseCapacity.test.ts +158 -0
- package/Tests/Server/Utils/GitHubCheckRunsConclusion.test.ts +100 -0
- package/Tests/Server/Utils/GitHubPullRequestStateMapping.test.ts +50 -0
- package/Tests/Server/Utils/Monitor/Criteria/SqlMonitorCriteria.test.ts +266 -0
- package/Tests/Server/Utils/Monitor/MonitorCriteriaExpectationBuilderUnits.test.ts +553 -0
- package/Tests/Server/Utils/Monitor/MonitorCriteriaMessageBuilderUnits.test.ts +590 -0
- package/Tests/Server/Utils/Monitor/MonitorCriteriaMessageFormatterUnits.test.ts +254 -0
- package/Tests/Server/Utils/Monitor/MonitorCriteriaObservationBuilderUnits.test.ts +821 -0
- package/Tests/Server/Utils/ServiceRepoLinkSuggester.test.ts +167 -0
- package/Tests/Server/Utils/StackTraceRepoResolver.test.ts +527 -0
- package/Tests/Types/AI/AIChatPermissionMode.test.ts +112 -0
- package/Tests/Types/AI/CodeFixTaskType.test.ts +152 -0
- package/Tests/Types/AI/FixPullRequestCiStatus.test.ts +181 -0
- package/Tests/Types/Monitor/MonitorStepSqlMonitor.test.ts +110 -0
- package/Tests/Types/Monitor/SqlDatabaseType.test.ts +55 -0
- package/Tests/Types/Workflow/AIGenerateTextMetadata.test.ts +180 -0
- package/Tests/UI/Components/TableBulkCsvExport.test.tsx +168 -0
- package/Tests/UI/Utils/TableColumnsToCsv.test.ts +523 -0
- package/Types/AI/AIChatTypes.ts +8 -0
- package/Types/AI/AIInsightEvidence.ts +77 -0
- package/Types/AI/AIInsightHumanVerdict.ts +15 -0
- package/Types/AI/AIInsightSeverity.ts +13 -0
- package/Types/AI/AIInsightStatus.ts +38 -0
- package/Types/AI/AIInsightType.ts +41 -0
- package/Types/AI/AIRunAutoGrade.ts +18 -0
- package/Types/AI/AIRunEventType.ts +5 -0
- package/Types/AI/AIRunHumanVerdict.ts +17 -0
- package/Types/AI/AIRunType.ts +6 -0
- package/Types/AI/CodeFixTaskContext.ts +88 -0
- package/Types/AI/CodeFixTaskType.ts +132 -0
- package/Types/AI/FixPullRequestCiStatus.ts +132 -0
- package/Types/BaseDatabase/AggregationIntervalUtil.ts +67 -0
- package/Types/Incident/IncidentMetricType.ts +7 -0
- package/Types/Monitor/CriteriaFilter.ts +8 -0
- package/Types/Monitor/MonitorCriteriaInstance.ts +67 -0
- package/Types/Monitor/MonitorStep.ts +38 -0
- package/Types/Monitor/MonitorStepSqlMonitor.ts +141 -0
- package/Types/Monitor/MonitorType.ts +17 -0
- package/Types/Monitor/SqlDatabaseType.ts +49 -0
- package/Types/Monitor/SqlMonitor/SqlMonitorResponse.ts +28 -0
- package/Types/Permission.ts +11 -95
- package/Types/Probe/ProbeMonitorResponse.ts +2 -0
- package/Types/Runbook/RunbookStep.ts +26 -2
- package/Types/Runbook/RunbookStepType.ts +1 -0
- package/Types/Workflow/Component.ts +13 -0
- package/Types/Workflow/ComponentID.ts +1 -0
- package/Types/Workflow/Components/AI.ts +148 -0
- package/Types/Workflow/Components.ts +8 -0
- package/UI/Components/AI/GenerateFromAIModal.tsx +1 -1
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +11 -0
- package/UI/Components/MoreMenu/MoreMenu.tsx +1 -1
- package/UI/Components/Table/Table.tsx +38 -2
- package/UI/Utils/TableColumnsToCsv.ts +385 -0
- package/Utils/Monitor/MonitorMetricType.ts +1 -0
- package/build/dist/Models/DatabaseModels/AIAgentTaskPullRequest.js +59 -45
- package/build/dist/Models/DatabaseModels/AIAgentTaskPullRequest.js.map +1 -1
- package/build/dist/Models/DatabaseModels/AIInsight.js +795 -0
- package/build/dist/Models/DatabaseModels/AIInsight.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AIRun.js +274 -0
- package/build/dist/Models/DatabaseModels/AIRun.js.map +1 -1
- package/build/dist/Models/DatabaseModels/CodeRepository.js +43 -0
- package/build/dist/Models/DatabaseModels/CodeRepository.js.map +1 -1
- package/build/dist/Models/DatabaseModels/GlobalConfig.js +110 -0
- package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +4 -8
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/InstanceHealthLog.js +304 -0
- package/build/dist/Models/DatabaseModels/InstanceHealthLog.js.map +1 -0
- package/build/dist/Models/DatabaseModels/LlmLog.js +35 -0
- package/build/dist/Models/DatabaseModels/LlmLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Project.js +127 -6
- package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Runbook.js +1 -1
- package/build/dist/Models/DatabaseModels/Runbook.js.map +1 -1
- package/build/dist/Models/DatabaseModels/User.js +46 -0
- package/build/dist/Models/DatabaseModels/User.js.map +1 -1
- package/build/dist/Server/API/AIAgentDataAPI.js +568 -85
- package/build/dist/Server/API/AIAgentDataAPI.js.map +1 -1
- package/build/dist/Server/API/AIAgentTaskAPI.js +100 -44
- package/build/dist/Server/API/AIAgentTaskAPI.js.map +1 -1
- package/build/dist/Server/API/AIAgentTaskLogAPI.js +49 -25
- package/build/dist/Server/API/AIAgentTaskLogAPI.js.map +1 -1
- package/build/dist/Server/API/AIAgentTaskPullRequestAPI.js +27 -0
- package/build/dist/Server/API/AIAgentTaskPullRequestAPI.js.map +1 -1
- package/build/dist/Server/API/AIInsightAPI.js +140 -0
- package/build/dist/Server/API/AIInsightAPI.js.map +1 -0
- package/build/dist/Server/API/AIInvestigationAPI.js +257 -1
- package/build/dist/Server/API/AIInvestigationAPI.js.map +1 -1
- package/build/dist/Server/API/CodeFixRunAPI.js +181 -0
- package/build/dist/Server/API/CodeFixRunAPI.js.map +1 -0
- package/build/dist/Server/API/GitHubAPI.js +164 -2
- package/build/dist/Server/API/GitHubAPI.js.map +1 -1
- package/build/dist/Server/API/TelemetryExceptionAPI.js +148 -43
- package/build/dist/Server/API/TelemetryExceptionAPI.js.map +1 -1
- package/build/dist/Server/EnvironmentConfig.js +1 -1
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783943300000-DropServiceCodeRepository.js +23 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783943300000-DropServiceCodeRepository.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783947444597-CodeFixRunsOnAIRun.js +32 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783947444597-CodeFixRunsOnAIRun.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783950962813-AddCodeFixTaskType.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783950962813-AddCodeFixTaskType.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783954040984-AddInstrumentationFixTasksFlag.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783954040984-AddInstrumentationFixTasksFlag.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783957160597-MigrationName.js +24 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783957160597-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783958542237-AddTaskContextToAIRun.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783958542237-AddTaskContextToAIRun.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783965945957-AddInvestigationVerdictAndGrade.js +24 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783965945957-AddInvestigationVerdictAndGrade.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783970619301-AddFixGuardrailColumns.js +24 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783970619301-AddFixGuardrailColumns.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783970619302-DropLegacyAIAgentTaskTables.js +24 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783970619302-DropLegacyAIAgentTaskTables.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783977781677-AddCiStatusToFixPullRequests.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783977781677-AddCiStatusToFixPullRequests.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783990000000-AddCompletionTokensToLlmLog.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783990000000-AddCompletionTokensToLlmLog.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784010274993-AddSentinelInsight.js +32 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784010274993-AddSentinelInsight.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784010274994-AddSentinelInsightFlags.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784010274994-AddSentinelInsightFlags.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784030612266-RenameSentinelToAI.js +125 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784030612266-RenameSentinelToAI.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784033837629-MigrationName.js +62 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784033837629-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784048917994-AddCreatedByUserToUser.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1784048917994-AddCreatedByUserToUser.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +32 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Infrastructure/Queue.js +73 -3
- package/build/dist/Server/Infrastructure/Queue.js.map +1 -1
- package/build/dist/Server/Infrastructure/Semaphore.js +44 -1
- package/build/dist/Server/Infrastructure/Semaphore.js.map +1 -1
- package/build/dist/Server/Middleware/MasterAdminAuthorization.js +26 -0
- package/build/dist/Server/Middleware/MasterAdminAuthorization.js.map +1 -1
- package/build/dist/Server/Middleware/ProjectAuthorization.js +40 -14
- package/build/dist/Server/Middleware/ProjectAuthorization.js.map +1 -1
- package/build/dist/Server/Services/AIAgentService.js +29 -0
- package/build/dist/Server/Services/AIAgentService.js.map +1 -1
- package/build/dist/Server/Services/AIAgentTaskPullRequestService.js +78 -0
- package/build/dist/Server/Services/AIAgentTaskPullRequestService.js.map +1 -1
- package/build/dist/Server/Services/AIInsightService.js +164 -0
- package/build/dist/Server/Services/AIInsightService.js.map +1 -0
- package/build/dist/Server/Services/AIRunEventService.js +49 -0
- package/build/dist/Server/Services/AIRunEventService.js.map +1 -1
- package/build/dist/Server/Services/AIRunService.js +221 -0
- package/build/dist/Server/Services/AIRunService.js.map +1 -1
- package/build/dist/Server/Services/AIService.js +198 -11
- package/build/dist/Server/Services/AIService.js.map +1 -1
- package/build/dist/Server/Services/AlertService.js +4 -4
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/CodeRepositoryService.js +180 -0
- package/build/dist/Server/Services/CodeRepositoryService.js.map +1 -1
- package/build/dist/Server/Services/GlobalConfigService.js +84 -0
- package/build/dist/Server/Services/GlobalConfigService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +149 -37
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/IncidentStateTimelineService.js +24 -4
- package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +4 -4
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/{AIAgentTaskLogService.js → InstanceHealthLogService.js} +2 -2
- package/build/dist/Server/Services/InstanceHealthLogService.js.map +1 -0
- package/build/dist/Server/Services/LlmLogService.js +23 -0
- package/build/dist/Server/Services/LlmLogService.js.map +1 -1
- package/build/dist/Server/Services/LlmProviderService.js +96 -0
- package/build/dist/Server/Services/LlmProviderService.js.map +1 -1
- package/build/dist/Server/Services/MetricBaselineService.js +65 -0
- package/build/dist/Server/Services/MetricBaselineService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +9 -1
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/TeamMemberService.js +2 -0
- package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
- package/build/dist/Server/Services/TelemetryExceptionService.js +243 -82
- package/build/dist/Server/Services/TelemetryExceptionService.js.map +1 -1
- package/build/dist/Server/Services/TraceAggregationService.js +124 -0
- package/build/dist/Server/Services/TraceAggregationService.js.map +1 -1
- package/build/dist/Server/Services/UserService.js +8 -0
- package/build/dist/Server/Services/UserService.js.map +1 -1
- package/build/dist/Server/Types/Workflow/ComponentCode.js.map +1 -1
- package/build/dist/Server/Types/Workflow/Components/AI/GenerateText.js +240 -0
- package/build/dist/Server/Types/Workflow/Components/AI/GenerateText.js.map +1 -0
- package/build/dist/Server/Types/Workflow/Components/Index.js +2 -0
- package/build/dist/Server/Types/Workflow/Components/Index.js.map +1 -1
- package/build/dist/Server/Utils/AI/CodeFix/CodeAgentWorkspaceGuard.js +48 -0
- package/build/dist/Server/Utils/AI/CodeFix/CodeAgentWorkspaceGuard.js.map +1 -0
- package/build/dist/Server/Utils/AI/CodeFix/CodeFixAgentCompletion.js +174 -0
- package/build/dist/Server/Utils/AI/CodeFix/CodeFixAgentCompletion.js.map +1 -0
- package/build/dist/Server/Utils/AI/CodeFix/CodeFixRunQueue.js +126 -0
- package/build/dist/Server/Utils/AI/CodeFix/CodeFixRunQueue.js.map +1 -0
- package/build/dist/Server/Utils/AI/CodeFix/FixRunBudget.js +131 -0
- package/build/dist/Server/Utils/AI/CodeFix/FixRunBudget.js.map +1 -0
- package/build/dist/Server/Utils/AI/CodeFix/OpenPullRequestCap.js +99 -0
- package/build/dist/Server/Utils/AI/CodeFix/OpenPullRequestCap.js.map +1 -0
- package/build/dist/Server/Utils/AI/Eval/EvalCorpus.js +245 -0
- package/build/dist/Server/Utils/AI/Eval/EvalCorpus.js.map +1 -0
- package/build/dist/Server/Utils/AI/Eval/EvalScores.js +83 -0
- package/build/dist/Server/Utils/AI/Eval/EvalScores.js.map +1 -0
- package/build/dist/Server/Utils/AI/Eval/ReplayInvestigation.js +12 -0
- package/build/dist/Server/Utils/AI/Eval/ReplayInvestigation.js.map +1 -0
- package/build/dist/Server/Utils/AI/PerfEvidence/SpanTreeAnalyzer.js +439 -0
- package/build/dist/Server/Utils/AI/PerfEvidence/SpanTreeAnalyzer.js.map +1 -0
- package/build/dist/Server/Utils/AI/{Sentinel/SentinelInvestigationEngine.js → SRE/AIInvestigationEngine.js} +47 -31
- package/build/dist/Server/Utils/AI/SRE/AIInvestigationEngine.js.map +1 -0
- package/build/dist/Server/Utils/AI/{Sentinel/SentinelMemory.js → SRE/AIMemory.js} +5 -5
- package/build/dist/Server/Utils/AI/SRE/AIMemory.js.map +1 -0
- package/build/dist/Server/Utils/AI/{Sentinel → SRE}/AlertInvestigationRunner.js +42 -19
- package/build/dist/Server/Utils/AI/SRE/AlertInvestigationRunner.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/ConfidenceSignal.js +226 -0
- package/build/dist/Server/Utils/AI/SRE/ConfidenceSignal.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/FixFromIncidentTaskTrigger.js +100 -0
- package/build/dist/Server/Utils/AI/SRE/FixFromIncidentTaskTrigger.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/FixPerformanceTaskTrigger.js +174 -0
- package/build/dist/Server/Utils/AI/SRE/FixPerformanceTaskTrigger.js.map +1 -0
- package/build/dist/Server/Utils/AI/{Sentinel → SRE}/IncidentInvestigationRunner.js +60 -22
- package/build/dist/Server/Utils/AI/SRE/IncidentInvestigationRunner.js.map +1 -0
- package/build/dist/Server/Utils/AI/{Sentinel → SRE}/IncidentPostmortemRunner.js +9 -9
- package/build/dist/Server/Utils/AI/SRE/IncidentPostmortemRunner.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/ErrorLogSpikeDetector.js +268 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/ErrorLogSpikeDetector.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/ExceptionSpikeDetector.js +226 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/ExceptionSpikeDetector.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/Index.js +26 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/Index.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/MetricDriftDetector.js +159 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/MetricDriftDetector.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/NewExceptionDetector.js +177 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/NewExceptionDetector.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/TraceLatencyRegressionDetector.js +384 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/TraceLatencyRegressionDetector.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/FixRouting.js +180 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/FixRouting.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/InsightScanner.js +269 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/InsightScanner.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/InsightStore.js +231 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/InsightStore.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/InsightTriageRunner.js +206 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/InsightTriageRunner.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Triage.js +121 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Triage.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Types.js +2 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Types.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/InstrumentationTaskTrigger.js +148 -0
- package/build/dist/Server/Utils/AI/SRE/InstrumentationTaskTrigger.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/InvestigationGrader.js +231 -0
- package/build/dist/Server/Utils/AI/SRE/InvestigationGrader.js.map +1 -0
- package/build/dist/Server/Utils/AI/{Sentinel → SRE}/InvestigationQueue.js +102 -23
- package/build/dist/Server/Utils/AI/SRE/InvestigationQueue.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/SubjectCodeFixRun.js +167 -0
- package/build/dist/Server/Utils/AI/SRE/SubjectCodeFixRun.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/{SentinelActionTools.js → AIActionTools.js} +18 -2
- package/build/dist/Server/Utils/AI/Toolbox/AIActionTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/Index.js +2 -2
- package/build/dist/Server/Utils/AI/Toolbox/Index.js.map +1 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/ClickhouseCapacity.js +301 -0
- package/build/dist/Server/Utils/AnalyticsDatabase/ClickhouseCapacity.js.map +1 -0
- package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js +240 -2
- package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js.map +1 -1
- package/build/dist/Server/Utils/CodeRepository/ServiceRepoLinkSuggester.js +127 -0
- package/build/dist/Server/Utils/CodeRepository/ServiceRepoLinkSuggester.js.map +1 -0
- package/build/dist/Server/Utils/CodeRepository/StackTraceRepoResolver.js +336 -0
- package/build/dist/Server/Utils/CodeRepository/StackTraceRepoResolver.js.map +1 -0
- package/build/dist/Server/Utils/Execute.js.map +1 -1
- package/build/dist/Server/Utils/LLM/LLMService.js +125 -25
- package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/SqlMonitorCriteria.js +120 -0
- package/build/dist/Server/Utils/Monitor/Criteria/SqlMonitorCriteria.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +21 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.js +15 -7
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaMessageBuilder.js +12 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaMessageBuilder.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaMessageFormatter.js +8 -3
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaMessageFormatter.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaObservationBuilder.js +96 -12
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaObservationBuilder.js.map +1 -1
- package/build/dist/Types/AI/AIInsightEvidence.js +2 -0
- package/build/dist/Types/AI/AIInsightEvidence.js.map +1 -0
- package/build/dist/Types/AI/AIInsightHumanVerdict.js +16 -0
- package/build/dist/Types/AI/AIInsightHumanVerdict.js.map +1 -0
- package/build/dist/Types/AI/AIInsightSeverity.js +14 -0
- package/build/dist/Types/AI/AIInsightSeverity.js.map +1 -0
- package/build/dist/Types/AI/AIInsightStatus.js +36 -0
- package/build/dist/Types/AI/AIInsightStatus.js.map +1 -0
- package/build/dist/Types/AI/AIInsightType.js +42 -0
- package/build/dist/Types/AI/AIInsightType.js.map +1 -0
- package/build/dist/Types/AI/AIRunAutoGrade.js +19 -0
- package/build/dist/Types/AI/AIRunAutoGrade.js.map +1 -0
- package/build/dist/Types/AI/AIRunEventType.js +5 -0
- package/build/dist/Types/AI/AIRunEventType.js.map +1 -1
- package/build/dist/Types/AI/AIRunHumanVerdict.js +18 -0
- package/build/dist/Types/AI/AIRunHumanVerdict.js.map +1 -0
- package/build/dist/Types/AI/AIRunType.js +6 -0
- package/build/dist/Types/AI/AIRunType.js.map +1 -1
- package/build/dist/Types/AI/CodeFixTaskContext.js +29 -0
- package/build/dist/Types/AI/CodeFixTaskContext.js.map +1 -0
- package/build/dist/Types/AI/CodeFixTaskType.js +122 -0
- package/build/dist/Types/AI/CodeFixTaskType.js.map +1 -0
- package/build/dist/Types/AI/FixPullRequestCiStatus.js +102 -0
- package/build/dist/Types/AI/FixPullRequestCiStatus.js.map +1 -0
- package/build/dist/Types/BaseDatabase/AggregationIntervalUtil.js +55 -0
- package/build/dist/Types/BaseDatabase/AggregationIntervalUtil.js.map +1 -1
- package/build/dist/Types/Incident/IncidentMetricType.js +7 -0
- package/build/dist/Types/Incident/IncidentMetricType.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +7 -0
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +62 -0
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js +28 -0
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepSqlMonitor.js +93 -0
- package/build/dist/Types/Monitor/MonitorStepSqlMonitor.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorType.js +15 -0
- package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
- package/build/dist/Types/Monitor/SqlDatabaseType.js +47 -0
- package/build/dist/Types/Monitor/SqlDatabaseType.js.map +1 -0
- package/build/dist/Types/Monitor/SqlMonitor/SqlMonitorResponse.js +2 -0
- package/build/dist/Types/Monitor/SqlMonitor/SqlMonitorResponse.js.map +1 -0
- package/build/dist/Types/Permission.js +10 -84
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/Runbook/RunbookStepType.js +1 -0
- package/build/dist/Types/Runbook/RunbookStepType.js.map +1 -1
- package/build/dist/Types/Workflow/ComponentID.js +1 -0
- package/build/dist/Types/Workflow/ComponentID.js.map +1 -1
- package/build/dist/Types/Workflow/Components/AI.js +135 -0
- package/build/dist/Types/Workflow/Components/AI.js.map +1 -0
- package/build/dist/Types/Workflow/Components.js +7 -0
- package/build/dist/Types/Workflow/Components.js.map +1 -1
- package/build/dist/UI/Components/AI/GenerateFromAIModal.js +1 -1
- package/build/dist/UI/Components/AI/GenerateFromAIModal.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +9 -0
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
- package/build/dist/UI/Components/MoreMenu/MoreMenu.js +1 -1
- package/build/dist/UI/Components/Table/Table.js +28 -2
- package/build/dist/UI/Components/Table/Table.js.map +1 -1
- package/build/dist/UI/Utils/TableColumnsToCsv.js +291 -0
- package/build/dist/UI/Utils/TableColumnsToCsv.js.map +1 -0
- package/build/dist/Utils/Monitor/MonitorMetricType.js +1 -0
- package/build/dist/Utils/Monitor/MonitorMetricType.js.map +1 -1
- package/package.json +1 -1
- package/Models/DatabaseModels/AIAgentTask.ts +0 -660
- package/Models/DatabaseModels/AIAgentTaskLog.ts +0 -426
- package/Models/DatabaseModels/AIAgentTaskTelemetryException.ts +0 -399
- package/Models/DatabaseModels/ServiceCodeRepository.ts +0 -647
- package/Server/Services/AIAgentTaskService.ts +0 -240
- package/Server/Services/AIAgentTaskTelemetryExceptionService.ts +0 -39
- package/Server/Services/ServiceCodeRepositoryService.ts +0 -55
- package/Tests/Server/Services/AIAgentTaskServiceClaim.test.ts +0 -146
- package/Types/AI/AIAgentTaskMetadata.ts +0 -25
- package/Types/AI/AIAgentTaskType.ts +0 -40
- package/build/dist/Models/DatabaseModels/AIAgentTask.js +0 -691
- package/build/dist/Models/DatabaseModels/AIAgentTask.js.map +0 -1
- package/build/dist/Models/DatabaseModels/AIAgentTaskLog.js +0 -447
- package/build/dist/Models/DatabaseModels/AIAgentTaskLog.js.map +0 -1
- package/build/dist/Models/DatabaseModels/AIAgentTaskTelemetryException.js +0 -415
- package/build/dist/Models/DatabaseModels/AIAgentTaskTelemetryException.js.map +0 -1
- package/build/dist/Models/DatabaseModels/ServiceCodeRepository.js +0 -665
- package/build/dist/Models/DatabaseModels/ServiceCodeRepository.js.map +0 -1
- package/build/dist/Server/Services/AIAgentTaskLogService.js.map +0 -1
- package/build/dist/Server/Services/AIAgentTaskService.js +0 -217
- package/build/dist/Server/Services/AIAgentTaskService.js.map +0 -1
- package/build/dist/Server/Services/AIAgentTaskTelemetryExceptionService.js +0 -36
- package/build/dist/Server/Services/AIAgentTaskTelemetryExceptionService.js.map +0 -1
- package/build/dist/Server/Services/ServiceCodeRepositoryService.js +0 -54
- package/build/dist/Server/Services/ServiceCodeRepositoryService.js.map +0 -1
- package/build/dist/Server/Utils/AI/Sentinel/AlertInvestigationRunner.js.map +0 -1
- package/build/dist/Server/Utils/AI/Sentinel/IncidentInvestigationRunner.js.map +0 -1
- package/build/dist/Server/Utils/AI/Sentinel/IncidentPostmortemRunner.js.map +0 -1
- package/build/dist/Server/Utils/AI/Sentinel/InvestigationQueue.js.map +0 -1
- package/build/dist/Server/Utils/AI/Sentinel/SentinelInvestigationEngine.js.map +0 -1
- package/build/dist/Server/Utils/AI/Sentinel/SentinelMemory.js.map +0 -1
- package/build/dist/Server/Utils/AI/Toolbox/SentinelActionTools.js.map +0 -1
- package/build/dist/Types/AI/AIAgentTaskMetadata.js +0 -6
- package/build/dist/Types/AI/AIAgentTaskMetadata.js.map +0 -1
- package/build/dist/Types/AI/AIAgentTaskType.js +0 -29
- package/build/dist/Types/AI/AIAgentTaskType.js.map +0 -1
|
@@ -217,6 +217,23 @@ export default class Queue {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Removes a one-off job by id, and also removes a repeatable whose repeat
|
|
222
|
+
* KEY equals `jobId` (QueueWorkflow persists `job.repeatJobKey` on the
|
|
223
|
+
* Workflow row and passes it back here).
|
|
224
|
+
*
|
|
225
|
+
* Note the asymmetry between the two removals, which is easy to get wrong:
|
|
226
|
+
* BullMQ rejects custom job ids containing ":", so the job lookup must use
|
|
227
|
+
* the sanitized id. But removeRepeatableByKey() expects the repeat KEY
|
|
228
|
+
* exactly as it appears in the `bull:<queue>:repeat` zset (an md5 hash, or a
|
|
229
|
+
* legacy "name:id:endDate:tz:pattern" string) — it ZREMs that exact member.
|
|
230
|
+
* Sanitizing would mangle the legacy colon form into a member that does not
|
|
231
|
+
* exist, and the removal would silently no-op. So the raw value is passed
|
|
232
|
+
* through.
|
|
233
|
+
*
|
|
234
|
+
* To remove a repeatable by its job NAME (e.g. to retire a renamed cron),
|
|
235
|
+
* use removeRepeatableByName() — passing a job name here does nothing.
|
|
236
|
+
*/
|
|
220
237
|
@CaptureSpan()
|
|
221
238
|
public static async removeJob(
|
|
222
239
|
queueName: QueueName,
|
|
@@ -226,17 +243,78 @@ export default class Queue {
|
|
|
226
243
|
return;
|
|
227
244
|
}
|
|
228
245
|
|
|
246
|
+
const queue: BullQueue = this.getQueue(queueName);
|
|
247
|
+
|
|
229
248
|
const sanitizedJobId: string = this.sanitizeJobId(jobId.toString());
|
|
230
249
|
|
|
231
|
-
const job: Job | undefined =
|
|
232
|
-
await this.getQueue(queueName).getJob(sanitizedJobId);
|
|
250
|
+
const job: Job | undefined = await queue.getJob(sanitizedJobId);
|
|
233
251
|
|
|
234
252
|
if (job) {
|
|
235
253
|
await job.remove();
|
|
236
254
|
}
|
|
237
255
|
|
|
238
|
-
|
|
239
|
-
|
|
256
|
+
/*
|
|
257
|
+
* Remove an existing repeatable keyed by this value. Raw, not sanitized —
|
|
258
|
+
* see the note above.
|
|
259
|
+
*/
|
|
260
|
+
await queue.removeRepeatableByKey(jobId.toString());
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Removes every repeatable job DEFINITION on `queueName` whose job NAME is
|
|
265
|
+
* `jobName`, and returns how many were removed. Idempotent: removing a name
|
|
266
|
+
* that isn't registered is a no-op that returns 0.
|
|
267
|
+
*
|
|
268
|
+
* Why this cannot be done with removeJob(): BullMQ keys a repeatable by an
|
|
269
|
+
* opaque `key` (the member of the `bull:<queue>:repeat` zset — an md5 hash),
|
|
270
|
+
* never by the job's name. removeRepeatableByKey() ZREMs that exact member,
|
|
271
|
+
* so handing it a job name (or a job id) matches nothing and silently
|
|
272
|
+
* succeeds as a no-op. BullMQ's own docs say so:
|
|
273
|
+
*
|
|
274
|
+
* "Removes a repeatable job by its key. Note that the key is the one used
|
|
275
|
+
* to store the repeatable job metadata and not one of the job iterations
|
|
276
|
+
* themselves. You can use "getRepeatableJobs" in order to get the keys."
|
|
277
|
+
*
|
|
278
|
+
* So the only supported name -> key path is to enumerate getRepeatableJobs()
|
|
279
|
+
* and match on `.name`. Removing by key also deletes the already-materialized
|
|
280
|
+
* next delayed iteration, so the job stops firing immediately.
|
|
281
|
+
*
|
|
282
|
+
* This exists to retire a RENAMED cron: RunCron registers a repeatable keyed
|
|
283
|
+
* by the new name, and addJob() above only clears a pre-existing repeatable
|
|
284
|
+
* that matches the NEW name — nothing clears the old one, so a renamed cron
|
|
285
|
+
* leaves its old definition behind in Redis, firing forever.
|
|
286
|
+
*/
|
|
287
|
+
@CaptureSpan()
|
|
288
|
+
public static async removeRepeatableByName(
|
|
289
|
+
queueName: QueueName,
|
|
290
|
+
jobName: string,
|
|
291
|
+
): Promise<number> {
|
|
292
|
+
if (!jobName) {
|
|
293
|
+
return 0;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const queue: BullQueue = this.getQueue(queueName);
|
|
297
|
+
|
|
298
|
+
const repeatableJobs: RepeatableJob[] = await queue.getRepeatableJobs();
|
|
299
|
+
|
|
300
|
+
let removedCount: number = 0;
|
|
301
|
+
|
|
302
|
+
for (const repeatableJob of repeatableJobs) {
|
|
303
|
+
if (repeatableJob.name !== jobName) {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// `.key` is the zset member BullMQ expects here — never the name or id.
|
|
308
|
+
const isRemoved: boolean = await queue.removeRepeatableByKey(
|
|
309
|
+
repeatableJob.key,
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
if (isRemoved) {
|
|
313
|
+
removedCount++;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return removedCount;
|
|
240
318
|
}
|
|
241
319
|
|
|
242
320
|
@CaptureSpan()
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import Redis, { ClientType } from "./Redis";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Mutex,
|
|
4
|
+
LockOptions,
|
|
5
|
+
Semaphore as RedisSemaphore,
|
|
6
|
+
} from "redis-semaphore";
|
|
3
7
|
import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
|
|
4
8
|
|
|
5
9
|
export type SemaphoreMutex = Mutex;
|
|
10
|
+
export type SemaphorePermit = RedisSemaphore;
|
|
6
11
|
|
|
7
12
|
export default class Semaphore {
|
|
8
13
|
// returns the mutex id
|
|
@@ -60,4 +65,60 @@ export default class Semaphore {
|
|
|
60
65
|
public static async release(mutex: SemaphoreMutex): Promise<void> {
|
|
61
66
|
await mutex.release();
|
|
62
67
|
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Acquire one permit from a distributed, fixed-size concurrency pool.
|
|
71
|
+
* Unlike lock(), up to `limit` callers may hold the key simultaneously.
|
|
72
|
+
*/
|
|
73
|
+
@CaptureSpan()
|
|
74
|
+
public static async acquirePermit(data: {
|
|
75
|
+
key: string;
|
|
76
|
+
namespace: string;
|
|
77
|
+
limit: number;
|
|
78
|
+
lockTimeout?: number | undefined;
|
|
79
|
+
acquireTimeout?: number | undefined;
|
|
80
|
+
acquireAttemptsLimit?: number | undefined;
|
|
81
|
+
retryInterval?: number | undefined;
|
|
82
|
+
}): Promise<SemaphorePermit> {
|
|
83
|
+
if (!Number.isInteger(data.limit) || data.limit <= 0) {
|
|
84
|
+
throw new Error("Semaphore permit limit must be a positive integer");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const client: ClientType | null = Redis.getClient();
|
|
88
|
+
|
|
89
|
+
if (!client) {
|
|
90
|
+
throw new Error("Redis client is not connected");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const lockOptions: LockOptions = {
|
|
94
|
+
lockTimeout: data.lockTimeout || 5000,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
if (data.acquireTimeout !== undefined) {
|
|
98
|
+
lockOptions.acquireTimeout = data.acquireTimeout;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (data.acquireAttemptsLimit !== undefined) {
|
|
102
|
+
lockOptions.acquireAttemptsLimit = data.acquireAttemptsLimit;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (data.retryInterval !== undefined) {
|
|
106
|
+
lockOptions.retryInterval = data.retryInterval;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const permit: SemaphorePermit = new RedisSemaphore(
|
|
110
|
+
client,
|
|
111
|
+
`${data.namespace}-${data.key}`,
|
|
112
|
+
data.limit,
|
|
113
|
+
lockOptions,
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
await permit.acquire();
|
|
117
|
+
return permit;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@CaptureSpan()
|
|
121
|
+
public static async releasePermit(permit: SemaphorePermit): Promise<void> {
|
|
122
|
+
await permit.release();
|
|
123
|
+
}
|
|
63
124
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import UserMiddleware from "./UserAuthorization";
|
|
2
|
+
import ProjectMiddleware from "./ProjectAuthorization";
|
|
2
3
|
import JSONWebToken from "../Utils/JsonWebToken";
|
|
3
4
|
import Response from "../Utils/Response";
|
|
4
5
|
import {
|
|
@@ -8,6 +9,7 @@ import {
|
|
|
8
9
|
} from "../Utils/Express";
|
|
9
10
|
import NotAuthorizedException from "../../Types/Exception/NotAuthorizedException";
|
|
10
11
|
import JSONWebTokenData from "../../Types/JsonWebTokenData";
|
|
12
|
+
import ObjectID from "../../Types/ObjectID";
|
|
11
13
|
|
|
12
14
|
export default class MasterAdminAuthorization {
|
|
13
15
|
public static async isAuthorizedMasterAdminMiddleware(
|
|
@@ -52,4 +54,39 @@ export default class MasterAdminAuthorization {
|
|
|
52
54
|
);
|
|
53
55
|
}
|
|
54
56
|
}
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* Same as isAuthorizedMasterAdminMiddleware, but ALSO accepts the instance-wide
|
|
60
|
+
* master API key (Admin Dashboard → Settings → API Key) supplied in the
|
|
61
|
+
* `apikey` header. The master key has root/master-admin access, so this lets
|
|
62
|
+
* automated callers reach the master-admin instance-health endpoints with the
|
|
63
|
+
* key instead of a logged-in master-admin session.
|
|
64
|
+
*
|
|
65
|
+
* Deliberately scoped to the read-only health / diagnostics routes only. It is
|
|
66
|
+
* NOT used on higher-risk master-admin actions (e.g. the read/write query
|
|
67
|
+
* console or broadcast email), which stay on the JWT-only middleware above so
|
|
68
|
+
* that a leaked static key cannot trigger them headlessly.
|
|
69
|
+
*/
|
|
70
|
+
public static async isAuthorizedMasterAdminOrMasterApiKeyMiddleware(
|
|
71
|
+
req: ExpressRequest,
|
|
72
|
+
res: ExpressResponse,
|
|
73
|
+
next: NextFunction,
|
|
74
|
+
): Promise<void> {
|
|
75
|
+
try {
|
|
76
|
+
const apiKey: ObjectID | null = ProjectMiddleware.getApiKey(req);
|
|
77
|
+
|
|
78
|
+
if (apiKey && (await ProjectMiddleware.isMasterApiKey(apiKey))) {
|
|
79
|
+
next();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
} catch {
|
|
83
|
+
// Fall through to the master-admin session (JWT) check below.
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return MasterAdminAuthorization.isAuthorizedMasterAdminMiddleware(
|
|
87
|
+
req,
|
|
88
|
+
res,
|
|
89
|
+
next,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
55
92
|
}
|
|
@@ -60,6 +60,43 @@ export default class ProjectMiddleware {
|
|
|
60
60
|
return Boolean(this.getProjectId(req));
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/*
|
|
64
|
+
* Whether the given key is the instance-wide master API key
|
|
65
|
+
* (Admin Dashboard → Settings → API Key) and that key is currently enabled.
|
|
66
|
+
* The master key has root/master-admin access, so this is shared with
|
|
67
|
+
* MasterAdminAuthorization to let the key reach master-admin-only endpoints
|
|
68
|
+
* (e.g. instance health) as well.
|
|
69
|
+
*/
|
|
70
|
+
@CaptureSpan()
|
|
71
|
+
public static async isMasterApiKey(apiKey: ObjectID): Promise<boolean> {
|
|
72
|
+
/*
|
|
73
|
+
* masterApiKey is a Postgres `uuid` column, so a non-UUID header value would
|
|
74
|
+
* make the lookup raise an "invalid input syntax for type uuid" error on
|
|
75
|
+
* every request. Reject it cleanly up front — a malformed key is never the
|
|
76
|
+
* master key anyway — so callers can safely fall through to other auth.
|
|
77
|
+
*/
|
|
78
|
+
if (!ObjectID.isValidUUID(apiKey.toString())) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const masterKeyGlobalConfig: GlobalConfig | null =
|
|
83
|
+
await GlobalConfigService.findOneBy({
|
|
84
|
+
query: {
|
|
85
|
+
_id: ObjectID.getZeroObjectID().toString(),
|
|
86
|
+
isMasterApiKeyEnabled: true,
|
|
87
|
+
masterApiKey: apiKey,
|
|
88
|
+
},
|
|
89
|
+
props: {
|
|
90
|
+
isRoot: true,
|
|
91
|
+
},
|
|
92
|
+
select: {
|
|
93
|
+
_id: true,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return Boolean(masterKeyGlobalConfig);
|
|
98
|
+
}
|
|
99
|
+
|
|
63
100
|
@CaptureSpan()
|
|
64
101
|
public static async isValidProjectIdAndApiKeyMiddleware(
|
|
65
102
|
req: ExpressRequest,
|
|
@@ -124,22 +161,10 @@ export default class ProjectMiddleware {
|
|
|
124
161
|
|
|
125
162
|
if (!apiKeyRow) {
|
|
126
163
|
// check master key.
|
|
127
|
-
const
|
|
128
|
-
await
|
|
129
|
-
query: {
|
|
130
|
-
_id: ObjectID.getZeroObjectID().toString(),
|
|
131
|
-
isMasterApiKeyEnabled: true,
|
|
132
|
-
masterApiKey: apiKey,
|
|
133
|
-
},
|
|
134
|
-
props: {
|
|
135
|
-
isRoot: true,
|
|
136
|
-
},
|
|
137
|
-
select: {
|
|
138
|
-
_id: true,
|
|
139
|
-
},
|
|
140
|
-
});
|
|
164
|
+
const isMasterApiKey: boolean =
|
|
165
|
+
await ProjectMiddleware.isMasterApiKey(apiKey);
|
|
141
166
|
|
|
142
|
-
if (
|
|
167
|
+
if (isMasterApiKey) {
|
|
143
168
|
(req as OneUptimeRequest).userType = UserType.MasterAdmin;
|
|
144
169
|
|
|
145
170
|
// get master admin user
|
|
@@ -571,6 +571,38 @@ export class Service extends DatabaseService<Model> {
|
|
|
571
571
|
|
|
572
572
|
return null;
|
|
573
573
|
}
|
|
574
|
+
|
|
575
|
+
/*
|
|
576
|
+
* Like getAIAgentForProject, but only returns an agent that is actually
|
|
577
|
+
* alive (recent heartbeat or Connected status). Used by readiness checks
|
|
578
|
+
* and the stuck-task sweeper so a task is never created — or left queued
|
|
579
|
+
* forever — for a fleet that isn't running.
|
|
580
|
+
*/
|
|
581
|
+
@CaptureSpan()
|
|
582
|
+
public async getConnectedAIAgentForProject(
|
|
583
|
+
projectId: ObjectID,
|
|
584
|
+
): Promise<Model | null> {
|
|
585
|
+
const agent: Model | null = await this.getAIAgentForProject(projectId);
|
|
586
|
+
|
|
587
|
+
if (!agent) {
|
|
588
|
+
return null;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return this.isAgentAlive(agent) ? agent : null;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
public isAgentAlive(agent: Model): boolean {
|
|
595
|
+
if (agent.connectionStatus === AIAgentConnectionStatus.Connected) {
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
if (!agent.lastAlive) {
|
|
600
|
+
return false;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const fiveMinutesAgo: Date = OneUptimeDate.getSomeMinutesAgo(5);
|
|
604
|
+
return OneUptimeDate.isAfter(agent.lastAlive, fiveMinutesAgo);
|
|
605
|
+
}
|
|
574
606
|
}
|
|
575
607
|
|
|
576
608
|
export default new Service();
|
|
@@ -1,10 +1,127 @@
|
|
|
1
1
|
import DatabaseService from "./DatabaseService";
|
|
2
2
|
import Model from "../../Models/DatabaseModels/AIAgentTaskPullRequest";
|
|
3
|
+
import BadDataException from "../../Types/Exception/BadDataException";
|
|
4
|
+
import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
|
|
5
|
+
import PullRequestState from "../../Types/CodeRepository/PullRequestState";
|
|
6
|
+
import FixPullRequestCiStatus from "../../Types/AI/FixPullRequestCiStatus";
|
|
7
|
+
import PositiveNumber from "../../Types/PositiveNumber";
|
|
8
|
+
import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
|
|
9
|
+
|
|
10
|
+
export interface AIFixOutcomeStats {
|
|
11
|
+
total: number;
|
|
12
|
+
open: number;
|
|
13
|
+
merged: number;
|
|
14
|
+
closedUnmerged: number;
|
|
15
|
+
/*
|
|
16
|
+
* merged / (merged + closedUnmerged), in whole percent. Null until at
|
|
17
|
+
* least one PR reached a terminal state — a rate over zero outcomes is
|
|
18
|
+
* noise, not signal.
|
|
19
|
+
*/
|
|
20
|
+
acceptanceRatePercent: number | null;
|
|
21
|
+
/*
|
|
22
|
+
* Merged PRs whose last recorded ciStatus was Green or (for should-fail
|
|
23
|
+
* regression-test PRs) ExpectedFailureObserved — merged is good,
|
|
24
|
+
* merged-and-CI-green is better. Per gate G9, ONLY those two conclusions
|
|
25
|
+
* count: a merged PR with no CI (NoCiConfigured), a never-polled null,
|
|
26
|
+
* Pending or Red is NOT verified and drags the rate down honestly.
|
|
27
|
+
*/
|
|
28
|
+
verifiedGreen: number;
|
|
29
|
+
/*
|
|
30
|
+
* verifiedGreen / merged, in whole percent. Null until at least one PR
|
|
31
|
+
* merged — same honesty rule as acceptanceRatePercent.
|
|
32
|
+
*/
|
|
33
|
+
verifiedGreenRatePercent: number | null;
|
|
34
|
+
}
|
|
3
35
|
|
|
4
36
|
export class Service extends DatabaseService<Model> {
|
|
5
37
|
public constructor() {
|
|
6
38
|
super(Model);
|
|
7
39
|
}
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* Outcome counts for the project's AI-authored fix PRs — the G11
|
|
43
|
+
* precision baseline (states kept current by AIAgent:SyncPullRequestStates).
|
|
44
|
+
* Queries run with the caller's props so tenant scoping and read
|
|
45
|
+
* permissions come from the model ACLs.
|
|
46
|
+
*/
|
|
47
|
+
@CaptureSpan()
|
|
48
|
+
public async getOutcomeStats(
|
|
49
|
+
props: DatabaseCommonInteractionProps,
|
|
50
|
+
): Promise<AIFixOutcomeStats> {
|
|
51
|
+
if (!props.tenantId) {
|
|
52
|
+
throw new BadDataException("Project ID is required");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const countForState: (
|
|
56
|
+
state: PullRequestState,
|
|
57
|
+
) => Promise<PositiveNumber> = (
|
|
58
|
+
state: PullRequestState,
|
|
59
|
+
): Promise<PositiveNumber> => {
|
|
60
|
+
return this.countBy({
|
|
61
|
+
query: {
|
|
62
|
+
projectId: props.tenantId!,
|
|
63
|
+
pullRequestState: state,
|
|
64
|
+
},
|
|
65
|
+
props,
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* CI-verified merged PRs (B4 Tier 1). Only Green and
|
|
71
|
+
* ExpectedFailureObserved count as verified — never NoCiConfigured,
|
|
72
|
+
* null, Pending or Red (G9: absence of CI reads as unverified).
|
|
73
|
+
*/
|
|
74
|
+
const countMergedWithCiStatus: (
|
|
75
|
+
ciStatus: FixPullRequestCiStatus,
|
|
76
|
+
) => Promise<PositiveNumber> = (
|
|
77
|
+
ciStatus: FixPullRequestCiStatus,
|
|
78
|
+
): Promise<PositiveNumber> => {
|
|
79
|
+
return this.countBy({
|
|
80
|
+
query: {
|
|
81
|
+
projectId: props.tenantId!,
|
|
82
|
+
pullRequestState: PullRequestState.Merged,
|
|
83
|
+
ciStatus: ciStatus,
|
|
84
|
+
},
|
|
85
|
+
props,
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const [open, merged, closedUnmerged, mergedCiGreen, mergedCiExpectedFail]: [
|
|
90
|
+
PositiveNumber,
|
|
91
|
+
PositiveNumber,
|
|
92
|
+
PositiveNumber,
|
|
93
|
+
PositiveNumber,
|
|
94
|
+
PositiveNumber,
|
|
95
|
+
] = await Promise.all([
|
|
96
|
+
countForState(PullRequestState.Open),
|
|
97
|
+
countForState(PullRequestState.Merged),
|
|
98
|
+
countForState(PullRequestState.Closed),
|
|
99
|
+
countMergedWithCiStatus(FixPullRequestCiStatus.Green),
|
|
100
|
+
countMergedWithCiStatus(FixPullRequestCiStatus.ExpectedFailureObserved),
|
|
101
|
+
]);
|
|
102
|
+
|
|
103
|
+
const mergedCount: number = merged.toNumber();
|
|
104
|
+
const closedCount: number = closedUnmerged.toNumber();
|
|
105
|
+
const terminalCount: number = mergedCount + closedCount;
|
|
106
|
+
const verifiedGreenCount: number =
|
|
107
|
+
mergedCiGreen.toNumber() + mergedCiExpectedFail.toNumber();
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
total: open.toNumber() + terminalCount,
|
|
111
|
+
open: open.toNumber(),
|
|
112
|
+
merged: mergedCount,
|
|
113
|
+
closedUnmerged: closedCount,
|
|
114
|
+
acceptanceRatePercent:
|
|
115
|
+
terminalCount === 0
|
|
116
|
+
? null
|
|
117
|
+
: Math.round((mergedCount / terminalCount) * 100),
|
|
118
|
+
verifiedGreen: verifiedGreenCount,
|
|
119
|
+
verifiedGreenRatePercent:
|
|
120
|
+
mergedCount === 0
|
|
121
|
+
? null
|
|
122
|
+
: Math.round((verifiedGreenCount / mergedCount) * 100),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
8
125
|
}
|
|
9
126
|
|
|
10
127
|
export default new Service();
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import DatabaseService from "./DatabaseService";
|
|
2
|
+
import AIRunService from "./AIRunService";
|
|
3
|
+
import AIRunEventService from "./AIRunEventService";
|
|
4
|
+
import AIInsight from "../../Models/DatabaseModels/AIInsight";
|
|
5
|
+
import AIRun from "../../Models/DatabaseModels/AIRun";
|
|
6
|
+
import AIRunEvent from "../../Models/DatabaseModels/AIRunEvent";
|
|
7
|
+
import ObjectID from "../../Types/ObjectID";
|
|
8
|
+
import OneUptimeDate from "../../Types/Date";
|
|
9
|
+
import SortOrder from "../../Types/BaseDatabase/SortOrder";
|
|
10
|
+
import BadDataException from "../../Types/Exception/BadDataException";
|
|
11
|
+
import AIInsightStatus from "../../Types/AI/AIInsightStatus";
|
|
12
|
+
import AIInsightHumanVerdict from "../../Types/AI/AIInsightHumanVerdict";
|
|
13
|
+
import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* Upper bound on triage-run events returned for one insight — mirrors the
|
|
17
|
+
* investigation panel's cap (AIInvestigationAPI MAX_EVENTS). The engine's
|
|
18
|
+
* per-run step budgets keep real trails far below this; the cap only
|
|
19
|
+
* bounds pathological rows.
|
|
20
|
+
*/
|
|
21
|
+
export const MAX_TRIAGE_RUN_EVENTS: number = 500;
|
|
22
|
+
|
|
23
|
+
export class Service extends DatabaseService<AIInsight> {
|
|
24
|
+
public constructor() {
|
|
25
|
+
super(AIInsight);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Human verdict capture — this IS the G11 precision measurement:
|
|
30
|
+
* confirm/dismiss rates per insight type tell us how precise each
|
|
31
|
+
* deterministic detector is in the field and gate any future automation.
|
|
32
|
+
*
|
|
33
|
+
* Overwriting an existing verdict is deliberate — people change their
|
|
34
|
+
* minds; the latest verdict wins (per-insight state, not an audit trail).
|
|
35
|
+
* Dismissed is a human terminal state, so it also closes the insight;
|
|
36
|
+
* Confirmed leaves the status untouched (the insight stays open until a
|
|
37
|
+
* human resolves it or a fix lands).
|
|
38
|
+
*
|
|
39
|
+
* Callers must have already access-checked the insight under the USER's
|
|
40
|
+
* permissions — insight rows are server-authored (empty update ACL), so
|
|
41
|
+
* this writes as root.
|
|
42
|
+
*/
|
|
43
|
+
@CaptureSpan()
|
|
44
|
+
public async applyHumanVerdict(data: {
|
|
45
|
+
insightId: ObjectID;
|
|
46
|
+
verdict: AIInsightHumanVerdict;
|
|
47
|
+
byUserId: ObjectID;
|
|
48
|
+
}): Promise<{ insightId: ObjectID; verdict: AIInsightHumanVerdict }> {
|
|
49
|
+
await this.updateOneById({
|
|
50
|
+
id: data.insightId,
|
|
51
|
+
data: {
|
|
52
|
+
humanVerdict: data.verdict,
|
|
53
|
+
humanVerdictAt: OneUptimeDate.getCurrentDate(),
|
|
54
|
+
humanVerdictByUserId: data.byUserId,
|
|
55
|
+
...(data.verdict === AIInsightHumanVerdict.Dismissed
|
|
56
|
+
? { status: AIInsightStatus.Dismissed }
|
|
57
|
+
: {}),
|
|
58
|
+
},
|
|
59
|
+
props: { isRoot: true },
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return { insightId: data.insightId, verdict: data.verdict };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* Marks the insight handled. Resolving implies the finding was real, so
|
|
67
|
+
* when no verdict was recorded yet this also stamps Confirmed (+ at/by) —
|
|
68
|
+
* the G11 measurement should count a silently-fixed insight as a true
|
|
69
|
+
* positive. An existing verdict (either value) is left untouched:
|
|
70
|
+
* resolve is a lifecycle action, not a verdict change.
|
|
71
|
+
*
|
|
72
|
+
* Callers must have already access-checked the insight under the USER's
|
|
73
|
+
* permissions — this reads and writes as root.
|
|
74
|
+
*/
|
|
75
|
+
@CaptureSpan()
|
|
76
|
+
public async resolveInsight(data: {
|
|
77
|
+
insightId: ObjectID;
|
|
78
|
+
byUserId: ObjectID;
|
|
79
|
+
}): Promise<{ insightId: ObjectID; status: AIInsightStatus }> {
|
|
80
|
+
const insight: AIInsight | null = await this.findOneById({
|
|
81
|
+
id: data.insightId,
|
|
82
|
+
select: { _id: true, humanVerdict: true },
|
|
83
|
+
props: { isRoot: true },
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (!insight || !insight.id) {
|
|
87
|
+
throw new BadDataException("AI insight not found.");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
await this.updateOneById({
|
|
91
|
+
id: insight.id,
|
|
92
|
+
data: {
|
|
93
|
+
status: AIInsightStatus.Resolved,
|
|
94
|
+
...(insight.humanVerdict
|
|
95
|
+
? {}
|
|
96
|
+
: {
|
|
97
|
+
humanVerdict: AIInsightHumanVerdict.Confirmed,
|
|
98
|
+
humanVerdictAt: OneUptimeDate.getCurrentDate(),
|
|
99
|
+
humanVerdictByUserId: data.byUserId,
|
|
100
|
+
}),
|
|
101
|
+
},
|
|
102
|
+
props: { isRoot: true },
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return { insightId: insight.id, status: AIInsightStatus.Resolved };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/*
|
|
109
|
+
* Data for the dashboard's live triage panel: the insight's triage AIRun
|
|
110
|
+
* plus its ordered event trail. Triage runs are system-authored
|
|
111
|
+
* (userId = null) and therefore hidden by the per-user privacy pin on the
|
|
112
|
+
* generic AIRun / AIRunEvent CRUD — so, mirroring AIInvestigationAPI's
|
|
113
|
+
* sendLatestInvestigation, the run and events are read as root AFTER the
|
|
114
|
+
* caller has access-checked the insight under the USER's permissions.
|
|
115
|
+
*
|
|
116
|
+
* A missing insight (raced deletion) or an insight without a triage run
|
|
117
|
+
* (no LLM provider / no budget headroom at scan time) returns the empty
|
|
118
|
+
* shape — the panel renders an empty state, not an error.
|
|
119
|
+
*/
|
|
120
|
+
@CaptureSpan()
|
|
121
|
+
public async getLatestTriageRunWithEvents(data: {
|
|
122
|
+
insightId: ObjectID;
|
|
123
|
+
}): Promise<{ run: AIRun | null; events: Array<AIRunEvent> }> {
|
|
124
|
+
const insight: AIInsight | null = await this.findOneById({
|
|
125
|
+
id: data.insightId,
|
|
126
|
+
select: { _id: true, triageAiRunId: true },
|
|
127
|
+
props: { isRoot: true },
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
if (!insight || !insight.triageAiRunId) {
|
|
131
|
+
return { run: null, events: [] };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const run: AIRun | null = await AIRunService.findOneById({
|
|
135
|
+
id: insight.triageAiRunId,
|
|
136
|
+
select: {
|
|
137
|
+
_id: true,
|
|
138
|
+
status: true,
|
|
139
|
+
startedAt: true,
|
|
140
|
+
completedAt: true,
|
|
141
|
+
errorMessage: true,
|
|
142
|
+
llmCallCount: true,
|
|
143
|
+
toolCallCount: true,
|
|
144
|
+
totalTokens: true,
|
|
145
|
+
createdAt: true,
|
|
146
|
+
},
|
|
147
|
+
props: { isRoot: true },
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
if (!run || !run.id) {
|
|
151
|
+
return { run: null, events: [] };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const events: Array<AIRunEvent> = await AIRunEventService.findBy({
|
|
155
|
+
query: { aiRunId: run.id },
|
|
156
|
+
select: {
|
|
157
|
+
_id: true,
|
|
158
|
+
sequence: true,
|
|
159
|
+
eventType: true,
|
|
160
|
+
toolName: true,
|
|
161
|
+
resultSummary: true,
|
|
162
|
+
createdAt: true,
|
|
163
|
+
},
|
|
164
|
+
sort: { sequence: SortOrder.Ascending },
|
|
165
|
+
limit: MAX_TRIAGE_RUN_EVENTS,
|
|
166
|
+
skip: 0,
|
|
167
|
+
props: { isRoot: true },
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
return { run, events };
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export default new Service();
|