import { n as OnDiskMigrationPackage, t as MigrationOps } from "../package-CWicKzNs.mjs"; import { t as MigrationMetadata } from "../metadata-DtStFLKa.mjs"; //#region src/hash.d.ts interface VerifyResult { readonly ok: boolean; readonly reason?: 'mismatch'; readonly storedHash: string; readonly computedHash: string; } /** * Content-addressed migration hash over (metadata envelope, ops). See * ADR 199 — Storage-only migration identity for the rationale: the * storage-hash bookends (`from`, `to`) inside the envelope anchor the * contract identity by hash. The full contract IRs are not part of the * manifest — they live in sibling `*-contract.json` files authored * alongside the migration, never inlined here. * * The integrity check is purely structural, not semantic. The function * canonicalizes its inputs via `sortKeys` (recursive) + `JSON.stringify` * and hashes the result. Target-specific operation payloads (`step.sql`, * Mongo's pipeline AST, …) are hashed verbatim — no per-target * normalization is required, because what's being verified is "do the * on-disk bytes still produce their recorded hash", not "do two * semantically-equivalent migrations hash the same". The latter is an * emit-drift concern (ADR 192 step 2). * * The symmetry across write and read holds because `JSON.parse( * JSON.stringify(x))` round-trips JSON-safe values losslessly and * `sortKeys` is idempotent and deterministic — write-time and read-time * canonicalization produce the same canonical bytes regardless of * source-side key ordering or whitespace. * * The `migrationHash` field on the metadata is stripped before hashing * so the function can be used both at write time (when no hash exists * yet) and at verify time (rehashing an already-attested record). */ declare function computeMigrationHash(metadata: Omit & { readonly migrationHash?: string; }, ops: MigrationOps): string; /** * Re-hash an in-memory migration package and compare against the stored * `migrationHash`. See `computeMigrationHash` for the canonicalization rules. * * Returns `{ ok: true }` when the package is internally consistent, or * `{ ok: false, reason: 'mismatch', storedHash, computedHash }` when it is * not — typically a sign of FS corruption, partial writes, or a post-emit * hand edit. */ declare function verifyMigrationHash(pkg: OnDiskMigrationPackage): VerifyResult; //#endregion export { type VerifyResult, computeMigrationHash, verifyMigrationHash }; //# sourceMappingURL=hash.d.mts.map