MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / selectPersistedAutonomyRuns

Function selectPersistedAutonomyRuns

src/utils/autonomyRuns.ts:140–162  ·  view source on GitHub ↗
(
  runs: AutonomyRunRecord[],
)

Source from the content-addressed store, hash-verified

138}
139
140function 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
164function normalizePersistedRunRecord(
165 run: PersistedAutonomyRunRecord,

Callers 1

writeAutonomyRunsFunction · 0.85

Calls 2

retainActiveFirstFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected