perf(heartbeat): schedule retry promotion from durable deadlines

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-30 15:53:26 -05:00
1 parent 76fde891cc
commit 294d8ca1c2
29 files changed
+415 -12

No files matched your search

@@ -80,18 +80,19 @@ export function agentRecords(db: Db, effects: LifecycleEffects) {
throw conflict("Only agents in error status can have their error cleared");
}
const updated = await db
.update(agents)
.set({
const updated = await effects.transaction(db, existing.companyId, async tx => {
await effects.beforeStatusChange(tx, existing.companyId, id, "error", "idle");
return tx.update(agents).set({
status: "idle",
pauseReason: null,
pausedAt: null,
errorReason: null,
updatedAt: new Date(),
})
.where(and(eq(agents.id, id), eq(agents.status, "error"), eq(agents.lifecycleState, "ready")))
.returning()
.then((rows) => rows[0] ?? null);
.where(and(eq(agents.id, id), eq(agents.status, "error"), eq(agents.lifecycleState, "ready")))
.returning()
.then((rows) => rows[0] ?? null);
});
if (!updated) {
throw conflict("Only agents in error status can have their error cleared");