import { type NodeRuntimeRef, type ReleaseRef } from "./release-ref.js"; import type { RestartDatabaseSnapshot } from "./database/restart-snapshot.js"; import { type SharedHomeRef, SharedReleaseStore } from "./shared-release-store.js"; export declare const HOME_RELEASE_STATE_SCHEMA_VERSION = 2; export interface UnresolvedLegacyRelease { runtimePath: string; reason: string; } export interface HomeReleaseState { schemaVersion: typeof HOME_RELEASE_STATE_SCHEMA_VERSION; current?: ReleaseRef; rejectedRecommendation?: RejectedRecommendation; unresolvedLegacy?: UnresolvedLegacyRelease[]; firstSharedSuccessAt?: string; sharedSuccessfulStarts?: number; transaction?: HomeReleaseTransaction; } export interface HomeReleaseTransaction { transactionId: string; phase: "activating"; candidate: ReleaseRef; rollbackCurrent?: ReleaseRef; ownerPid?: number; ownerStartMarker?: string; databaseSnapshot?: RestartDatabaseSnapshot; } export interface RejectedRecommendation { generation: number; artifactId: string; failedAt: string; reason?: string; } interface HomeReleaseStateV2 { schemaVersion: typeof HOME_RELEASE_STATE_SCHEMA_VERSION; current?: ReleaseRef; previous?: ReleaseRef; lastKnownGood?: ReleaseRef; unresolvedLegacy?: UnresolvedLegacyRelease[]; firstSharedSuccessAt?: string; sharedSuccessfulStarts?: number; transaction?: { transactionId: string; phase: "activating"; candidate: ReleaseRef; rollback: { current?: ReleaseRef; previous?: ReleaseRef; lastKnownGood?: ReleaseRef; }; ownerPid?: number; ownerStartMarker?: string; databaseSnapshot?: RestartDatabaseSnapshot; }; } export interface LegacyMigrationRuntime { runtimePath: string; node: NodeRuntimeRef; } export declare class HomeReleaseStore { readonly niubotHome: string; readonly sharedStore: SharedReleaseStore; readonly runtimeDirectory: string; readonly stateFile: string; readonly homeId: string; constructor(niubotHome: string, sharedStore: SharedReleaseStore); readState(): HomeReleaseState; stateExistsRecovering(): boolean; readStateStrict(options?: { persistMigration?: boolean; }): HomeReleaseState; readOrMigrateLegacy(node: NodeRuntimeRef, running?: LegacyMigrationRuntime, verify?: (runtimePath: string, node: NodeRuntimeRef) => boolean): HomeReleaseState; migrateLegacyState(node: NodeRuntimeRef, running?: LegacyMigrationRuntime, verify?: (runtimePath: string, node: NodeRuntimeRef) => boolean): HomeReleaseState | undefined; reconcileInterruptedTransaction(state?: HomeReleaseState): HomeReleaseState; transactionOwnerIsActive(transaction: HomeReleaseTransaction): boolean; assertTransactionSnapshotContained(snapshot: RestartDatabaseSnapshot): void; writeState(input: HomeReleaseState | HomeReleaseStateV2): void; resolveRuntime(ref: ReleaseRef, verifyTree?: boolean): string; releaseRefForRuntimePath(runtimePath: string, node: NodeRuntimeRef): ReleaseRef | undefined; discoverUnresolvedLegacy(excludeRuntimePaths?: string[]): UnresolvedLegacyRelease[]; commitHealthy(ref: ReleaseRef): HomeReleaseState; /** * Commit the first runtime only after that runtime has completed normal * Engine startup. The launcher deliberately leaves an empty home unbound * until this method runs, so a broken imported package can never become the * persisted current merely because its files were copied successfully. */ commitInitialHealthy(ref: ReleaseRef): HomeReleaseState; recordRejectedRecommendation(generation: number, release: ReleaseRef & { storage: "shared"; }, reason?: string): HomeReleaseState; /** * Replace storage references after an installed legacy tree has been copied * byte-for-byte into the shared store. This is a storage migration, not a * version activation: slot meaning and ordering must remain unchanged. */ replaceEquivalentRelease(expected: ReleaseRef, replacement: ReleaseRef): HomeReleaseState; writeSharedRef(options?: { state?: HomeReleaseState; pending?: SharedHomeRef["pending"]; rollback?: ReleaseRef[]; runtimePath?: string; }): void; private assertResolvableRef; private assertNodeRuntime; private assertLegacyRuntimePath; private migrateV2State; private normalizeV2State; } export declare function isHomeReleaseState(value: unknown): value is HomeReleaseState; export {};