/** * Schema-version read policy — the two directions, named so the choice is * unmissable at the call site. * * State written by an older version of the tool is read back under the CURRENT * version's semantics. A reader that never compares the stamped version (spelled * `schema_version` on artifacts, `contract_version` on contracts — both are read * here) silently reinterprets old bytes as new-shape data. Stamping a version on * WRITE and not comparing it on READ is therefore not "versioned" at all — it is * an unchecked cast wearing a version field. * * There are exactly two correct policies, and which one applies is a property * of the STATE, not of the module: * * - **Regenerable state** (a cache, a carry, a snapshot, a derived index — * anything the pipeline can rebuild from its inputs at the cost of some * recompute): a mismatch means TREAT AS ABSENT and rebuild. Throwing here * would strand a run on a file it is perfectly able to reproduce. * → {@link discardOnSchemaVersionMismatch} * * - **Costly / authored state** (an operator confirmation, a checkpoint, a * human- or LLM-authored artifact — anything that cannot be recreated * without redoing work or asking a person again): a mismatch means THROW. * Silently discarding it would destroy work and read as "not done yet". * → {@link throwOnSchemaVersionMismatch} * * Both treat an ABSENT payload (`undefined`/`null`) as absent, not as a * mismatch — "not written yet" is a normal state on a fresh run and is the * caller's own fail-shape (`?? {}`, `?? null`, `if (!x)`) to express. */ /** * Thrown when costly/authored state is loaded with a `schema_version` that does * not match the expected version constant. The message names the artifact and * both versions so the operator has an actionable diagnosis. */ export declare class SchemaVersionMismatchError extends Error { readonly artifactName: string; readonly expected: string; readonly actual: string; constructor(artifactName: string, expected: string, actual: string); } /** * REGENERABLE state: return the payload only when its stamped `schema_version` * equals `expected`; otherwise `undefined` — i.e. treat a stale (or unstamped, * or non-string-stamped) payload exactly as if the file were not there, so the * caller's existing absent-path rebuilds it. * * Use for caches, carries, snapshots and derived indexes. For state that cannot * be rebuilt, use {@link throwOnSchemaVersionMismatch} instead. */ export declare function discardOnSchemaVersionMismatch(value: T | undefined | null, expected: string): T | undefined; /** * COSTLY / AUTHORED state: throw {@link SchemaVersionMismatchError} when the * stamped `schema_version` is missing, non-string, or not equal to `expected`. * Returns silently for an absent payload (`undefined`/`null`) — a not-yet- * produced artifact is not a mismatch. * * Use for operator confirmations, checkpoints and authored artifacts, whose * silent loss would destroy work. For rebuildable state, use * {@link discardOnSchemaVersionMismatch} instead. */ export declare function throwOnSchemaVersionMismatch(value: object | undefined | null, artifactName: string, expected: string): void; //# sourceMappingURL=schemaVersion.d.ts.map