export interface MaterializeReleaseOptions { /** Root of the built checkout (must contain dist/, package.json, lockfile). * Defaults to the repo root inferred from this module's own location. */ checkoutDir?: string; /** Directory releases are materialized under. Defaults to * `/releases` (i.e. %LOCALAPPDATA%\Astramem\releases). */ releasesRoot?: string; /** Node binary used for the boot-verify probe. Defaults to * `process.execPath` — matches install-flow.ts's shim pointer, which uses * the same value as the daemon's own launch binary. */ nodeBin?: string; /** Lockfile filename to copy + pass to `--frozen-lockfile`. Defaults to * 'bun.lock' (this repo's lockfile; overridable for tests/fixtures). */ lockfileName?: string; } export interface ReleaseManifest { /** `${pkgversion}+${gitsha}` — also the final directory's basename. NOT a * reliable content identity on its own: `gitsha` is only as fresh as the * last commit, so an uncommitted change (a bumped SCHEMA_VERSION, a new * migration file, ...) leaves `id` unchanged even though the build output * has changed. `contentHash` below is the actual identity check — see * computeContentHash. */ id: string; pkgversion: string; gitsha: string; /** ISO-8601 timestamp of materialization. */ createdAt: string; /** `process.version` of the machine that ran materialization. */ nodeVersion: string; /** sha256 over dist/ + migrations/ + package.json + the lockfile (see * computeContentHash). This — not `id` — is what materializeRelease's * reuse-vs-rebuild decision below trusts: two materializations can share * an `id` (same pkgversion+gitsha) while genuinely differing in content * whenever the checkout was dirty at build time (the 2026-07-13 * stale-release-dir incident: an uncommitted migration + SCHEMA_VERSION * bump kept shipping the old build because the id never moved). Optional * on read because release.json files materialized before this field * existed won't have it — see the reuse check, which treats a missing * hash as "cannot prove this is safe to reuse" rather than trusting it. */ contentHash?: string; } export interface MaterializeReleaseResult { releaseDir: string; manifest: ReleaseManifest; /** How `releaseDir` was produced: * - 'fresh' — no release with this id existed yet. * - 'reused' — a release with this id already existed, its entry * boot-verified correctly, AND its contentHash matched the * just-built tmp dir's — genuinely the same build, safe to * reuse without rewriting anything. * - 'rebuilt' — a release with this id already existed but was rejected * (failed boot-verify, i.e. corruption; OR its contentHash * didn't match — same id, different content, e.g. an * uncommitted change). The fresh, already boot-verified tmp * build was promoted in its place. See `rebuiltReason`. */ outcome: 'fresh' | 'reused' | 'rebuilt'; /** Populated only when outcome === 'rebuilt' — the evidence that made the * existing dir untrustworthy. Callers (reinstall.ts) MUST surface this to * the operator: a same-id rebuild is exactly the kind of event that used * to be invisible (FEAT-486). */ rebuiltReason?: string; } /** Default root releases are materialized under / read from: * `/releases` (i.e. %LOCALAPPDATA%\Astramem\releases). * Single-sourced here so materializeRelease/listReleases/pruneReleases and * callers (reinstall.ts, doctor) never drift on the path. */ export declare function defaultReleasesRoot(): string; /** * Given a shim pointer's `entryJs` (e.g. * `\1.2.3+abcdef\dist\cli\index.js`), extract the release id * (`1.2.3+abcdef`) if it lives under `releasesRoot` — else `null` (e.g. a * `--dev`-pinned pointer at the mutable checkout's `dist/`, which is not * under releasesRoot at all). Used by `reinstall --rollback` (AC-3) and the * doctor pointer check (AC-4) to identify "the release currently pointed * at" without assuming the pointer is release-pinned. */ export declare function releaseIdFromEntryJs(entryJs: string, releasesRoot?: string): string | null; /** The install command materializeRelease should use, resolved at call time. */ interface InstallCommand { cmd: string; args: string[]; /** npm on win32 is `npm.cmd` — spawnSync needs shell:true to resolve it. A * resolved absolute bun path needs no shell. */ shell: boolean; kind: 'bun' | 'npm'; } /** * Resolve the package-manager command for materializeRelease's production * install (issue #305). Prefers a RUNNABLE bun so `--frozen-lockfile` gives a * deterministic install off the copied `bun.lock`; falls back to * `npm install --omit=dev` when no bun on this box actually executes (a * common Windows state: `bun` on PATH is only an npm shim, or `~/.bun/bin` * isn't on the service's inherited PATH). Candidate order: `$BUN_INSTALL/bin`, * `~/.bun/bin`, then bare `bun` (PATH). npm has no frozen-lock equivalent here * (we copy bun.lock, not package-lock.json), so the fallback does a fresh * production resolve from package.json — noted at the call site. */ export declare function resolveInstallCommand(): InstallCommand; export declare function materializeRelease(opts?: MaterializeReleaseOptions): MaterializeReleaseResult; export interface ReleaseListEntry { id: string; dir: string; createdAt: string; } export interface PruneReleasesResult { /** Release ids that were deleted. A delete that failed is still recorded * here (soft-fail — see pruneReleases doc), annotated with the error so * the caller can surface it without the run itself throwing. */ pruned: string[]; /** Release ids retained (newest `keep` + anything in `protectIds`). */ kept: string[]; } /** * List materialized releases under `releasesRoot`, NEWEST-first (by * `manifest.createdAt`, tie-broken by id descending for determinism). * * Skips anything that isn't a genuine, currently-valid release: in-progress * (`.tmp-*`) and quarantined (`*.failed`) dirs (materializeRelease's own * naming — see module header), non-directories, and any dir whose * `release.json` is missing or fails to parse. A corrupted/partial release * must never crash listing (retention and rollback both depend on this being * safe to call unconditionally) — it just becomes invisible to both, the * same "skip, don't throw" posture materializeRelease itself uses whenever it * discovers a stale on-disk artifact. */ export declare function listReleases(releasesRoot?: string): ReleaseListEntry[]; /** * Prune old releases, keeping the newest `keep` (default 2) PLUS any id * listed in `protectIds` — the caller MUST pass the currently-pointed-at * release's id there even if it's older than the retention window, so a * repoint never leaves current.json pointing at a directory this function * just deleted (the exact bug class AC-3 exists to prevent). * * Deletion is best-effort per directory: a failed `rmSync` is recorded in * the returned `pruned` list (annotated with the error) rather than thrown — * retention is a soft cleanup step, never something that should abort a * reinstall that otherwise succeeded. */ export declare function pruneReleases(releasesRoot?: string, keep?: number, protectIds?: string[]): PruneReleasesResult; export {};