import { n as OnDiskMigrationPackage } from "./package-CWicKzNs.mjs"; import { n as MigrationGraph, t as MigrationEdge } from "./graph-bDjJ4GL9.mjs"; //#region src/migration-graph.d.ts declare function reconstructGraph(packages: readonly OnDiskMigrationPackage[]): MigrationGraph; /** * Find the shortest path from `fromHash` to `toHash` using BFS over the * contract-hash graph. Returns the ordered list of edges, or null if no path * exists. Returns an empty array when `fromHash === toHash` (no-op). * * Neighbor ordering is deterministic via the tie-break sort key: * createdAt → to → migrationHash. */ declare function findPath(graph: MigrationGraph, fromHash: string, toHash: string): readonly MigrationEdge[] | null; /** * Find the shortest path from `fromHash` to `toHash` whose edges collectively * cover every invariant in `required`. Returns `null` when no such path exists * (either `fromHash`→`toHash` is structurally unreachable, or every reachable * path leaves at least one required invariant uncovered). When `required` is * empty, delegates to `findPath` so the result is byte-identical for that case. * * Algorithm: BFS over `(node, coveredSubset)` states with state-level dedup. * The covered subset is a `Set` of invariant ids; the state's dedup * key is `${node}\0${[...covered].sort().join('\0')}`. State keys distinguish * distinct `(node, covered)` tuples regardless of node-name length because * `\0` cannot appear in any invariant id (validation rejects whitespace and * control chars at authoring time). * * Neighbour ordering when `required ≠ ∅`: edges covering ≥1 still-needed * invariant come first, with `createdAt → to → migrationHash` as the * secondary key. The heuristic steers BFS toward the satisfying path; * correctness (shortest, deterministic) does not depend on it. */ declare function findPathWithInvariants(graph: MigrationGraph, fromHash: string, toHash: string, required: ReadonlySet): readonly MigrationEdge[] | null; interface PathDecision { readonly selectedPath: readonly MigrationEdge[]; readonly fromHash: string; readonly toHash: string; readonly alternativeCount: number; readonly tieBreakReasons: readonly string[]; readonly refName?: string; /** The caller-supplied required invariant set, sorted ascending. */ readonly requiredInvariants: readonly string[]; /** * The subset of `requiredInvariants` actually covered by edges on * `selectedPath`. Always a subset of `requiredInvariants` (when the path * is satisfying, equal to it); always derived from `selectedPath`. */ readonly satisfiedInvariants: readonly string[]; } /** * Outcome of {@link findPathWithDecision}. The pathfinder distinguishes * three cases up front so callers don't re-derive structural reachability: * * - `ok` — a path covering `required` exists; `decision` carries the * selection metadata and per-edge invariants. * - `unreachable` — `from`→`to` has no structural path. Mapped by callers * to the existing no-path / `NO_TARGET` diagnostic. * - `unsatisfiable` — `from`→`to` is structurally reachable but no path * covers every required invariant. `structuralPath` is the * `findPath(graph, from, to)` result, included so callers don't have to * recompute it when raising `MIGRATION.NO_INVARIANT_PATH`. `missing` is * the subset of `required` that the structural path does *not* cover — * correctly accounts for partial coverage when some required invariants * are met by the fallback path. Only emitted when `required` is * non-empty. */ type FindPathOutcome = { readonly kind: 'ok'; readonly decision: PathDecision; } | { readonly kind: 'unreachable'; } | { readonly kind: 'unsatisfiable'; readonly structuralPath: readonly MigrationEdge[]; readonly missing: readonly string[]; }; /** * Routing context for {@link findPathWithDecision}. Both fields are optional; * `refName` is only used to decorate the resulting `PathDecision` for the * JSON envelope, and `required` defaults to an empty set (purely structural * routing). They are passed via a single options object so the call sites * cannot silently swap two adjacent string parameters. */ interface FindPathWithDecisionOptions { readonly refName?: string; readonly required?: ReadonlySet; } /** * Find the shortest path from `fromHash` to `toHash` and return structured * path-decision metadata for machine-readable output. When `required` is * non-empty, the returned path is the shortest one whose edges collectively * cover every required invariant. * * The discriminated return type tells the caller *why* a path could not be * found, so the CLI can pick the right structured error without re-running * a structural BFS. */ declare function findPathWithDecision(graph: MigrationGraph, fromHash: string, toHash: string, options?: FindPathWithDecisionOptions): FindPathOutcome; /** * Find all branch tips (nodes with no outgoing edges) reachable from * `fromHash` via forward edges. */ declare function findReachableLeaves(graph: MigrationGraph, fromHash: string): readonly string[]; /** * Find the target contract hash of the migration graph reachable from * EMPTY_CONTRACT_HASH. Returns `null` for a graph that has no target * state (either empty, or containing only the root with no outgoing * edges). Throws NO_INITIAL_MIGRATION if the graph has nodes but none * originate from the empty hash, and AMBIGUOUS_TARGET if multiple * branch tips exist. */ declare function findLeaf(graph: MigrationGraph): string | null; /** * Find the latest migration entry by traversing from EMPTY_CONTRACT_HASH * to the single target. Returns null for an empty graph. * Throws AMBIGUOUS_TARGET if the graph has multiple branch tips. */ declare function findLatestMigration(graph: MigrationGraph): MigrationEdge | null; declare function detectCycles(graph: MigrationGraph): readonly string[][]; declare function detectOrphans(graph: MigrationGraph): readonly MigrationEdge[]; //#endregion export { findLeaf as a, findPathWithInvariants as c, findLatestMigration as i, findReachableLeaves as l, detectCycles as n, findPath as o, detectOrphans as r, findPathWithDecision as s, PathDecision as t, reconstructGraph as u }; //# sourceMappingURL=migration-graph-BJpeTOuY.d.mts.map