(signals, config)
| 250 | } |
| 251 | |
| 252 | function shouldReport(signals, config) { |
| 253 | if (!config) return false; |
| 254 | |
| 255 | const hasFailureLoop = signals.includes('failure_loop_detected'); |
| 256 | const hasRecurringAndHigh = signals.includes('recurring_error') && signals.includes('high_failure_ratio'); |
| 257 | |
| 258 | if (!hasFailureLoop && !hasRecurringAndHigh) return false; |
| 259 | |
| 260 | const streakCount = extractStreakCount(signals); |
| 261 | if (streakCount < config.minStreak) return false; |
| 262 | |
| 263 | const state = readState(); |
| 264 | const errorKey = computeErrorKey(signals); |
| 265 | |
| 266 | if (state.lastReportedAt) { |
| 267 | const elapsed = Date.now() - new Date(state.lastReportedAt).getTime(); |
| 268 | if (elapsed < config.cooldownMs) { |
| 269 | const recentKeys = Array.isArray(state.recentIssueKeys) ? state.recentIssueKeys : []; |
| 270 | if (recentKeys.includes(errorKey)) { |
| 271 | return false; |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | return true; |
| 277 | } |
| 278 | |
| 279 | async function createGithubIssue(repo, title, body, token) { |
| 280 | const url = 'https://api.github.com/repos/' + repo + '/issues'; |
no test coverage detected