From 860eec1bfc5fdc650dc90dcbf09ef2cc71d680bc Mon Sep 17 00:00:00 2001 From: aiongg <67543387+aiongg@users.noreply.github.com> Date: Fri, 20 Nov 2026 00:08:10 +0000 Subject: [PATCH] Load rig: per-scenario time scale, scenario 6 at 0.5 in its own process with calls queued over 25 s, scenario 5 gives the failing helper 5 slots, scenario 3 checks that no requeued lease's reply is accepted; claims take a leased call out of the cached queue order instead of rebuilding it --- scripts/loadtest/README.md | 18 ++++++------ scripts/loadtest/report.mjs | 36 +++++++++++++++++++++++- scripts/loadtest/rig.mjs | 13 ++++++--- scripts/loadtest/run.mjs | 55 ++++++++++++++++++++++++++++--------- src/remote/calls.ts | 22 +++++++++++++-- 5 files changed, 115 insertions(+), 29 deletions(-) diff --git a/scripts/loadtest/README.md b/scripts/loadtest/README.md index 63b28940..266c641b 100644 --- a/scripts/loadtest/README.md +++ b/scripts/loadtest/README.md @@ -7,11 +7,13 @@ Runs user-local helpers against a scratch dashboard with injected faults and loa ```sh node scripts/loadtest/run.mjs smoke # 2 helpers, 20 calls, faults on; about 1 minute node scripts/loadtest/run.mjs 1 # one scenario: 1 to 6 -node scripts/loadtest/run.mjs all # 1-5 side by side, then 6 alone; about 4 minutes at the default time scale +node scripts/loadtest/run.mjs all # 1-5 side by side, then 6 alone in its own process; about 2 minutes ``` Options: `--dir ` (default a new directory under the system temp dir; mode 0700), `--db ` (copy of a production-like database, taken with `VACUUM INTO`; the source is opened read-only), `--time-scale S` (0.01 to 1, default 0.1, see below), `--time-factor F` (multiplies the fake harness delays, on top of the scale), `--users N`, `--parallel K`, `--calls M`, `--max-minutes N`, `--sequential` (with `all`). Exit code 1 when a line fails. +`RIG_DASH_PROF=` in the environment writes a CPU profile of each scratch dashboard there (`--cpu-prof`). + Requirements: Node 24, `bwrap` (the helper's own sandbox check), and the repository's dependencies. Run it from the repository root. ## Parts @@ -38,14 +40,14 @@ Requirements: Node 24, `bwrap` (the helper's own sandbox check), and the reposit |---|---|---| | 1 | 10% 502, 5% resets, 2% 429 (`Retry-After` 2 s), 0-3 s latency | no finished reply lost | | 2 | Dashboard restarted mid-call, then stopped for 5 minutes | no reply lost; no cool-off | -| 3 | One helper (with its harnesses) frozen with SIGSTOP for 3 minutes, then resumed | no reply lost; no call answered twice | +| 3 | One helper (with its harnesses) frozen with SIGSTOP for 3 minutes, then resumed | no reply lost; no reply accepted from a requeued lease (the frozen helper's calls run again elsewhere, as they must; its late replies are refused) | | 4 | One helper killed with SIGKILL mid-call, restarted 20 s later | no reply lost | -| 5 | One helper whose harness always fails | only that helper cooled off; the others finish every call | -| 6 | 50 helpers x 4 slots against 500 mixed calls, real durations | dashboard p99 under 200 ms, no request over 5 s, no SQLite busy lines, gating p95 wait under 60 s | +| 5 | One helper whose harness always fails (5 slots and the fast lane, so it fails 5 calls in a row before the queue drains) | only that helper cooled off; the others finish every call | +| 6 | 50 helpers x 4 slots against 300 mixed calls queued over 25 s, at time scale 0.5 (claim, heartbeat and status intervals about twice production's rate) with harness delays cut to 10% | dashboard p99 under 200 ms, no request over 5 s, no SQLite busy lines, gating p95 wait under 60 s | Every scenario also checks that no helper sat idle for over 90 seconds with calls queued without a reason visible to the user (a cool-off, a readiness other than `ready`, a last error, or a helper that is not running). -Definitions: a lost reply is a call the fake harness answered (ledger) whose call row did not end `done`. Duplicate runs are calls with more than one harness start. Latency is the dashboard's time per request as the proxy sees it, excluding injected delay and faults. SQLite busy errors are lines in the dashboard log matching `SQLITE_BUSY` or `database is locked`. Queue wait is the call's `queued_ms`. +Definitions: a lost reply is a call the fake harness answered (ledger) whose call row did not end `done`. Duplicate runs are calls with more than one harness start. A reply accepted from a requeued lease is a call two of whose leases ended `submitted` in the helpers' logs. Latency is the dashboard's time per request as the proxy sees it, excluding injected delay and faults. SQLite busy errors are lines in the dashboard log matching `SQLITE_BUSY` or `database is locked`. Queue wait is the call's `queued_ms`. ## Output @@ -53,7 +55,7 @@ The report prints at the end; each scenario directory also holds `report.json`, ## Known limits -- A scaled run multiplies the helpers' claim rate by 1 / scale, so scenario 6 at the default scale 0.1 loads the dashboard about ten times harder than production does; its p99 line can fail there while passing at `--time-scale 1`. +- A scaled run multiplies the helpers' claim rate by 1 / scale. Scenario 6 therefore runs at its own scale, 0.5, unless `--time-scale` is given; `all` runs it in a separate process, since the driver's server modules read the scale once per process. -- The "idle helper has a reason" line reads the helper status table. Until the Connect page shows slots, busy and last error, a helper that is ready and silent counts as idle without a reason. -- The rig does not measure the fast lane or the per-user call limit; it runs ordinary helpers, so those arrive as the helper and server tracks land. +- The "idle helper has a reason" line reads the helper status table: a helper that is ready, holds no lease and reports no last error while calls wait counts as idle without a reason. +- The helpers run their fast lane, but no line checks it, nor the per-user call limit. diff --git a/scripts/loadtest/report.mjs b/scripts/loadtest/report.mjs index 354c2c4d..ccde5251 100644 --- a/scripts/loadtest/report.mjs +++ b/scripts/loadtest/report.mjs @@ -6,6 +6,36 @@ import { MIX, pct } from "./rig.mjs"; const ms = (v) => (v === null || v === undefined ? "n/a" : `${Math.round(v)} ms`); const s = (v) => (v === null || v === undefined ? "n/a" : `${(v / 1000).toFixed(1)} s`); +const OUTCOMES = ["submitted", "lost", "failed", "rejected", "released"]; + +/** + * How each lease a helper ran ended, from its log: `lease [ (fast lane)]: `, then `<outcome>: <title>, …` or + * `<outcome>: <title>: …`. A lease id is its call's id. Returns call id -> outcomes, one per lease of the call. + */ +export function leaseOutcomes(rig) { + /** @type {Map<number, string[]>} */ + const out = new Map(); + for (const h of rig.helpers) { + if (!h) continue; + let text = ""; + try { text = readFileSync(h.log, "utf8"); } catch { continue; } + /** @type {{ id: number, title: string }[]} */ + const open = []; + for (const line of text.split("\n")) { + const l = /^lease (\d+)(?: \(fast lane\))?: (.+)$/.exec(line); + if (l) { open.push({ id: Number(l[1]), title: l[2] }); continue; } + const state = OUTCOMES.find((o) => line.startsWith(`${o}: `)); + if (!state) continue; + const rest = line.slice(state.length + 2); + const i = open.findIndex((x) => rest === x.title || rest.startsWith(`${x.title},`) || rest.startsWith(`${x.title}:`)); + if (i < 0) continue; + const [x] = open.splice(i, 1); + out.set(x.id, [...(out.get(x.id) ?? []), state]); + } + } + return out; +} + export function collect(rig) { const db = rig.db; const rows = new Map(db.prepare("SELECT id, state, tier, prompt_id, queued_ms, attempt, error, token_id, user_login FROM main.remote_calls").all().map((r) => [Number(r.id), r])); @@ -24,6 +54,10 @@ export function collect(rig) { if (starts > 1) m.duplicateRuns.push({ call: c.id, starts }); } m.waits = waits; + // A call that ran again after a requeue (a frozen or lost helper) is expected; its earlier lease's reply must be refused. + const outcomes = leaseOutcomes(rig); + m.acceptedTwice = [...outcomes].filter(([, o]) => o.filter((x) => x === "submitted").length > 1).map(([call, o]) => ({ call, outcomes: o })); + m.rerunOutcomes = m.duplicateRuns.map((d) => ({ call: d.call, outcomes: outcomes.get(d.call) ?? [] })); // The cool-off is per login: the audit target is the login cooled off. m.cooloffs = db.prepare("SELECT at, target FROM main.audit WHERE action = 'remote-cooloff' ORDER BY at").all().map((r) => ({ at: r.at, login: String(r.target) })); m.cooloffHelpers = [...new Set(m.cooloffs.flatMap((c) => rig.helpers.flatMap((h, i) => (h && h.login.toLowerCase() === c.login.toLowerCase() ? [i + 1] : []))))]; @@ -54,7 +88,7 @@ export function evaluate(rig, spec, m) { add("only the failing helper is cooled off", m.cooloffHelpers.length === 1 && m.cooloffHelpers[0] === bad, `cooled helpers: ${m.cooloffHelpers.join(", ") || "none"} (failing: ${bad})`); add("other helpers keep working", m.done > 0 && m.failed === 0, `${m.done} done, ${m.failed} failed for good`); } - if (num.includes("noDouble")) add("no call run twice after a requeue", m.answeredAgain.length === 0, `${m.answeredAgain.length} answered twice, ${m.duplicateRuns.length} started more than once`); + if (num.includes("noDouble")) add("no reply accepted from a requeued lease", m.acceptedTwice.length === 0, `${m.duplicateRuns.length} call(s) ran again after a requeue${m.rerunOutcomes.length ? ` (leases ended ${m.rerunOutcomes.map((r) => `#${r.call} ${r.outcomes.join("/") || "?"}`).join(", ")})` : ""}; ${m.acceptedTwice.length} accepted twice`); if (num.includes("latency")) { const u = m.proxy.upstream; add("dashboard p99 under 200 ms", u.p99 !== null && u.p99 < 200, `p50 ${ms(u.p50)}, p99 ${ms(u.p99)}, max ${ms(u.max)} over ${u.n} requests`); diff --git a/scripts/loadtest/rig.mjs b/scripts/loadtest/rig.mjs index 59606fb2..6eeca04f 100644 --- a/scripts/loadtest/rig.mjs +++ b/scripts/loadtest/rig.mjs @@ -95,7 +95,7 @@ export class Rig { AUTOCRAFT_DEV_AUTH: "1", AUTOCRAFT_LISTEN: `127.0.0.1:${this.dashPort}`, AUTOCRAFT_DB: this.dbPath, AUTOCRAFT_DEV_PERMS: join(this.dir, "perms.json"), ...this.scaleEnv(), }; writeFileSync(join(this.dir, "perms.json"), "{}"); - this.dash = spawn(process.execPath, [join(ROOT, "src/cli.ts"), "dash", "serve"], { cwd: ROOT, env, stdio: ["ignore", "pipe", "pipe"] }); + this.dash = spawn(process.execPath, [...(process.env.RIG_DASH_PROF ? ["--cpu-prof", `--cpu-prof-dir=${process.env.RIG_DASH_PROF}`] : []), join(ROOT, "src/cli.ts"), "dash", "serve"], { cwd: ROOT, env, stdio: ["ignore", "pipe", "pipe"] }); this.dash.stdout.pipe(this.dashLog, { end: false }); this.dash.stderr.pipe(this.dashLog, { end: false }); const dash = this.dash; this.dashExit = new Promise((r) => dash.on("exit", r)); @@ -212,12 +212,17 @@ export class Rig { } /** Queues `n` calls of the mix at once (a queued backlog) and keeps the calls alive like a job process: seen_at and lease expiry. */ - async enqueueMix(n, { followUps = 0.1 } = {}) { + /** Queues `n` calls of the mix; with `rampMs`, spread evenly over that long (jobs queue their calls as they go), else at once. */ + async enqueueMix(n, { followUps = 0.1, rampMs = 0 } = {}) { const pick = () => { let r = Math.random(); for (const k of MIX) { if ((r -= k.share) <= 0) return k; } return MIX[3]; }; const kinds = Array.from({ length: n }, pick); - // A few Opus calls keep their session so a follow-up turn can resume it. - for (const k of kinds) await this.enqueue(k.tier === "top" && Math.random() < followUps * 2 ? { ...k, keepSession: true } : k); this.startJobEmulator(); + const t0 = Date.now(); + for (const [i, k] of kinds.entries()) { + if (rampMs > 0) { const due = t0 + (i * rampMs) / n; if (due > Date.now()) await sleep(due - Date.now()); } + // A few Opus calls keep their session so a follow-up turn can resume it. + await this.enqueue(k.tier === "top" && Math.random() < followUps * 2 ? { ...k, keepSession: true } : k); + } } startJobEmulator() { if (this.jobTimer) return; diff --git a/scripts/loadtest/run.mjs b/scripts/loadtest/run.mjs index 8dd9eeb1..eb84cb7d 100644 --- a/scripts/loadtest/run.mjs +++ b/scripts/loadtest/run.mjs @@ -3,7 +3,8 @@ // node scripts/loadtest/run.mjs <smoke|1|2|3|4|5|6|all> [--dir <work dir>] [--db <db to copy>] [--time-factor F] [--time-scale S] // [--users N] [--parallel K] [--calls M] [--max-minutes N] [--sequential] // `all` runs 1 to 5 side by side, then 6 alone (its latency numbers need the machine to itself). See README.md. -import { mkdirSync, writeFileSync } from "node:fs"; +import { spawn } from "node:child_process"; +import { mkdirSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { collect, evaluate } from "./report.mjs"; @@ -15,7 +16,9 @@ const flag = (n) => argv.includes(`--${n}`); const which = argv.find((a) => !a.startsWith("--") && !argv[argv.indexOf(a) - 1]?.startsWith("--")) ?? "smoke"; // Every user-local time window (leases, heartbeats, cool-offs) and every scenario timing is multiplied by the scale -// (AUTOCRAFT_REMOTE_TIME_SCALE, test only); 1 runs the production windows. +// (AUTOCRAFT_REMOTE_TIME_SCALE, test only); 1 runs the production windows. A scenario may name its own default scale; the +// driver's server modules read the scale once per process, so `all` runs such a scenario in a process of its own. +const SCALE_GIVEN = argv.includes("--time-scale"); const TIME_SCALE = Number(opt("time-scale", 0.1)); if (!(TIME_SCALE >= 0.01 && TIME_SCALE <= 1)) { console.error("--time-scale must be a number from 0.01 to 1"); process.exit(64); } const S = (ms) => Math.max(1, Math.round(ms * TIME_SCALE)); @@ -32,23 +35,35 @@ const SCENARIOS = { async during(rig) { await sleep(S(40_000)); rig.helpers[0].frozen = true; await rig.freezeHelper(0, 180 * TIME_SCALE); rig.helpers[0].frozen = false; } }, 4: { title: "a helper killed with SIGKILL mid-call and restarted", users: 4, parallel: 2, calls: 40, timeFactor: 0.5, accept: ["noLoss", "idle"], maxMin: 12, async during(rig) { await sleep(S(45_000)); rig.killHelper(0); await sleep(S(20_000)); rig.restartHelper(0); } }, - 5: { title: "a helper whose harness always fails", users: 5, parallel: 2, calls: 60, timeFactor: 0.1, failing: [4], accept: ["oneCooloff", "idle"], maxMin: 10 }, - 6: { title: "50 helpers x 4 slots against 500 mixed calls", users: 50, parallel: 4, calls: 500, timeFactor: 1, accept: ["noLoss", "latency", "idle"], maxMin: 25 }, + // The failing helper runs 5 slots and the fast lane, so its first claims fail 5 calls in a row (the cool-off threshold) + // before the others drain the queue; one slot each would back off after every failure and see too few calls. + 5: { title: "a helper whose harness always fails", users: 5, parallel: 2, calls: 60, timeFactor: 0.1, failing: [4], failingParallel: 5, accept: ["oneCooloff", "idle"], maxMin: 10 }, + // Claims, heartbeats and status reports come at the scaled intervals, so the scale sets the dashboard's idle load: 0.5 is + // about twice production's. The harness delays are cut instead (time factor) to keep the run short, and the calls arrive + // over 25 s, as jobs queue them, rather than in one burst. + 6: { title: "50 helpers x 4 slots against 300 mixed calls", users: 50, parallel: 4, calls: 300, rampS: 25, timeFactor: 0.1, timeScale: 0.5, accept: ["noLoss", "latency", "idle"], maxMin: 25 }, }; +/** The time scale scenario `key` runs at: --time-scale when given, else the scenario's own, else the default. */ +const scaleOf = (key) => (SCALE_GIVEN ? TIME_SCALE : SCENARIOS[key].timeScale ?? TIME_SCALE); + async function run(key) { const sp = SCENARIOS[key]; - const spec = { ...sp, name: `scenario-${key}`, users: Number(opt("users", sp.users)), parallel: Number(opt("parallel", sp.parallel)), calls: Number(opt("calls", sp.calls)), timeFactor: Number(opt("time-factor", sp.timeFactor)) * TIME_SCALE, maxMin: Number(opt("max-minutes", sp.maxMin * Math.max(TIME_SCALE, 0.3))) }; + const scale = scaleOf(key); + const spec = { ...sp, name: `scenario-${key}`, users: Number(opt("users", sp.users)), parallel: Number(opt("parallel", sp.parallel)), calls: Number(opt("calls", sp.calls)), timeFactor: Number(opt("time-factor", sp.timeFactor)) * scale, maxMin: Number(opt("max-minutes", sp.maxMin * Math.max(scale, 0.3))) }; const dir = opt("dir", join(tmpdir(), `autocraft-loadtest-${Date.now()}`)); mkdirSync(dir, { recursive: true, mode: 0o700 }); - const rig = new Rig({ name: spec.name, dir, users: spec.users, parallel: spec.parallel, timeFactor: spec.timeFactor, timeScale: TIME_SCALE, dbFrom: opt("db"), faults: sp.faults }); + const rig = new Rig({ name: spec.name, dir, users: spec.users, parallel: spec.parallel, timeFactor: spec.timeFactor, timeScale: scale, dbFrom: opt("db"), faults: sp.faults }); try { await rig.init(); - for (let i = 0; i < spec.users; i++) rig.startHelper(i, { failing: (sp.failing ?? []).includes(i) }); + for (let i = 0; i < spec.users; i++) { + const failing = (sp.failing ?? []).includes(i); + rig.startHelper(i, { failing, ...(failing && sp.failingParallel && { parallel: sp.failingParallel }) }); + } rig.note(`${spec.users} helpers started, ${spec.parallel} slots each`); await sleep(Math.min(S(20_000) + 3000, 4000 + spec.users * 300)); - await rig.enqueueMix(spec.calls); - rig.note(`${spec.calls} calls queued (harness delay factor ${spec.timeFactor}, time scale ${TIME_SCALE})`); + await rig.enqueueMix(spec.calls, { rampMs: (sp.rampS ?? 0) * 1000 }); + rig.note(`${spec.calls} calls queued${sp.rampS ? ` over ${sp.rampS} s` : ""} (harness delay factor ${spec.timeFactor}, time scale ${scale})`); const during = sp.during ? sp.during(rig).catch((e) => rig.note(`scenario step failed: ${e.message}`)) : Promise.resolve(); const drained = await rig.waitDrained(spec.maxMin * 60_000); await during; @@ -65,15 +80,29 @@ async function run(key) { } } +/** Runs scenario `key` in a child process (its own time scale) and returns its result. */ +async function runApart(key) { + const out = join(opt("dir", tmpdir()), `result-${key}-${process.pid}.json`); + const args = argv.filter((a, i) => a !== which || argv[i - 1]?.startsWith("--")); + const code = await new Promise((r) => spawn(process.execPath, [process.argv[1], key, ...args, "--result", out], { stdio: ["ignore", "inherit", "inherit"] }).on("close", r)); + try { return JSON.parse(readFileSync(out, "utf8")); } catch { return { key, lines: [`== scenario-${key}: the run ended without a result (exit ${code})`], checks: [{ ok: false, name: "the scenario ran", detail: `exit ${code}` }], dir: "" }; } +} + +const started = Date.now(); const keys = which === "all" ? ["1", "2", "3", "4", "5", "6"] : [which]; if (!keys.every((k) => SCENARIOS[k])) { console.error(`unknown scenario ${which}; use smoke, 1-6 or all`); process.exit(64); } const results = []; -if (which === "all" && !flag("sequential")) { - results.push(...await Promise.all(keys.slice(0, 5).map((k) => run(k)))); - results.push(await run("6")); -} else for (const k of keys) results.push(await run(k)); +// Scenarios at another scale than the rest run apart; the rest share this process. +const apart = which === "all" ? keys.filter((k) => scaleOf(k) !== TIME_SCALE) : []; +const here = keys.filter((k) => !apart.includes(k)); +if (which === "all" && !flag("sequential")) results.push(...await Promise.all(here.filter((k) => k !== "6").map((k) => run(k))), ...(here.includes("6") ? [await run("6")] : [])); +else for (const k of here) results.push(await run(k)); +for (const k of apart) results.push(await runApart(k)); +results.sort((a, b) => a.key.localeCompare(b.key)); +if (opt("result")) { writeFileSync(opt("result"), JSON.stringify(results[0])); process.exit(0); } console.log("\n==================== acceptance ===================="); for (const r of results) console.log(`${r.lines.join("\n")}\n(files: ${r.dir})\n`); const fails = results.flatMap((r) => r.checks.filter((c) => !c.ok).map((c) => `scenario ${r.key}: ${c.name}`)); console.log(fails.length ? `FAILED ${fails.length}:\n ${fails.join("\n ")}` : "ALL PASSED"); +console.log(`run time ${Math.round((Date.now() - started) / 1000)} s`); process.exit(fails.length ? 1 : 0); diff --git a/src/remote/calls.ts b/src/remote/calls.ts index 0384fa47..1856b480 100644 --- a/src/remote/calls.ts +++ b/src/remote/calls.ts @@ -404,11 +404,27 @@ type Parsed = Pick<Cand, "refs" | "repos" | "authors">; const parsedCalls = new WeakMap<DatabaseSync, Map<number, Parsed>>(); /** Drops the cached queue order: a call was queued or leased by this process. Other processes' changes show in the signature (count and newest id of the queued calls) or within QUEUE_CACHE_MS. */ const dropQueueCache = (db: DatabaseSync): void => void queueCaches.delete(db); +/** The signature of the queued calls as queuedCalls reads it from the table: their count and newest id. */ +const queueSig = (n: number, m: number | null): string => `${n}:${m}`; +/** + * Takes a call this process just leased out of the cached queue order, so a burst of claims does not rebuild the order + * after every lease; the signature follows, so the cache stays valid while no other process changed the queue. + */ +function takeFromQueueCache(db: DatabaseSync, id: number): void { + const c = queueCaches.get(db); + if (!c) return; + const drop = (l: Cand[]): boolean => { const i = l.findIndex((r) => r.id === id); if (i >= 0) l.splice(i, 1); return i >= 0; }; + if (!drop(c.followUps) && !drop(c.ordered)) return dropQueueCache(db); + let m: number | null = null; + for (const r of c.followUps) if (m === null || r.id > m) m = r.id; + for (const r of c.ordered) if (m === null || r.id > m) m = r.id; + c.sig = queueSig(c.followUps.length + c.ordered.length, m); +} -/** Every queued call, read once per QUEUE_CACHE_MS: follow-ups by age, the rest in queue order. Callers filter it and must not change it. */ +/** Every queued call, read once per QUEUE_CACHE_MS: follow-ups by age, the rest in queue order. Callers filter it and must not change it; only takeFromQueueCache does. */ function queuedCalls(db: DatabaseSync, nowMs: number): QueueCache { const q = db.prepare("SELECT COUNT(*) AS n, MAX(id) AS m FROM main.remote_calls WHERE state = 'queued'").get() as { n: number; m: number | null }; - const sig = `${q.n}:${q.m}`; + const sig = queueSig(Number(q.n), q.m === null ? null : Number(q.m)); const hit = queueCaches.get(db); if (hit && hit.sig === sig && nowMs >= hit.at && nowMs - hit.at < QUEUE_CACHE_MS) return hit; const known = parsedCalls.get(db) ?? new Map<number, Parsed>(), seen = new Map<number, Parsed>(); @@ -542,7 +558,7 @@ async function claimNew(db: DatabaseSync, caller: Caller, claim: Claim, canWrite continue; } if (!lease) continue; - dropQueueCache(db); + takeFromQueueCache(db, Number(r.id)); // The fast lane says nothing about the helper's other slots: only their claims mark it idle or busy. if (!fast) db.prepare("UPDATE main.mcp_tokens SET idle_claim_at = NULL WHERE id = ?").run(caller.tokenId); return { lease, reserve: userReserve(db, caller.login) };