( runs: AutonomyRunRecord[], )
| 138 | } |
| 139 | |
| 140 | function selectPersistedAutonomyRuns( |
| 141 | runs: AutonomyRunRecord[], |
| 142 | ): AutonomyRunRecord[] { |
| 143 | const cloned = runs.map(cloneRunRecord) |
| 144 | const activeCount = cloned.filter(isAutonomyRunActive).length |
| 145 | if ( |
| 146 | !warnedActiveRunsThresholdCrossed && |
| 147 | activeCount >= AUTONOMY_ACTIVE_RUNS_WARN_THRESHOLD |
| 148 | ) { |
| 149 | warnedActiveRunsThresholdCrossed = true |
| 150 | logError( |
| 151 | new Error( |
| 152 | `autonomy: ${activeCount} active runs exceed warn threshold ${AUTONOMY_ACTIVE_RUNS_WARN_THRESHOLD}; check for finalize leaks`, |
| 153 | ), |
| 154 | ) |
| 155 | } |
| 156 | return retainActiveFirst( |
| 157 | cloned, |
| 158 | isAutonomyRunActive, |
| 159 | run => run.createdAt, |
| 160 | AUTONOMY_RUNS_MAX, |
| 161 | ) |
| 162 | } |
| 163 | |
| 164 | function normalizePersistedRunRecord( |
| 165 | run: PersistedAutonomyRunRecord, |
no test coverage detected