// "Boot idle": start the server WITHOUT resuming any of the long-running work // a previous process was doing. // // editor/instrumentation.ts arms four things on every boot — the sync heartbeat, // the auto-queue runners, the digest sweep and the backfill sweep. That is right // for a host install, where a restart is an interruption of work you own. It is // wrong the first time a CONTAINER is pointed at a corpus somebody else built: // the policies stored in that corpus's settings.json say "yes, sweep", and the // container obliges by starting GPU-weeks of work seconds after `docker compose // up`, before the operator has seen a single page. // // So: an env switch, read once at boot. Unset (the host default) keeps the old // behavior exactly. See RUNNING_IN_DOCKER.md. // // Deliberately dependency-free — instrumentation.ts is bundled for the Edge // runtime as well as Node, and every import it makes is lazy for that reason. // This module imports nothing and touches no Node API, so it is safe to import // statically from there. export const IDLE_BOOT_ENV = "ARCHILYZER_IDLE_BOOT"; // Values that mean "yes". Anything else — including the empty string a compose // file writes for an unset variable — means "no", so a half-configured .env // cannot silently disable the runners. const TRUTHY = new Set(["1", "true", "yes", "on"]); // True when this process should skip arming the boot-time runners. export function isIdleBoot( env: Record = process.env, ): boolean { const raw = env[IDLE_BOOT_ENV]; if (typeof raw !== "string") return false; return TRUTHY.has(raw.trim().toLowerCase()); }