/** * Forge-store housekeeping — the job directories under `.bitmagic/forge` that * nothing will read again are removed once a forge has landed. * * Every edit is a NEW job and the level keeps only its newest job's id, so a * level edited a dozen times leaves a dozen finished job directories behind * (dev-games/alien held 13, 6 MB, after one afternoon). A job is kept while * anything could still want it: * * - an asset of the world names it as its forge job (`parentForgeJobId`, the * same reading `--edit` uses) — that is the parent an edit reuses bakes from; * - it is the job that just ran; * - it never finished (no `persisted` record) — an unfinished job is what * `--resume` continues, and its local bakes are the progress a resume keeps. * * The server's copy of every job is untouched: it is what a resume or an edit * from another machine reads, and its lifetime is the server's call. The * resolution is pure over world.json and a listing, so the rules are testable * without a project on disk; the removal is best-effort, since a directory * that will not delete must never fail a forge that has already landed. */ import { type JsonObject } from '../project/world-json.js'; export interface ForgeJobDir { jobId: string; /** The job wrote its `persisted` record: world.json has what it built. */ finished: boolean; } /** The job ids the world's assets name — the jobs an edit could reuse bakes from. */ export declare function referencedForgeJobs(world: JsonObject): Set; /** Of `jobs`, the finished ones neither the world nor `keep` refers to, in listing order. */ export declare function staleForgeJobs(world: JsonObject, jobs: ReadonlyArray, keep: ReadonlyArray): string[]; /** `/.bitmagic/forge/worlds/v3/forged-work` — the store's job directories, by the shared key layout. */ export declare function forgeJobsDir(projectRoot: string): string; /** The store's job directories, finished or not; an absent store lists nothing. */ export declare function listForgeJobDirs(projectRoot: string): ForgeJobDir[]; /** * Remove the finished jobs the project no longer refers to. One line when * something was removed, a warning when something would not go; silent otherwise. */ export declare function pruneForgeStore(options: { projectRoot: string; world: JsonObject; /** Jobs to keep whatever the world says — the one that just ran. */ keep: ReadonlyArray; log: (message: string) => void; }): string[];