The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Hosted runs: a run held until the service says ready starts by itself
Adarshee013a1a137e
diff --git a/docs/billing-hook.md b/docs/billing-hook.mdindex d000c0af..84455bbe 100644--- a/docs/billing-hook.md+++ b/docs/billing-hook.md@@ -332,6 +332,8 @@ above, unchanged.| `links` | Up to two more links, `[{ label, url }]` (labels up to 40 characters; `url` a same-site path or https), shown before `action`. || `waitFor: { url, everyMs }` | A same-site path (an address on another site is left out) that the page asks with a GET, never cached, every `everyMs` (2 to 60 seconds; 4 by default) while the card is open, for 10 minutes at most. Once it answers `{ "ready": true }`, the card says "All set", sends the same run once more by itself as a new press (a fresh request id), and closes when it has started. While it waits, the card's links open in a new tab, so the card stays. |+| `hold: true` | Only where runs wait instead of being refused (the policy has `limits.held`): the run is made at once and held until the service says ready. Its tile says "<title> · starts by itself", and the card opens once with the same look (and its `waitFor`, which here only closes the card: nothing is sent again). The release loop asks the reserve again under the press's own request id every few seconds; once it is taken, the run enters the line by itself, with no page open, after restarts too. A run the service hasn't taken within 48 hours is cancelled quietly. Without `limits.held`, the answer stays the refusal it is. |+```json{ "ok": false, "code": "blocked", "text": "One more step and your run starts.", "title": "One quick step","tone": "info", "action": { "label": "Details", "url": "/your-page" }, "waitFor": { "url": "/your-page/ready", "everyMs": 4000 } }diff --git a/src/app/api/generations/route.ts b/src/app/api/generations/route.tsindex 740249f5..60210ee9 100644--- a/src/app/api/generations/route.ts+++ b/src/app/api/generations/route.ts@@ -501,7 +501,10 @@ export async function POST(request: Request) {if (viewer.kind === "owner" && token && getSetting("comfyWhere") === "computer" && items.some((g) => g.provider === "comfyui")) notes.push(RUNS_ON_COMPUTER_NOTE);// What the run leaves out or changes (a model that replaced a retired one, a LoRA that runs only on a GPU, a length the API rounds).const all = [...new Set([...notes, ...items.flatMap((g) => g.notes ?? [])])];- return Response.json({ items, ...(all.length && { notes: all }), ...(gpuWarning && { gpuWarning }), ...(heldFor && { held: { reason: heldFor } }) }, { status: 201 });+ // Held until the billing service says ready: its card goes with the answer (the page opens it once; the run starts by+ // itself when the service says ready, with or without the page).+ const card = heldFor && wait?.reason === "service" ? wait.ready : undefined;+ return Response.json({ items, ...(all.length && { notes: all }), ...(gpuWarning && { gpuWarning }), ...(heldFor && { held: { reason: heldFor, ...(card && { card }) } }) }, { status: 201 });} catch (e) {const refusal = e instanceof AccountRunError ? e.refusal : undefined;// A price check of a paid model the account has no key for says so, without opening "Add your key".diff --git a/src/components/billing-card.tsx b/src/components/billing-card.tsxindex 2fba9c5e..8f2f240a 100644--- a/src/components/billing-card.tsx+++ b/src/components/billing-card.tsx@@ -32,7 +32,7 @@ export function BillingCard() {const onRefusal = (e: Event) => {const d = (e as CustomEvent<BillingRefusalDetail>).detail;setRefusal(d);- setPhase(d.waitFor && d.runFresh ? "waiting" : "none");+ setPhase(d.waitFor && (d.runFresh || d.heldRun) ? "waiting" : "none");setOpen(true);// A new price (or the balance it was refused for): the composer and the chip ask again.refreshPriceChecks(qc);@@ -44,9 +44,10 @@ export function BillingCard() {const r = refusal;// While the card is open and waiting: ask the service's address; once ready, send the run once more by itself.useEffect(() => {- if (!open || phase !== "waiting" || !r?.waitFor || !r.runFresh) return;+ if (!open || phase !== "waiting" || !r?.waitFor || (!r.runFresh && !r.heldRun)) return;const stop = new AbortController();- const run = r.runFresh;+ // A held run starts by itself on the server: the card only says so. Else the same run is sent again, once.+ const run = r.heldRun ? async () => true : r.runFresh!;void waitUntilReady(r.waitFor.url, r.waitFor.everyMs, { signal: stop.signal }).then(async (ready) => {if (!ready || stop.signal.aborted) return;setPhase("ready");diff --git a/src/lib/api.ts b/src/lib/api.tsindex 248a73d9..8dc9b0ce 100644--- a/src/lib/api.ts+++ b/src/lib/api.ts@@ -1824,6 +1824,17 @@ export function watchGuestRefusals(): void {// A run started here, on the ComfyUI on this computer: the tab that runs it asks for it at once.if (res.status === 201 && method === "POST" && requestPath(input) === "/api/generations") {window.dispatchEvent(new Event(COMPUTER_KICK_EVENT));+ // A run held until the billing service says ready: its card opens once (the run starts by itself).+ res+ .clone()+ .json()+ .then((b: { held?: { card?: { text?: string } & Omit<BillingRefusalDetail, "code" | "error"> } }) => {+ const c = b.held?.card;+ if (!c?.text || !refusalCard("gpu", window.location)) return;+ const { text, ...look } = c;+ window.dispatchEvent(new CustomEvent<BillingRefusalDetail>(BILLING_EVENT, { detail: { ...look, code: "held", error: text, heldRun: true } }));+ })+ .catch(() => {});}// An account's paid run without its own key for that provider (x-fuobe-add-key: fal | replicate): "Add your key".const addKey = res.status === 403 ? res.headers.get(ADD_KEY_HEADER) : null;diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.tsindex ef7df1b2..eaa1df60 100644--- a/src/lib/catalog/types.ts+++ b/src/lib/catalog/types.ts@@ -1592,6 +1592,8 @@ export interface Generation {held?: "mine" | "today" | "service" | "hour" | "list" | "credits";startAt?: number;paused?: true;+ /** Held until the service says ready: the step it waits for (the service's card title). */+ waitsFor?: string;};/*** A run working on this install's GPUs: the address of its latest preview picture (a JPEG, for the run's own accountdiff --git a/src/lib/hosted.ts b/src/lib/hosted.tsindex 1360d40c..e53fa4d6 100644--- a/src/lib/hosted.ts+++ b/src/lib/hosted.ts@@ -72,6 +72,8 @@ export interface BillingRefusalDetail {waitFor?: { url: string; everyMs: number };/** The same run sent again as a new press (a fresh request id), for waitFor (true when it started). */runFresh?: () => Promise<boolean>;+ /** The run is made and held until the service says ready: it starts by itself, so nothing is sent again. */+ heldRun?: boolean;/** A changed price: the same run sent again at the new price (true when it started). */runAgain?: () => Promise<boolean>;/** The same run sent again on the account's own GPU (true when it started). */diff --git a/src/lib/pool-line.ts b/src/lib/pool-line.tsindex e4ade74c..0ca828b3 100644--- a/src/lib/pool-line.ts+++ b/src/lib/pool-line.ts@@ -35,6 +35,8 @@ export interface LineFacts {startAt?: number;paused?: boolean;note?: string;+ /** Held until the service says ready: the step it waits for (its card's title). The run starts by itself after it. */+ waitsFor?: string;}/** "about 40 s", "about 2 min", "about 3 h". */@@ -86,6 +88,7 @@ function warmingWords(q: LineFacts, now: number): string {*/export function waitWords(q: LineFacts, now = Date.now()): string | null {if (q.light) return "ready in seconds";+ if (q.waitsFor) return "starts by itself";if (q.held === "mine") return "starts after your other runs";if (q.held === "list") return "starts as soon as you're in";if (q.held === "today" || q.held === "hour" || q.held === "credits") return `starts ${atWords(q.startAt, now)}`;@@ -104,6 +107,7 @@ export const capitalFirst = (s: string): string => (s ? s[0].toUpperCase() + s.s* while runs there are paused. Null when nothing is known.*/export function noteWords(q: LineFacts, now = Date.now()): string | null {+ if (q.waitsFor) return `${q.waitsFor} · starts by itself`;if (q.held === "service" && q.paused && q.note) return q.note;if (q.held === "list") return "You're on the waiting list. Your runs start as soon as you're in.";// (The same sentences as a limit's refusal, src/lib/limit-words.ts.)@@ -127,6 +131,7 @@ const MANY_AHEAD = 5;* list"; one waiting for the service, as warming up.*/export function lineWords(q: LineFacts, now = Date.now()): string {+ if (q.waitsFor) return `${q.waitsFor} · starts by itself`;if (q.held === "mine") {const s = q.etaSeconds;return s !== null && Number.isFinite(s) && s >= 0 ? `After your other runs · ready in ${aboutWords(s)}` : "After your other runs";diff --git a/src/server/billing.ts b/src/server/billing.tsindex 35b10d8a..c2e90629 100644--- a/src/server/billing.ts+++ b/src/server/billing.ts@@ -229,7 +229,19 @@ export type ReserveAnswer =/** The hold is made, and the run waits until then (epoch ms) before it enters the line (absent: at once). */startAt?: number;}- | ({ ok: false; code: RefuseCode | "price-changed"; text: string; quote?: Quote; action?: Action; offer?: Offer } & CardLook);+ | ({ ok: false; code: RefuseCode | "price-changed"; text: string; quote?: Quote; action?: Action; offer?: Offer; hold?: boolean } & CardLook);++/**+ * A run the service holds until it says ready (a refusal with `hold: true`, while runs wait instead of being refused):+ * the run is made and waits to enter the line, and is cancelled quietly when the service hasn't said ready within this.+ */+export const HOLD_READY_MS = 48 * 60 * 60_000;++/** What a run held until ready shows: the service's words and its card look (the card opens once, at the press). */+export interface ReadyCard extends CardLook {+ text: string;+ action?: Action;+}export interface Balance {amount: number;diff --git a/src/server/db.ts b/src/server/db.tsindex 0e0cde6c..fa09f9cf 100644--- a/src/server/db.ts+++ b/src/server/db.ts@@ -1310,6 +1310,10 @@ function open(): Database.Database {db.exec(RUN_ON_TABLES);// Runs on this install's GPUs waiting to enter the line (pool-holds.ts): empty unless hosted runs are on.db.exec(POOL_HOLD_TABLES);+ // A run held until the billing service says ready keeps its card (pool-holds.ts ready_json), for tables made before it.+ if (!(db.prepare("PRAGMA table_info(pool_holds)").all() as { name: string }[]).some((c) => c.name === "ready_json")) {+ addColumn(db, "ALTER TABLE pool_holds ADD COLUMN ready_json TEXT");+ }// The billing service's last policy answer (billing.ts keptPolicy): empty unless hosted runs are on.db.exec(KEPT_POLICY_TABLES);// Its list reads this small summary, never every board's pages (a table made before it had the column gets it).diff --git a/src/server/hosted-run.ts b/src/server/hosted-run.tsindex 473419d9..ca2788ce 100644--- a/src/server/hosted-run.ts+++ b/src/server/hosted-run.ts@@ -13,6 +13,7 @@ import {BILLING_WAIT,billingConfigured,cardLook,+ type ReadyCard,cachedPolicy,forgetBalance,FREE_QUOTE,@@ -686,7 +687,7 @@ export function policyWait(p: Pick<Policy, "limits"> | null | undefined): Pick<R* start (`today`, `hour`: its hold is made; `credits`: it reserves then).*/export type ReserveWait =- | { reason: "service"; requestId: string; paused?: true }+ | { reason: "service"; requestId: string; paused?: true; ready?: ReadyCard }| { reason: "today" | "hour"; startAt: number }| { reason: "credits"; startAt: number; requestId: string };@@ -748,6 +749,12 @@ export async function reservePool(// No free generations left until they renew: it waits, and reserves then.const at = await renewalAt(a, account, run, queue);if (at !== null) return { ok: true, stamp: base, wait: { reason: "credits", startAt: at, requestId }, facts };+ // Held until the service says ready: the run is made and waits; it reserves again under this same request id, and+ // enters the line once the service takes it, with no page open (pool-release.ts).+ if (a.hold === true) {+ const ready: ReadyCard = { text: a.text, ...(a.action && { action: a.action }), ...cardLook(a) };+ return { ok: true, stamp: base, wait: { reason: "service", requestId, ready }, facts };+ }}if (!a.ok) {if (a.unsure) {diff --git a/src/server/hosted.ts b/src/server/hosted.tsindex 228814bc..5bf6f7dd 100644--- a/src/server/hosted.ts+++ b/src/server/hosted.ts@@ -381,9 +381,20 @@ export function queueFacts(accountId: string | null, workflowId?: string | null)* starts when a GPU is free). Behind the account's runs going: about when it would be ready, when known (when the first* of them is due done, plus a new run's wait now). Until a time: that time. Null when the row isn't held.*/-export function heldLine(generationId: string, now = Date.now()): (LinePlace & { held: HoldReason; startAt?: number; paused?: true }) | null {+export function heldLine(generationId: string, now = Date.now()): (LinePlace & { held: HoldReason; startAt?: number; paused?: true; waitsFor?: string }) | null {const h = holdOf(generationId);if (!h) return null;+ // Held until the service says ready: its card's title on the tile ("<title> · starts by itself").+ if (h.ready_json) {+ let title = "One more step";+ try {+ const c = JSON.parse(h.ready_json) as { title?: unknown };+ if (typeof c.title === "string" && c.title) title = c.title;+ } catch {+ // the plain words+ }+ return { place: 1, etaSeconds: null, held: h.reason, waitsFor: title };+ }const startAt = h.start_at !== null && h.start_at > now ? h.start_at : undefined;const base = { held: h.reason, ...(startAt !== undefined && { startAt }) };if (startAt !== undefined) return { place: 1, etaSeconds: null, ...base };diff --git a/src/server/pool-holds.ts b/src/server/pool-holds.tsindex 298cc6a1..62cf17c8 100644--- a/src/server/pool-holds.ts+++ b/src/server/pool-holds.ts@@ -56,6 +56,8 @@ export interface HoldRow {next_at: number | null;holder: string | null;lease_until: number | null;+ /** Held until the service says ready: its card (JSON, billing.ts ReadyCard); null for any other hold. */+ ready_json: string | null;}/** A run to hold, as the press made it. */@@ -86,6 +88,8 @@ export interface NewHold {requestId?: string;/** What the reserve at release sends of the run (its facts, the price shown, its timing). */facts?: unknown;+ /** Held until the service says ready: its words and card (billing.ts ReadyCard). */+ ready?: unknown;}/** Hold a run (call it inside the transaction that made its rows). Returns its run id (its first row's id). */@@ -93,8 +97,8 @@ export function holdRun(h: NewHold, now = Date.now()): string {const runId = h.runId ?? h.rows[0]?.id;if (!runId) throw new Error("A run to hold has no rows");const insert = db().prepare(- `INSERT INTO pool_holds (generation_id, run_id, account_id, reason, pressed_at, start_at, rank_rule, reserved, checked, paused, counted, request_id, facts_json, job, tries, tried_at, next_at)- VALUES (@id, @run, @account, @reason, @pressed, @start, @rank, @reserved, @checked, @paused, @counted, @request, @facts, @job, 0, NULL, @next)+ `INSERT INTO pool_holds (generation_id, run_id, account_id, reason, pressed_at, start_at, rank_rule, reserved, checked, paused, counted, request_id, facts_json, job, tries, tried_at, next_at, ready_json)+ VALUES (@id, @run, @account, @reason, @pressed, @start, @rank, @reserved, @checked, @paused, @counted, @request, @facts, @job, 0, NULL, @next, @ready)ON CONFLICT(generation_id) DO NOTHING`,);const facts = h.facts === undefined ? null : JSON.stringify(h.facts);@@ -115,6 +119,7 @@ export function holdRun(h: NewHold, now = Date.now()): string {facts,job: r.job,next: now,+ ready: h.ready === undefined ? null : JSON.stringify(h.ready),});}return runId;@@ -263,7 +268,7 @@ export interface HoldCauses {/** The policy's limits (pool-limits.ts AdmitPlan): behind the account's runs going, or an hourly limit until `startAt`. */limit?: { reason: "mine" | "hour"; startAt?: number };/** The billing service's answer (hosted-run.ts ReserveWait). */- wait?: { reason: "service" | "today" | "hour" | "credits"; startAt?: number; requestId?: string; paused?: true };+ wait?: { reason: "service" | "today" | "hour" | "credits"; startAt?: number; requestId?: string; paused?: true; ready?: unknown };/** The moderation service didn't answer: the run is checked before it enters the line. */unchecked?: boolean;}@@ -275,7 +280,7 @@ export interface HoldCauses {* the back of the line when the account's own limits held it too. It reserves at release when the service didn't* answer, or for free generations that renew.*/-export function holdShape(c: HoldCauses): Pick<NewHold, "reason" | "startAt" | "rankRule" | "reserved" | "checked" | "paused" | "requestId"> | null {+export function holdShape(c: HoldCauses): Pick<NewHold, "reason" | "startAt" | "rankRule" | "reserved" | "checked" | "paused" | "requestId" | "ready"> | null {if (!c.limit && !c.wait && !c.unchecked) return null;const starts = [c.limit?.startAt, c.wait?.startAt].filter((n): n is number => typeof n === "number");const startAt = starts.length ? Math.max(...starts) : undefined;@@ -290,9 +295,15 @@ export function holdShape(c: HoldCauses): Pick<NewHold, "reason" | "startAt" | "checked: !c.unchecked,...(c.wait?.paused && { paused: true }),...(c.wait?.requestId && { requestId: c.wait.requestId }),+ ...(c.wait?.ready !== undefined && { ready: c.wait.ready }),};}+/** Held runs the service hasn't said ready for within HOLD_READY_MS (billing.ts): their run ids. */+export function expiredReadyHolds(maxMs: number, now = Date.now()): string[] {+ return (db().prepare("SELECT DISTINCT run_id FROM pool_holds WHERE ready_json IS NOT NULL AND pressed_at < ?").all(now - maxMs) as { run_id: string }[]).map((r) => r.run_id);+}+/*** About how long a run waits before it enters the line, for the billing service's hold (ReserveRequest.timing.heldMs):* until its later start, else an hour behind the account's runs going (the service keeps the hold of a run stilldiff --git a/src/server/pool-release.ts b/src/server/pool-release.tsindex f71b0526..85d34574 100644--- a/src/server/pool-release.ts+++ b/src/server/pool-release.ts@@ -1,12 +1,12 @@import "server-only";import type { GenerationRequest } from "@/lib/catalog/types";import { accountById } from "./auth";-import { accountFacts, billingConfigured, forgetBalance, keptPolicy, policy as billingPolicy, policyGiveUpMs, reserve, serviceAnsweredAt, type Policy } from "./billing";+import { accountFacts, billingConfigured, forgetBalance, HOLD_READY_MS, keptPolicy, policy as billingPolicy, policyGiveUpMs, reserve, serviceAnsweredAt, type Policy } from "./billing";import { db } from "./db";-import { failWaiting, previewGeneration, restampRows, sendHeld } from "./generations";+import { cancelGeneration, failWaiting, previewGeneration, restampRows, sendHeld } from "./generations";import { queueFacts, runOnPool } from "./hosted";import { heldStamp, moderateRun, renewalAt, type ReserveFacts } from "./hosted-run";-import { dropGone, dropRun, endRunLease, heldRunHeads, leaseRun, runHolds, setRunHold, startReason, takeRun, type HoldRow } from "./pool-holds";+import { dropGone, dropRun, endRunLease, expiredReadyHolds, heldRunHeads, leaseRun, runHolds, setRunHold, startReason, takeRun, type HoldRow } from "./pool-holds";import { lineRoom, poolRunCounts } from "./pool-limits";import { stampOf, withoutStamp, withRunStamp } from "./run-stamp";@@ -28,6 +28,9 @@ import { stampOf, withoutStamp, withRunStamp } from "./run-stamp";* never release one run twice, and a process that stops mid-way leaves it to the other once its lease ends.*/+/** How often a run held until the service says ready asks again. */+export const READY_ASK_MS = 5000;+/** Service calls one turn of the loop makes at most: a service that hangs holds up nothing else for long. */const SERVICE_TRIES_PER_TURN = 3;@@ -148,6 +151,11 @@ async function serviceStep(h: HoldRow, now: number): Promise<"ready" | "wait" |later(h, now, a.code === "paused" && !a.down);return a.down ? "down" : "wait";}+ // Still held until the service says ready: asked again later, calmly (it isn't the service that is slow).+ if (a.hold === true && h.ready_json) {+ setRunHold(h.run_id, { tries: h.tries + 1, tried_at: now, next_at: now + READY_ASK_MS });+ return "wait";+ }// No free generations left until they renew: it waits for them, and reserves then.const renews = await renewalAt(a, account, facts.run, queue, now);if (renews !== null) {@@ -175,6 +183,12 @@ async function serviceStep(h: HoldRow, now: number): Promise<"ready" | "wait" |* Holds whose rows no longer wait (stopped, deleted) go first.*/export async function releaseHeldRuns(now = Date.now()): Promise<number> {+ // Held until ready for longer than HOLD_READY_MS: cancelled quietly (no failure on the tile, nothing charged).+ for (const run of expiredReadyHolds(HOLD_READY_MS, now)) {+ const ids = runHolds(run).map((r) => r.generation_id);+ dropRun(run);+ for (const id of ids) await cancelGeneration(id).catch(() => undefined);+ }dropGone();const heads = heldRunHeads();if (!heads.length) return 0;diff --git a/tests/billing-card-wait.test.ts b/tests/billing-card-wait.test.tsindex cdd113a0..2248d627 100644--- a/tests/billing-card-wait.test.ts+++ b/tests/billing-card-wait.test.ts@@ -50,3 +50,13 @@ describe("the billing card's wait", () => {expect(freshBody("not json", () => "new")).toBe("not json");});});++describe("a run held until the service says ready", () => {+ it("says on its tile and before Run that it starts by itself after the service's step", async () => {+ const { lineWords, noteWords, waitWords } = await import("@/lib/pool-line");+ const q = { place: 1, etaSeconds: null, held: "service" as const, waitsFor: "One more step" };+ expect(lineWords(q)).toBe("One more step · starts by itself");+ expect(noteWords(q)).toBe("One more step · starts by itself");+ expect(waitWords(q)).toBe("starts by itself");+ });+});diff --git a/tests/pool-holds.test.ts b/tests/pool-holds.test.tsindex d34101d2..fe62aa94 100644--- a/tests/pool-holds.test.ts+++ b/tests/pool-holds.test.ts@@ -490,6 +490,56 @@ describe("service blips (H3)", () => {expect(await until(() => taskOf(idOf(r)))).toBeTruthy();});+ it("a run the service holds until it says ready: made at once with its card, asked again calmly, and started by itself with no page open", async () => {+ const a = account();+ await check(a.cookie);+ const look = { title: "One more step", tone: "info", action: { label: "Details", url: "/details" }, waitFor: { url: "/ready", everyMs: 4000 } };+ fake.refuse = { code: "blocked", text: "One more step, then your run starts by itself.", hold: true, ...look };+ const r = await press(a.cookie);+ expect(r.status, JSON.stringify(r.body)).toBe(201);+ expect(r.body.held).toEqual({ reason: "service", card: { text: "One more step, then your run starts by itself.", ...look } });+ const id = idOf(r);+ expect(tile(id)).toBe("One more step · starts by itself");+ expect(heldOf(id)!.ready_json).toBeTruthy();+ // still held: asked again, nothing sent, nothing failed+ await tick();+ await tick();+ expect(taskOf(id)).toBeUndefined();+ expect(getGeneration(id)!.status).toBe("queued");+ // the service says ready (no page asks anything): it reserves under its press's request id and enters the line+ const requestId = heldOf(id)!.request_id;+ fake.refuse = null;+ const t = await until(() => taskOf(id), 400);+ expect(t).toBeTruthy();+ expect(heldOf(id)).toBeUndefined();+ expect([...fake.holds.values()].filter((h) => h.requestId === requestId)).toHaveLength(1);+ });++ it("a run held until ready that the service never says ready for is cancelled quietly after its time", async () => {+ const a = account();+ await check(a.cookie);+ fake.refuse = { code: "blocked", text: "One more step.", hold: true };+ const r = await press(a.cookie);+ const id = idOf(r);+ expect(heldOf(id)).toBeTruthy();+ db().prepare("UPDATE pool_holds SET pressed_at = ? WHERE generation_id = ?").run(Date.now() - billing.HOLD_READY_MS - 1000, id);+ await release.releaseHeldRuns();+ expect(heldOf(id)).toBeUndefined();+ await until(() => getGeneration(id)!.status === "canceled");+ expect(getGeneration(id)!.error ?? null).toBeNull();+ });++ it("an answer that asks to hold, where runs aren't held (no `held` in the policy), stays the refusal it was", async () => {+ const a = account();+ fake.policy = { ...FAKE_POLICY, ttlS: 0 };+ billing.resetBillingCache();+ await check(a.cookie);+ fake.refuse = { code: "blocked", text: "One more step.", hold: true };+ const r = await press(a.cookie);+ expect(r.status).toBe(403);+ expect(r.body.code).toBe("blocked");+ });+it("a refusal once the service answers ends the run in plain words", async () => {const was = { ...billing.RESERVE_INLINE };try {