/** * `@sylphx/management/adminBuilds` — operator recovery for stuck builds. * * Mirrors `POST /admin/builds/reap` in * `apps/api/src/server/platform/routes/admin/builds.ts`. Replaces the raw * `UPDATE build_records SET status='failed' …` historically run from psql * per `docs/runbooks/build-records-stuck-in-building.md`. * * Typical use: an on-call engineer mints a service token scoped to * `platform:builds:reap`, points the CLI (`sylphx admin builds reap`) at * the cluster, and the CLI calls `reap()` here. CI / cron / dashboards * call this SDK directly. * * The API does NOT touch `build_records` rows whose `started_at IS NULL` * (a different failure mode — queue starvation). */ import type { Client } from './client.js'; export interface ReapBuildsInput { /** * Window grammar `^[0-9]+(s|m|h|d)$`. Examples: `30m`, `2h`, `1d`. Rows * whose `started_at < NOW() - olderThan` are in the candidate set. */ readonly olderThan: string; /** * When true, returns the candidate set without mutating anything. * `reason` becomes optional in this mode. */ readonly dryRun?: boolean; /** * Required on the write path (min 3 chars). Goes verbatim into the * audit row + into each reaped row's `failure_reason` column (prefixed * `admin reap: `). Surfaced to the affected customer in Console. */ readonly reason?: string; /** * OPS-7 fold-in. When provided, restricts the candidate set to rows * whose `image_digest = ` AND additionally NULLs the column on * each reaped row. Format: `sha256:<64hex>`. */ readonly imageDigest?: string; } export interface ReapBuildsRecord { /** TypeID (`bld_xxx`). */ readonly id: string; /** TypeID (`proj_xxx`). */ readonly projectId: string; /** TypeID (`env_xxx`). */ readonly envId: string; /** ISO-8601. */ readonly startedAt: string; /** Wall-clock age at reap time. Floored to whole seconds. */ readonly ageSeconds: number; } export interface ReapBuildsResult { /** Echo of the request flag. */ readonly dryRun: boolean; /** Rows transitioned (`0` on dry-run). */ readonly reaped: number; /** Rows whose stale `image_digest` was additionally cleared. */ readonly digestCleared: number; /** Up to 1000 rows from the candidate set / write set. */ readonly records: ReadonlyArray; } /** * Reap stuck `build_records` rows older than `input.olderThan`. Single * UPDATE statement on the write path; SELECT only on `dryRun=true`. * * Idempotent: re-running with the same window flips zero rows because the * first call already moved them out of `'building'`. */ export declare const reap: (client: Client, input: ReapBuildsInput) => Promise; //# sourceMappingURL=adminBuilds.d.ts.map