import { WeftError } from './weft-error.ts'; /** * Thrown by {@link Engine.create} (and other storage-opening entry points) when * a persisted Weft database's schema version does not match what the engine * requires — an older version, a newer one, an unparseable sentinel, or user * data present with no sentinel at all. Weft loads persisted data only at the * exact current schema version; it never reshapes a non-matching database in * place. Bumping {@link CURRENT_PERSISTED_DATA_SCHEMA_VERSION} intentionally * invalidates databases stamped with any other version so the failure surfaces * deterministically at boot, before any workflow attempts replay. * * Inspect `foundVersion` to see what the storage advertised and `expectedVersion` * to see what this engine requires. Resolve by deleting the database or by * starting from fresh storage. * * @example * ```ts * import { Engine, PersistedDataIncompatibleError } from '@lostgradient/weft'; * * try { * await Engine.create({}); * } catch (error) { * if (error instanceof PersistedDataIncompatibleError) { * console.error( * `expected schema ${error.expectedVersion}, found ${error.foundVersion ?? 'pre-versioned'}`, * ); * } * } * ``` */ export declare class PersistedDataIncompatibleError extends WeftError<'PersistedDataIncompatibleError'> { readonly foundVersion: number | null; readonly expectedVersion: number; constructor(foundVersion: number | null, expectedVersion: number); } /** * A durable record could not be decoded without risking data loss. * * @example * ```ts * import { PersistedDataCorruptError } from '@lostgradient/weft'; * declare const error: unknown; * if (error instanceof PersistedDataCorruptError) console.error(error.key); * ``` */ export declare class PersistedDataCorruptError extends WeftError<'PersistedDataCorruptError'> { readonly key: string; constructor(key: string); } /** * Bumped to `2` by the durable fleet-event feed hardening. Pre-MVP databases * have no version key recorded — `assertCompatiblePersistedDataVersion` treats * the absence of the key on an otherwise non-empty database as * `pre-versioned`, which is incompatible. Fresh databases get the current * version written on first open. */ export declare const CURRENT_PERSISTED_DATA_SCHEMA_VERSION = 2; /** * Storage key holding the persisted-data schema version (encoded as the UTF-8 * digits of an integer). Kept under a `weft:` prefix so it cannot collide with * the public `wf:` / `op:` / `schedule:` / etc. layouts in * `src/storage/interface.ts#KEYS`. */ export declare const PERSISTED_DATA_SCHEMA_VERSION_KEY = "weft:schema-version";