Drive remaining live run and resource recovery from durable work (#18419)

Reviewed and verified at 6a4c193906.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip authored and GitHub committed 2026-10-31 16:00:35 -05:00
1 parent eb12cfc96b
commit 9ca9af544a
62 files changed
+1822 -237

No files matched your search

@@ -123,6 +123,7 @@ export interface WakeQueueTransaction {
cancelDeferredWake(input: {
companyId: string;
wakeId: string;
agentId: string;
reason: string;
now: Date;
}): Promise<boolean>;
@@ -135,7 +136,7 @@ export interface WakeQueueTransaction {
now: Date;
}): Promise<DeferredWakeCandidate | null>;
/** Sets `status = 'failed'` guarded by the current `deferred_issue_execution` status. */
failDeferredWake(input: { companyId: string; wakeId: string; now: Date }): Promise<boolean>;
failDeferredWake(input: { companyId: string; wakeId: string; agentId: string; now: Date }): Promise<boolean>;
getPauseHoldFacts(input: {
companyId: string;
issueId: string;
@@ -191,6 +191,7 @@ async function runReleaseDrain(
await ports.transaction.cancelDeferredWake({
companyId: run.companyId,
wakeId: candidate.id,
agentId: candidate.agentId,
reason: "Delegation closing note refers to completed child work",
now: input.now,
});
@@ -212,6 +213,7 @@ async function runReleaseDrain(
await ports.transaction.cancelDeferredWake({
companyId: run.companyId,
wakeId: candidate.id,
agentId: candidate.agentId,
reason: "Deferred task messages now belong to the current assignee",
now: input.now,
});
@@ -260,6 +262,7 @@ async function runReleaseDrain(
await ports.transaction.cancelDeferredWake({
companyId: run.companyId,
wakeId: candidate.id,
agentId: candidate.agentId,
reason: commentAction.selfAuthored
? "Deferred wake contained only comments authored by the finishing run"
: "Queued messages were discarded before promotion",
@@ -288,7 +291,7 @@ async function runReleaseDrain(
});
if (wakeOutcome.kind === "fail_not_invokable") {
await ports.transaction.failDeferredWake({ companyId: run.companyId, wakeId: workingCandidate.id, now: input.now });
await ports.transaction.failDeferredWake({ companyId: run.companyId, wakeId: workingCandidate.id, agentId: workingCandidate.agentId, now: input.now });
continue;
}
@@ -300,7 +303,7 @@ async function runReleaseDrain(
if (wakeOutcome.kind === "cancel_pause_hold") {
await ports.transaction.cancelDeferredWake({
companyId: run.companyId,
wakeId: workingCandidate.id,
wakeId: workingCandidate.id, agentId: workingCandidate.agentId,
reason: "Deferred wake suppressed by active subtree pause hold",
now: input.now,
});
@@ -374,7 +377,7 @@ async function promoteDeferredWake(
) {
await ports.transaction.cancelDeferredWake({
companyId: run.companyId,
wakeId: workingCandidate.id,
wakeId: workingCandidate.id, agentId: workingCandidate.agentId,
reason: "Deferred execution wake no longer applies to a terminal task",
now: input.now,
});