@prisma/orm-toolchain 8.0.0-rc.11-dev.39 → 8.0.0-rc.11-dev.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/{aggregate-DKBycuzO.d.mts → aggregate-BxeUZtei.d.mts} +14 -4
  2. package/dist/aggregate-BxeUZtei.d.mts.map +1 -0
  3. package/dist/{aggregate-DI9VS7yL.mjs → aggregate-DqY54LCk.mjs} +43 -31
  4. package/dist/aggregate-DqY54LCk.mjs.map +1 -0
  5. package/dist/cli.mjs +87 -32
  6. package/dist/cli.mjs.map +1 -1
  7. package/dist/cli__control-api.d.mts +75 -6
  8. package/dist/cli__control-api.d.mts.map +1 -1
  9. package/dist/cli__control-api.mjs +1 -1
  10. package/dist/cli__control-api__testing.d.mts +1 -1
  11. package/dist/cli__migration-cli.mjs +2 -2
  12. package/dist/contract-snapshot-store-Bok5nQYi-D3g_P7im.d.mts +59 -0
  13. package/dist/contract-snapshot-store-Bok5nQYi-D3g_P7im.d.mts.map +1 -0
  14. package/dist/{contract-snapshot-store-D-mFkiHR-CFl0ulR2.mjs → contract-snapshot-store-CM9ubenX-o8kTVHxP.mjs} +48 -11
  15. package/dist/contract-snapshot-store-CM9ubenX-o8kTVHxP.mjs.map +1 -0
  16. package/dist/contract-snapshot-store-DrIwu5pn.d.mts +2 -0
  17. package/dist/{db-verify-BdKY7U7l-6VLIVuKF.d.mts → db-verify-BkwsVjIf-CDWnVSjr.d.mts} +6 -2
  18. package/dist/db-verify-BkwsVjIf-CDWnVSjr.d.mts.map +1 -0
  19. package/dist/{errors-SoLLYLtw-DMxVbVs9.mjs → errors-BIroGS9E-Dg6CF-dm.mjs} +15 -3
  20. package/dist/{errors-SoLLYLtw-DMxVbVs9.mjs.map → errors-BIroGS9E-Dg6CF-dm.mjs.map} +1 -1
  21. package/dist/{graph-membership-DY1Onbc3-CwBd6wuB.mjs → graph-membership-CdU6royq-gP9Kb9Eh.mjs} +3 -3
  22. package/dist/{graph-membership-DY1Onbc3-CwBd6wuB.mjs.map → graph-membership-CdU6royq-gP9Kb9Eh.mjs.map} +1 -1
  23. package/dist/{hash-DH8hl5Rq-BpM2t3Nu.mjs → hash-BAZVWU4a-BdynTmar.mjs} +24 -3
  24. package/dist/hash-BAZVWU4a-BdynTmar.mjs.map +1 -0
  25. package/dist/hash-CwWGlFWV.d.mts +1 -0
  26. package/dist/{hash-XZYYKJ-i.d.mts → hash-DclMqd7S-WBvXJ_4C.d.mts} +17 -4
  27. package/dist/hash-DclMqd7S-WBvXJ_4C.d.mts.map +1 -0
  28. package/dist/{invariants-Cww4bv0v-BEiFxmbX.mjs → invariants-CUbFGAse-DqgE4fhO.mjs} +3 -3
  29. package/dist/{invariants-Cww4bv0v-BEiFxmbX.mjs.map → invariants-CUbFGAse-DqgE4fhO.mjs.map} +1 -1
  30. package/dist/{io-DSQXOfBH-GRpmFG2F.mjs → io-CyV6U3am-CMJIi_UO.mjs} +7 -7
  31. package/dist/io-CyV6U3am-CMJIi_UO.mjs.map +1 -0
  32. package/dist/io-D8Epu7iY.d.mts +1 -0
  33. package/dist/{io-sr4CO9_t-C3eV_kn-.d.mts → io-DZfMV51z-BKlH5Dhb.d.mts} +9 -2
  34. package/dist/io-DZfMV51z-BKlH5Dhb.d.mts.map +1 -0
  35. package/dist/{migration-B9w-7dKe.mjs → migration-D95UJ0Dj.mjs} +4 -4
  36. package/dist/{migration-B9w-7dKe.mjs.map → migration-D95UJ0Dj.mjs.map} +1 -1
  37. package/dist/{migration-graph-CW4bMmTz-B5xFtFVB.mjs → migration-graph-BBWEuNAt-C6X6rauo.mjs} +3 -3
  38. package/dist/{migration-graph-CW4bMmTz-B5xFtFVB.mjs.map → migration-graph-BBWEuNAt-C6X6rauo.mjs.map} +1 -1
  39. package/dist/{migration-graph-Dqndu0i5.d.mts → migration-graph-CHhNBJSJ.d.mts} +2 -2
  40. package/dist/{migration-graph-Dqndu0i5.d.mts.map → migration-graph-CHhNBJSJ.d.mts.map} +1 -1
  41. package/dist/{migration-graph-tarTxJ99-BrGBANeE.d.mts → migration-graph-tarTxJ99-2GNs0O8U.d.mts} +2 -2
  42. package/dist/{migration-graph-tarTxJ99-BrGBANeE.d.mts.map → migration-graph-tarTxJ99-2GNs0O8U.d.mts.map} +1 -1
  43. package/dist/migration-tools.d.mts +12 -10
  44. package/dist/migration-tools.mjs +14 -14
  45. package/dist/migration-tools__aggregate.d.mts +1 -1
  46. package/dist/migration-tools__aggregate.mjs +1 -1
  47. package/dist/migration-tools__contract-snapshot-store.d.mts +4 -2
  48. package/dist/migration-tools__contract-snapshot-store.mjs +2 -2
  49. package/dist/migration-tools__errors.mjs +1 -1
  50. package/dist/migration-tools__hash.d.mts +2 -1
  51. package/dist/migration-tools__hash.mjs +1 -1
  52. package/dist/migration-tools__invariants.mjs +1 -1
  53. package/dist/migration-tools__io.d.mts +2 -2
  54. package/dist/migration-tools__io.mjs +1 -1
  55. package/dist/migration-tools__migration-graph.d.mts +2 -2
  56. package/dist/migration-tools__migration-graph.mjs +2 -2
  57. package/dist/migration-tools__migration.mjs +1 -1
  58. package/dist/migration-tools__ref-resolution.mjs +1 -1
  59. package/dist/migration-tools__refs.mjs +1 -1
  60. package/dist/migration-tools__spaces.mjs +2 -2
  61. package/dist/{ref-DlKsxbtg-B55l0TCq.mjs → ref-D5u8Xxwc-BjjqYtnQ.mjs} +212 -48
  62. package/dist/ref-D5u8Xxwc-BjjqYtnQ.mjs.map +1 -0
  63. package/dist/{ref-resolution-BWpwb8_b.mjs → ref-resolution-BwWLoU7C.mjs} +2 -2
  64. package/dist/{ref-resolution-BWpwb8_b.mjs.map → ref-resolution-BwWLoU7C.mjs.map} +1 -1
  65. package/dist/{refs-BpSpzdYB-BcDelHGt.mjs → refs-S0wu2JkI-BbFdehLe.mjs} +3 -3
  66. package/dist/{refs-BpSpzdYB-BcDelHGt.mjs.map → refs-S0wu2JkI-BbFdehLe.mjs.map} +1 -1
  67. package/dist/{spaces-DzFtKEl3.mjs → spaces--kxjIRHx.mjs} +14 -13
  68. package/dist/spaces--kxjIRHx.mjs.map +1 -0
  69. package/dist/{verify-contract-spaces-_vwt5LT0-BQAf8Q4T.mjs → verify-contract-spaces-BLkC9r9l-CJIppNL8.mjs} +4 -4
  70. package/dist/{verify-contract-spaces-_vwt5LT0-BQAf8Q4T.mjs.map → verify-contract-spaces-BLkC9r9l-CJIppNL8.mjs.map} +1 -1
  71. package/dist/vite-plugin-contract-emit.mjs +1 -1
  72. package/package.json +12 -12
  73. package/dist/aggregate-DI9VS7yL.mjs.map +0 -1
  74. package/dist/aggregate-DKBycuzO.d.mts.map +0 -1
  75. package/dist/contract-snapshot-store-BqDMcO4r.d.mts +0 -27
  76. package/dist/contract-snapshot-store-BqDMcO4r.d.mts.map +0 -1
  77. package/dist/contract-snapshot-store-D-mFkiHR-CFl0ulR2.mjs.map +0 -1
  78. package/dist/db-verify-BdKY7U7l-6VLIVuKF.d.mts.map +0 -1
  79. package/dist/hash-DH8hl5Rq-BpM2t3Nu.mjs.map +0 -1
  80. package/dist/hash-XZYYKJ-i.d.mts.map +0 -1
  81. package/dist/io-DSQXOfBH-GRpmFG2F.mjs.map +0 -1
  82. package/dist/io-DYfeLJxR.d.mts +0 -1
  83. package/dist/io-sr4CO9_t-C3eV_kn-.d.mts.map +0 -1
  84. package/dist/ref-DlKsxbtg-B55l0TCq.mjs.map +0 -1
  85. package/dist/spaces-DzFtKEl3.mjs.map +0 -1
@@ -1,18 +1,18 @@
1
1
  import { r as getEmittedArtifactPaths, t as emit } from "./exports-DI1kMms6--e9LdT9A.mjs";
2
- import { O as errorNoInvariantPath, P as errorUnknownInvariant, b as errorInvalidRefName, i as errorContractDeserializationFailed, t as MigrationToolsError } from "./errors-SoLLYLtw-DMxVbVs9.mjs";
3
- import { a as writeContractSnapshot, i as snapshotsImportPathFrom, n as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-D-mFkiHR-CFl0ulR2.mjs";
4
- import { n as verifyMigrationHash, t as computeMigrationHash } from "./hash-DH8hl5Rq-BpM2t3Nu.mjs";
5
- import { t as deriveProvidedInvariants } from "./invariants-Cww4bv0v-BEiFxmbX.mjs";
6
- import { i as materialiseExtensionMigrationPackageIfMissing, r as formatMigrationDirName, u as writeMigrationPackage } from "./io-DSQXOfBH-GRpmFG2F.mjs";
2
+ import { F as errorUnknownInvariant, i as errorContractDeserializationFailed, k as errorNoInvariantPath, t as MigrationToolsError, x as errorInvalidRefName } from "./errors-BIroGS9E-Dg6CF-dm.mjs";
3
+ import { r as verifyMigrationHash, t as computeMigrationHash } from "./hash-BAZVWU4a-BdynTmar.mjs";
4
+ import { a as snapshotsImportPathFrom, n as createSnapshotContentVerifier, o as writeContractSnapshot, r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-CM9ubenX-o8kTVHxP.mjs";
5
+ import { t as deriveProvidedInvariants } from "./invariants-CUbFGAse-DqgE4fhO.mjs";
6
+ import { i as materialiseExtensionMigrationPackageIfMissing, r as formatMigrationDirName, u as writeMigrationPackage } from "./io-CyV6U3am-CMJIi_UO.mjs";
7
7
  import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
8
- import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-DY1Onbc3-CwBd6wuB.mjs";
9
- import { a as findPath, o as findPathWithDecision, r as findLatestMigration } from "./migration-graph-CW4bMmTz-B5xFtFVB.mjs";
10
- import { d as writeRef, i as readRefs, l as validateRefName, n as deleteRef, o as refsByContractHash, t as HEAD_REF_NAME, u as validateRefValue } from "./refs-BpSpzdYB-BcDelHGt.mjs";
11
- import { a as isValidSpaceId, c as spaceMigrationDirectory, l as spaceRefsDirectory, o as listContractSpaceDirectories, s as readContractSpaceHeadRef, t as APP_SPACE_ID$1 } from "./verify-contract-spaces-_vwt5LT0-BQAf8Q4T.mjs";
12
- import { d as resolveRecordedPath, f as verifyMigration, l as planMigration, n as buildFabricatedMigrationEdge, r as collectAggregateNamespaces, s as loadContractSpaceAggregate, t as allStorageElementsExternal, u as requireHeadRef } from "./aggregate-DI9VS7yL.mjs";
13
- import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-DzFtKEl3.mjs";
8
+ import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-CdU6royq-gP9Kb9Eh.mjs";
9
+ import { a as findPath, o as findPathWithDecision, r as findLatestMigration } from "./migration-graph-BBWEuNAt-C6X6rauo.mjs";
10
+ import { d as writeRef, i as readRefs, l as validateRefName, n as deleteRef, o as refsByContractHash, t as HEAD_REF_NAME, u as validateRefValue } from "./refs-S0wu2JkI-BbFdehLe.mjs";
11
+ import { a as isValidSpaceId, c as spaceMigrationDirectory, l as spaceRefsDirectory, o as listContractSpaceDirectories, s as readContractSpaceHeadRef, t as APP_SPACE_ID$1 } from "./verify-contract-spaces-BLkC9r9l-CJIppNL8.mjs";
12
+ import { d as resolveRecordedPath, f as verifyMigration, l as planMigration, n as buildFabricatedMigrationEdge, r as collectAggregateNamespaces, s as loadContractSpaceAggregate, t as allStorageElementsExternal, u as requireHeadRef } from "./aggregate-DqY54LCk.mjs";
13
+ import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces--kxjIRHx.mjs";
14
14
  import { c as internalImportRoot, o as importRootForDependencies, r as createImportSpecifierResolver, t as ImportRootError } from "./import-roots-CCyOuQxb.mjs";
15
- import { n as parseContractRef, r as parseMigrationRef } from "./ref-resolution-BWpwb8_b.mjs";
15
+ import { n as parseContractRef, r as parseMigrationRef } from "./ref-resolution-BwWLoU7C.mjs";
16
16
  import { i as writeMigrationTs } from "./migration-ts-DdVm0rws.mjs";
17
17
  import { createRequire } from "node:module";
18
18
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
@@ -25,15 +25,15 @@ import { CliStructuredError, CliStructuredError as CliStructuredError$1, errorCo
25
25
  import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaSubjectClassifier, hasSchemaView } from "@prisma/orm-framework/components/control";
26
26
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
27
27
  import { mergeCapabilityMatrices } from "@prisma/orm-framework/components/components";
28
- import { errorConsentPlanMismatch, errorDestructiveChanges, errorHashMismatch, errorMarkerMissing, errorRunnerFailed, errorRuntime, errorTargetMismatch } from "@prisma/orm-framework/errors/execution";
28
+ import { ERROR_CODE_DESTRUCTIVE_CHANGES, errorConsentPlanMismatch, errorDestructiveChanges, errorHashMismatch, errorMarkerMissing, errorRunnerFailed, errorRuntime, errorTargetMismatch } from "@prisma/orm-framework/errors/execution";
29
29
  import "@prisma/orm-framework/errors/migration";
30
30
  import { basename, dirname, isAbsolute, join, relative, resolve } from "pathe";
31
- import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
32
31
  import { createHash } from "node:crypto";
33
32
  import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
33
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
34
34
  import { abortable } from "@prisma/orm-framework/utils/abortable";
35
35
  import { resolve as resolve$1 } from "node:path";
36
- //#region ../../../1-framework/3-tooling/cli/dist/ref-DlKsxbtg.mjs
36
+ //#region ../../../1-framework/3-tooling/cli/dist/ref-D5u8Xxwc.mjs
37
37
  /**
38
38
  * The typed remediation the CLI attaches to its own errors and findings.
39
39
  * Constructors live here rather than in any library the CLI calls: naming a
@@ -466,6 +466,23 @@ function assertFrameworkComponentsCompatible(expectedFamilyId, expectedTargetId,
466
466
  }
467
467
  return frameworkComponents;
468
468
  }
469
+ /**
470
+ * Build the per-command snapshot content verifier from the target
471
+ * serializer's `hashCanonicalizationHooks` — the hooks the family's emit
472
+ * pipeline computed the published storage hash with. The serializer's own
473
+ * `shouldPreserveEmpty` / `sortStorage` must NOT be used here: they govern
474
+ * on-disk serialization and may be broader per target (Postgres preserves
475
+ * required entity-kind fields at default values), so recomputing with them
476
+ * would reject untampered snapshots. A serializer that does not declare its
477
+ * hashing hooks (structural test stand-ins) reads without content
478
+ * verification. Build one verifier per command run and share it across
479
+ * every load, so each snapshot hash is recomputed at most once per run.
480
+ */
481
+ function snapshotVerifierFor(config) {
482
+ const hooks = config.target.contractSerializer?.hashCanonicalizationHooks;
483
+ if (hooks === void 0) return;
484
+ return createSnapshotContentVerifier(hooks);
485
+ }
469
486
  function isPlainObject(value) {
470
487
  return typeof value === "object" && value !== null && !Array.isArray(value);
471
488
  }
@@ -828,7 +845,8 @@ async function loadContractSpaceAggregateForCli(inputs) {
828
845
  return ok(await loadContractSpaceAggregate({
829
846
  migrationsDir: inputs.migrationsDir,
830
847
  deserializeContract: inputs.deserializeContract,
831
- appContract: inputs.appContract
848
+ appContract: inputs.appContract,
849
+ ...ifDefined("verifySnapshotContent", inputs.verifySnapshotContent)
832
850
  }));
833
851
  }
834
852
  /**
@@ -930,7 +948,8 @@ async function buildReadAggregate(config, options) {
930
948
  migrationsDir: options.migrationsDir,
931
949
  appContract: appContractForLoad,
932
950
  extensions: config.extensions ?? [],
933
- deserializeContract
951
+ deserializeContract,
952
+ ...ifDefined("verifySnapshotContent", options.verifySnapshotContent ?? snapshotVerifierFor(config))
934
953
  });
935
954
  if (!loaded.ok) return loaded;
936
955
  return ok({
@@ -1143,7 +1162,8 @@ async function executeRun(options) {
1143
1162
  migrationsDir,
1144
1163
  appContract: contract,
1145
1164
  extensions,
1146
- deserializeContract: (json) => familyInstance.deserializeContract(json)
1165
+ deserializeContract: (json) => familyInstance.deserializeContract(json),
1166
+ ...ifDefined("verifySnapshotContent", options.verifySnapshotContent)
1147
1167
  });
1148
1168
  if (!loaded.ok) throw loaded.failure;
1149
1169
  const aggregate = loaded.value;
@@ -1403,6 +1423,7 @@ async function executeDbInit(options) {
1403
1423
  extensions: options.extensions ?? [],
1404
1424
  policy: { allowedOperationClasses: ["additive"] },
1405
1425
  action: "dbInit",
1426
+ ...ifDefined("verifySnapshotContent", options.verifySnapshotContent),
1406
1427
  ...ifDefined("onProgress", options.onProgress)
1407
1428
  });
1408
1429
  }
@@ -1433,6 +1454,7 @@ async function executeDbUpdate(options) {
1433
1454
  extensions: options.extensions ?? [],
1434
1455
  policy: DB_UPDATE_POLICY,
1435
1456
  action: "dbUpdate",
1457
+ ...ifDefined("verifySnapshotContent", options.verifySnapshotContent),
1436
1458
  ...ifDefined("onProgress", options.onProgress)
1437
1459
  };
1438
1460
  if (options.mode === "apply" && !options.acceptDataLoss && options.consent === void 0) {
@@ -1543,7 +1565,8 @@ function buildLoadInputs(options) {
1543
1565
  migrationsDir: options.migrationsDir,
1544
1566
  appContract: options.contract,
1545
1567
  extensions: options.extensions,
1546
- deserializeContract: (json) => options.familyInstance.deserializeContract(json)
1568
+ deserializeContract: (json) => options.familyInstance.deserializeContract(json),
1569
+ ...ifDefined("verifySnapshotContent", options.verifySnapshotContent)
1547
1570
  };
1548
1571
  }
1549
1572
  async function runIntrospection(args) {
@@ -1722,7 +1745,8 @@ async function executeMigrate(options) {
1722
1745
  migrationsDir,
1723
1746
  appContract: contract,
1724
1747
  extensions,
1725
- deserializeContract: (json) => familyInstance.deserializeContract(json)
1748
+ deserializeContract: (json) => familyInstance.deserializeContract(json),
1749
+ ...ifDefined("verifySnapshotContent", options.verifySnapshotContent)
1726
1750
  });
1727
1751
  if (!loaded.ok) throw loaded.failure;
1728
1752
  const aggregate = loaded.value;
@@ -2079,9 +2103,12 @@ var ControlClientImpl = class {
2079
2103
  frameworkComponents = null;
2080
2104
  initialized = false;
2081
2105
  defaultConnection;
2106
+ /** One per client so the verified-hash memo spans operations (e.g. db update's pre-plan + consented apply). */
2107
+ snapshotVerifier;
2082
2108
  constructor(options) {
2083
2109
  this.options = options;
2084
2110
  this.defaultConnection = options.connection;
2111
+ this.snapshotVerifier = snapshotVerifierFor(options);
2085
2112
  }
2086
2113
  init() {
2087
2114
  if (this.initialized) return;
@@ -2310,6 +2337,7 @@ var ControlClientImpl = class {
2310
2337
  migrationsDir: options.migrationsDir,
2311
2338
  targetId: this.options.target.targetId,
2312
2339
  extensions: this.options.extensions ?? [],
2340
+ ...ifDefined("verifySnapshotContent", this.snapshotVerifier),
2313
2341
  ...ifDefined("onProgress", onProgress)
2314
2342
  });
2315
2343
  }
@@ -2338,6 +2366,7 @@ var ControlClientImpl = class {
2338
2366
  extensions: this.options.extensions ?? [],
2339
2367
  ...ifDefined("acceptDataLoss", options.acceptDataLoss),
2340
2368
  ...ifDefined("consent", options.consent),
2369
+ ...ifDefined("verifySnapshotContent", this.snapshotVerifier),
2341
2370
  ...ifDefined("onProgress", onProgress)
2342
2371
  });
2343
2372
  }
@@ -2356,6 +2385,7 @@ var ControlClientImpl = class {
2356
2385
  mode: options.strict ? "strict" : "lenient",
2357
2386
  skipSchema: options.skipSchema,
2358
2387
  skipMarker: options.skipMarker,
2388
+ ...ifDefined("verifySnapshotContent", this.snapshotVerifier),
2359
2389
  ...ifDefined("onProgress", onProgress)
2360
2390
  });
2361
2391
  }
@@ -2401,6 +2431,7 @@ var ControlClientImpl = class {
2401
2431
  ...ifDefined("refHash", options.refHash),
2402
2432
  ...ifDefined("refInvariants", options.refInvariants),
2403
2433
  ...ifDefined("refName", options.refName),
2434
+ ...ifDefined("verifySnapshotContent", this.snapshotVerifier),
2404
2435
  ...ifDefined("onProgress", onProgress)
2405
2436
  });
2406
2437
  }
@@ -3218,7 +3249,7 @@ async function resolveContractRefToSnapshot(options) {
3218
3249
  const targetHash = refResult.value.hash;
3219
3250
  if (bundles.find((p) => p.metadata.to === targetHash)) return ok({
3220
3251
  hash: targetHash,
3221
- contractJson: blindCast(await readContractSnapshotJson(options.migrationsDir, targetHash)),
3252
+ contractJson: blindCast(await readContractSnapshotJson(options.migrationsDir, targetHash, snapshotVerifierFor(options.config))),
3222
3253
  contractJsonPath: join(contractSnapshotDir(options.migrationsDir, targetHash), "contract.json"),
3223
3254
  source: "snapshot"
3224
3255
  });
@@ -3691,7 +3722,9 @@ function checkFileExists(space, dirPath, dirName, fileName) {
3691
3722
  * package dir with only `migration.json` + `ops.json` is legitimate); a
3692
3723
  * present entry whose inner `storage.storageHash` disagrees with
3693
3724
  * `pkg.metadata.to` is `MIGRATION.CHECK_SNAPSHOT_HASH_MISMATCH`; an unparseable store
3694
- * entry (or a malformed `to`) is `MIGRATION.CHECK_SNAPSHOT_UNPARSEABLE`.
3725
+ * entry (or a malformed `to`) is `MIGRATION.CHECK_SNAPSHOT_UNPARSEABLE`; a parseable
3726
+ * entry whose declared hash agrees but whose content recomputes to a different
3727
+ * storage hash is `MIGRATION.CHECK_SNAPSHOT_CONTENT_MISMATCH`.
3695
3728
  */
3696
3729
  async function checkSnapshotConsistency(space, pkg, migrationsDir) {
3697
3730
  const spaceId = space.spaceId;
@@ -3728,6 +3761,21 @@ async function checkSnapshotConsistency(space, pkg, migrationsDir) {
3728
3761
  why: `Migration "${pkg.dirName}" declares to=${pkg.metadata.to} but its contract snapshot has storageHash=${snapshotHash}`,
3729
3762
  nextActions: [chooseAction("Re-emit the migration package so migration.json and its contract snapshot agree")]
3730
3763
  };
3764
+ if (space.verifySnapshotContent !== void 0) {
3765
+ const jsonPath = join(snapshotDir, "contract.json");
3766
+ try {
3767
+ space.verifySnapshotContent.assertSnapshotContentMatches(raw, pkg.metadata.to, jsonPath);
3768
+ } catch (error) {
3769
+ if (!MigrationToolsError.is(error) || error.code !== "MIGRATION.CONTRACT_SNAPSHOT_CONTENT_MISMATCH") throw error;
3770
+ return {
3771
+ space: spaceId,
3772
+ code: "MIGRATION.CHECK_SNAPSHOT_CONTENT_MISMATCH",
3773
+ where: migrationPathRelative(space.cwd, jsonPath),
3774
+ why: `Migration "${pkg.dirName}": ${error.why}`,
3775
+ nextActions: [chooseAction("Restore migrations/snapshots/ from version control"), chooseAction("Or re-run the command that produced this migration to regenerate its snapshot")]
3776
+ };
3777
+ }
3778
+ }
3731
3779
  return null;
3732
3780
  }
3733
3781
  /**
@@ -3738,7 +3786,7 @@ async function checkSnapshotConsistency(space, pkg, migrationsDir) {
3738
3786
  * membership matches the on-disk directories, package / ref / graph data come
3739
3787
  * from `aggregate.space(id)`.
3740
3788
  */
3741
- async function enumerateCheckSpaces(aggregate, projectMigrationsDir, cwd) {
3789
+ async function enumerateCheckSpaces(aggregate, projectMigrationsDir, cwd, verifySnapshotContent) {
3742
3790
  const candidateDirs = await listContractSpaceDirectories(projectMigrationsDir);
3743
3791
  const onDiskSpaceIds = new Set(candidateDirs.filter(isValidSpaceId));
3744
3792
  const spaces = [];
@@ -3755,7 +3803,8 @@ async function enumerateCheckSpaces(aggregate, projectMigrationsDir, cwd) {
3755
3803
  migrationsDir,
3756
3804
  refsDir: spaceRefsDirectory(migrationsDir),
3757
3805
  projectMigrationsDir,
3758
- cwd
3806
+ cwd,
3807
+ ...ifDefined("verifySnapshotContent", verifySnapshotContent)
3759
3808
  });
3760
3809
  }
3761
3810
  return spaces;
@@ -3846,7 +3895,7 @@ async function runMigrationCheck(inputs) {
3846
3895
  summary: `${failures.length} integrity failure(s)`
3847
3896
  });
3848
3897
  }
3849
- async function loadAggregateIntegrityViolations(config, migrationsDir) {
3898
+ async function loadAggregateIntegrityViolations(config, migrationsDir, verifySnapshotContent) {
3850
3899
  try {
3851
3900
  const contractJsonContent = await readFile(resolveContractPath(config), "utf-8");
3852
3901
  const familyInstance = config.family.create(createControlStack(config));
@@ -3855,7 +3904,8 @@ async function loadAggregateIntegrityViolations(config, migrationsDir) {
3855
3904
  return (await loadContractSpaceAggregate({
3856
3905
  migrationsDir,
3857
3906
  deserializeContract: (json) => familyInstance.deserializeContract(json),
3858
- appContract: familyInstance.deserializeContract(parsedAppContract)
3907
+ appContract: familyInstance.deserializeContract(parsedAppContract),
3908
+ ...ifDefined("verifySnapshotContent", verifySnapshotContent)
3859
3909
  })).checkIntegrity({
3860
3910
  declaredExtensions,
3861
3911
  checkContracts: true
@@ -4068,24 +4118,38 @@ async function executeMigrationNewCommand(options) {
4068
4118
  why: `Contract at ${contractPathAbsolute} has no storageHash`,
4069
4119
  fix: "Run `{bin} contract emit` to regenerate the contract"
4070
4120
  }));
4121
+ const verifySnapshotContent = snapshotVerifierFor(config);
4071
4122
  const aggregate = await loadContractSpaceAggregate({
4072
4123
  migrationsDir,
4073
4124
  deserializeContract: (json) => familyInstance.deserializeContract(json),
4074
- appContract: toContract
4125
+ appContract: toContract,
4126
+ ...ifDefined("verifySnapshotContent", verifySnapshotContent)
4075
4127
  });
4076
4128
  const packageCorruptionFailure = refusePackageCorruptionOnAggregate(aggregate, migrationsDir);
4077
4129
  if (packageCorruptionFailure) return notOk(packageCorruptionFailure);
4078
4130
  const packages = aggregate.app.packages;
4079
4131
  const graph = aggregate.app.graph();
4080
4132
  let fromHash = null;
4081
- if (packages.length > 0) if (options.from) {
4082
- const match = packages.find((p) => p.metadata.to.startsWith(options.from));
4083
- if (!match) return notOk(errorRuntime("MIGRATION.HASH_NOT_IN_GRAPH", "Starting contract not found", {
4133
+ if (options.from !== void 0) {
4134
+ if (packages.length === 0) return notOk(errorRuntime("MIGRATION.HASH_NOT_IN_GRAPH", "--from has no meaning on an empty graph", {
4135
+ why: `--from "${options.from}" was passed, but ${appMigrationsRelative} contains no migrations, so there is no migration target hash it could name.`,
4136
+ fix: "Omit --from to scaffold the first migration (it records a baseline origin). `migration new --from` accepts the full 64-hex target hash of an existing migration, or a unique prefix of one."
4137
+ }));
4138
+ const matchedHashes = [...new Set(packages.filter((p) => p.metadata.to.startsWith(options.from ?? "")).map((p) => p.metadata.to))].sort();
4139
+ if (matchedHashes.length === 0) return notOk(errorRuntime("MIGRATION.HASH_NOT_IN_GRAPH", "Starting contract not found", {
4084
4140
  why: `No migration with to hash matching "${options.from}" exists in ${appMigrationsRelative}`,
4085
- fix: "Check that the --from hash matches a known migration target hash."
4141
+ fix: "Check that the --from hash matches a known migration target hash. `migration new --from` accepts the full 64-hex target hash of an existing migration, or a unique prefix of one."
4086
4142
  }));
4087
- fromHash = match.metadata.to;
4088
- } else {
4143
+ if (matchedHashes.length > 1) return notOk(errorRuntime("MIGRATION.REF_AMBIGUOUS", `Ambiguous --from prefix: "${options.from}"`, {
4144
+ why: `"${options.from}" is a prefix of ${matchedHashes.length} migration target hashes in ${appMigrationsRelative}: ${matchedHashes.join(", ")}`,
4145
+ fix: "Provide a longer prefix or the full 64-hex target hash to disambiguate.",
4146
+ meta: {
4147
+ input: options.from,
4148
+ candidates: matchedHashes
4149
+ }
4150
+ }));
4151
+ fromHash = matchedHashes[0] ?? null;
4152
+ } else if (packages.length > 0) {
4089
4153
  const latestMigration = findLatestMigration(graph);
4090
4154
  if (latestMigration) fromHash = latestMigration.to;
4091
4155
  }
@@ -4242,6 +4306,18 @@ function looksLikeFullHash(input) {
4242
4306
  function graphIsEmpty(space) {
4243
4307
  return space.packages.length === 0;
4244
4308
  }
4309
+ /**
4310
+ * The graph tip, or `null` when the graph is empty or already forked —
4311
+ * a forked graph has no single tip to compare the default ref against.
4312
+ */
4313
+ function findUnambiguousTip(graph) {
4314
+ try {
4315
+ return findLatestMigration(graph)?.to ?? null;
4316
+ } catch (error) {
4317
+ if (MigrationToolsError.is(error)) return null;
4318
+ throw error;
4319
+ }
4320
+ }
4245
4321
  function getReachableRefs(refs, graph) {
4246
4322
  return Object.entries(refs).flatMap(([name, entry]) => entry && isGraphNode(entry.hash, graph) ? [{
4247
4323
  name,
@@ -4321,13 +4397,27 @@ async function resolveFromForPlan(input) {
4321
4397
  });
4322
4398
  return notOk(errorPlanOriginUnknown(getReachableRefs(refs, graph), findLatestMigration(graph)?.to ?? null));
4323
4399
  }
4324
- return resolveFromPolicy({
4400
+ const resolved = await resolveFromPolicy({
4325
4401
  hash: dbRef.hash,
4326
4402
  provenance: {
4327
4403
  kind: "ref",
4328
4404
  refName: "db"
4329
4405
  }
4330
4406
  }, input, refs);
4407
+ if (!resolved.ok) return resolved;
4408
+ const value = resolved.value;
4409
+ if (value.kind === "ref" || value.kind === "graph-node") {
4410
+ const tipHash = findUnambiguousTip(graph);
4411
+ if (tipHash !== null && tipHash !== value.fromHash) return ok({
4412
+ ...value,
4413
+ defaultOriginBehindTip: {
4414
+ refName: "db",
4415
+ refHash: value.fromHash,
4416
+ tipHash
4417
+ }
4418
+ });
4419
+ }
4420
+ return resolved;
4331
4421
  }
4332
4422
  const refResult = parseContractRef(optionsFrom, {
4333
4423
  graph,
@@ -4410,8 +4500,14 @@ async function runPlannerLeg(planner, migrations, frameworkComponents, contract,
4410
4500
  summary: "Contract changed but planner produced no operations. This indicates unsupported or ignored changes."
4411
4501
  }] }));
4412
4502
  } catch (e) {
4413
- if (CliStructuredError$1.is(e) && e.code === "MIGRATION.UNFILLED_PLACEHOLDER") hasPlaceholders = true;
4414
- else throw e;
4503
+ if (CliStructuredError$1.is(e) && e.code === "MIGRATION.UNFILLED_PLACEHOLDER") {
4504
+ hasPlaceholders = true;
4505
+ try {
4506
+ plannedOps = (await Promise.allSettled(plannerResult.plan.operations)).flatMap((entry) => entry.status === "fulfilled" ? [entry.value] : []);
4507
+ } catch {
4508
+ plannedOps = [];
4509
+ }
4510
+ } else throw e;
4415
4511
  }
4416
4512
  return ok({
4417
4513
  plannedOps,
@@ -4433,6 +4529,48 @@ async function writePlannedMigrationPackage(packageDir, fromHash, toHash, create
4433
4529
  }, opsForWrite);
4434
4530
  await writeMigrationTs(packageDir, leg.migrationTsContent);
4435
4531
  }
4532
+ /**
4533
+ * The consent check for an auto-baseline write, mirroring `db update`'s
4534
+ * destructive-changes refusal: a baseline leg carrying destructive operations
4535
+ * is only written when the caller consents to that exact plan by its hash.
4536
+ * Runs before the baseline and delta packages are written, so a refusal
4537
+ * leaves the app-space migrations directory untouched (the extension seed
4538
+ * phase runs earlier and unconditionally, as it does for no-op runs).
4539
+ * A leg with unfilled placeholders is still checked over the operations
4540
+ * that did resolve. Returns `null` when the write may proceed.
4541
+ */
4542
+ function refuseUnconsentedDestructiveBaseline(leg, baselineToHash, consent) {
4543
+ const ops = leg.plannedOps;
4544
+ const destructiveOps = ops.filter((op) => op.operationClass === "destructive");
4545
+ if (destructiveOps.length === 0) return null;
4546
+ const planHash = computePlanHash({
4547
+ operations: ops.map((op) => ({
4548
+ id: op.id,
4549
+ label: op.label,
4550
+ operationClass: op.operationClass
4551
+ })),
4552
+ destination: { storageHash: baselineToHash }
4553
+ });
4554
+ if (consent === void 0) {
4555
+ const verdict = {
4556
+ destructiveOperations: destructiveOps.map((op) => ({
4557
+ id: op.id,
4558
+ label: op.label
4559
+ })),
4560
+ planHash
4561
+ };
4562
+ return errorDestructiveChanges(`The baseline migration contains ${destructiveOps.length} destructive operation(s) that require confirmation`, {
4563
+ why: "The migrations directory is empty, so planning writes a baseline derived from the `db` ref — and that baseline contains operations that would remove data when the migration is applied.",
4564
+ fix: "Re-run `prisma migration plan` and type the project directory name when asked, or pass `--no-interactive --confirm <directory>` where there is nobody to ask.",
4565
+ meta: { ...verdict }
4566
+ });
4567
+ }
4568
+ if (consent.planHash !== planHash) return errorConsentPlanMismatch({
4569
+ consentedPlanHash: consent.planHash,
4570
+ planHash
4571
+ });
4572
+ return null;
4573
+ }
4436
4574
  async function executeMigrationPlanCommand(options, startTime, callbacks) {
4437
4575
  try {
4438
4576
  return await executeMigrationPlanCommandInner(options, startTime, callbacks);
@@ -4483,12 +4621,14 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4483
4621
  let fromContractInStore = false;
4484
4622
  let isAutoBaseline = false;
4485
4623
  let fromDefaulted = false;
4624
+ const verifySnapshotContent = snapshotVerifierFor(config);
4486
4625
  const tolerantAggregateResult = await loadContractSpaceAggregateForCli({
4487
4626
  targetId: config.target.targetId,
4488
4627
  migrationsDir,
4489
4628
  appContract: toContract,
4490
4629
  extensions: config.extensions ?? [],
4491
- deserializeContract: (json) => familyInstance.deserializeContract(json)
4630
+ deserializeContract: (json) => familyInstance.deserializeContract(json),
4631
+ ...ifDefined("verifySnapshotContent", verifySnapshotContent)
4492
4632
  });
4493
4633
  if (!tolerantAggregateResult.ok) return notOk(tolerantAggregateResult.failure);
4494
4634
  const resolutionSpace = tolerantAggregateResult.value.app;
@@ -4497,6 +4637,10 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4497
4637
  space: resolutionSpace
4498
4638
  });
4499
4639
  if (!resolutionResult.ok) return notOk(resolutionResult.failure);
4640
+ const warnings = [];
4641
+ const warnBehindTip = (behind) => {
4642
+ warnings.push(`The default origin ref '${behind.refName}' points at ${behind.refHash}, which is not the latest migration (${behind.tipHash}). Planning from it forks the migration graph; pass --from to choose the origin explicitly.`);
4643
+ };
4500
4644
  switch (resolutionResult.value.kind) {
4501
4645
  case "greenfield":
4502
4646
  fromDefaulted = resolutionResult.value.defaulted;
@@ -4504,11 +4648,13 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4504
4648
  case "graph-node":
4505
4649
  fromHash = resolutionResult.value.fromHash;
4506
4650
  fromContract = resolutionResult.value.fromContract;
4651
+ if (resolutionResult.value.defaultOriginBehindTip !== void 0) warnBehindTip(resolutionResult.value.defaultOriginBehindTip);
4507
4652
  break;
4508
4653
  case "ref":
4509
4654
  fromHash = resolutionResult.value.fromHash;
4510
4655
  fromContract = resolutionResult.value.fromContract;
4511
4656
  fromContractInStore = true;
4657
+ if (resolutionResult.value.defaultOriginBehindTip !== void 0) warnBehindTip(resolutionResult.value.defaultOriginBehindTip);
4512
4658
  break;
4513
4659
  case "auto-baseline":
4514
4660
  fromHash = resolutionResult.value.fromHash;
@@ -4541,10 +4687,12 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4541
4687
  extensions: toExtensionInputs(config.extensions ?? [])
4542
4688
  });
4543
4689
  for (const record of seedResult.seeded) callbacks?.onSeeded?.(record);
4544
- const emittedExtensionDirs = seedResult.seeded.flatMap((r) => r.newMigrationDirs.map((dirName) => ({
4690
+ const seededThisRun = seedResult.seeded.flatMap((r) => r.newMigrationDirs.map((dirName) => ({
4545
4691
  spaceId: r.spaceId,
4546
4692
  dirName
4547
4693
  })));
4694
+ const carried = options.carryEmittedExtensionDirs ?? [];
4695
+ const emittedExtensionDirs = [...carried, ...seededThisRun.filter((entry) => !carried.some((prior) => prior.spaceId === entry.spaceId && prior.dirName === entry.dirName))];
4548
4696
  if (fromHash === toStorageHash && !isAutoBaseline) return ok({
4549
4697
  ok: true,
4550
4698
  noOp: true,
@@ -4552,6 +4700,7 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4552
4700
  to: toStorageHash,
4553
4701
  operations: [],
4554
4702
  emittedExtensionDirs,
4703
+ ...warnings.length > 0 ? { warnings } : {},
4555
4704
  summary: "No changes detected between contracts",
4556
4705
  timings: { total: Date.now() - startTime }
4557
4706
  });
@@ -4562,7 +4711,8 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4562
4711
  migrationsDir,
4563
4712
  appContract: toContract,
4564
4713
  extensions: config.extensions ?? [],
4565
- deserializeContract: (json) => familyInstance.deserializeContract(json)
4714
+ deserializeContract: (json) => familyInstance.deserializeContract(json),
4715
+ ...ifDefined("verifySnapshotContent", verifySnapshotContent)
4566
4716
  });
4567
4717
  if (!aggregateResult.ok) return notOk(aggregateResult.failure);
4568
4718
  const aggregate = aggregateResult.value;
@@ -4589,6 +4739,8 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4589
4739
  const deltaPackageDir = join(appMigrationsDir, deltaDirName);
4590
4740
  const baselineLeg = await runPlannerLeg(planner, migrations, frameworkComponents, fromContract, null, aggregate.app.spaceId, aggregate, snapshotsImportPathFrom(baselinePackageDir, migrationsDir), resolveImportSpecifier);
4591
4741
  if (!baselineLeg.ok) return notOk(baselineLeg.failure);
4742
+ const consentFailure = refuseUnconsentedDestructiveBaseline(baselineLeg.value, fromHash, options.consent);
4743
+ if (consentFailure !== null) return notOk(consentFailure);
4592
4744
  await writePlannedMigrationPackage(baselinePackageDir, null, fromHash, baselineTimestamp, baselineLeg.value);
4593
4745
  if (fromHash === toStorageHash) {
4594
4746
  const baselineOps = baselineLeg.value.hasPlaceholders ? [] : baselineLeg.value.plannedOps;
@@ -4603,6 +4755,7 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4603
4755
  baselineDir,
4604
4756
  operations: [],
4605
4757
  emittedExtensionDirs,
4758
+ ...warnings.length > 0 ? { warnings } : {},
4606
4759
  pendingPlaceholders: true,
4607
4760
  summary: "Planned baseline with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit",
4608
4761
  timings: { total: Date.now() - startTime }
@@ -4622,7 +4775,8 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4622
4775
  })),
4623
4776
  emittedExtensionDirs,
4624
4777
  ...preview !== void 0 ? { preview } : {},
4625
- summary: buildAutoBaselinePlanSummary(0, emittedExtensionDirs.length),
4778
+ ...warnings.length > 0 ? { warnings } : {},
4779
+ summary: buildAutoBaselinePlanSummary(baselineOps.length, 0, emittedExtensionDirs.length),
4626
4780
  timings: { total: Date.now() - startTime }
4627
4781
  });
4628
4782
  }
@@ -4630,8 +4784,9 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4630
4784
  if (!deltaLeg.ok) return notOk(deltaLeg.failure);
4631
4785
  await writePlannedMigrationPackage(deltaPackageDir, fromHash, toStorageHash, deltaTimestamp, deltaLeg.value);
4632
4786
  await writeDestinationSnapshot(toStorageHash);
4787
+ const baselineOps = baselineLeg.value.hasPlaceholders ? [] : baselineLeg.value.plannedOps;
4633
4788
  const deltaOps = deltaLeg.value.hasPlaceholders ? [] : deltaLeg.value.plannedOps;
4634
- if (deltaLeg.value.hasPlaceholders) return ok({
4789
+ if (baselineLeg.value.hasPlaceholders || deltaLeg.value.hasPlaceholders) return ok({
4635
4790
  ok: true,
4636
4791
  noOp: false,
4637
4792
  from: fromHash,
@@ -4640,11 +4795,12 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4640
4795
  baselineDir: relative(cwd, baselinePackageDir),
4641
4796
  operations: [],
4642
4797
  emittedExtensionDirs,
4798
+ ...warnings.length > 0 ? { warnings } : {},
4643
4799
  pendingPlaceholders: true,
4644
4800
  summary: "Planned baseline + migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit",
4645
4801
  timings: { total: Date.now() - startTime }
4646
4802
  });
4647
- const preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(deltaOps) : void 0;
4803
+ const preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview([...baselineOps, ...deltaOps]) : void 0;
4648
4804
  return ok({
4649
4805
  ok: true,
4650
4806
  noOp: false,
@@ -4657,9 +4813,15 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4657
4813
  label: op.label,
4658
4814
  operationClass: op.operationClass
4659
4815
  })),
4816
+ baselineOperations: baselineOps.map((op) => ({
4817
+ id: op.id,
4818
+ label: op.label,
4819
+ operationClass: op.operationClass
4820
+ })),
4660
4821
  emittedExtensionDirs,
4661
4822
  ...preview !== void 0 ? { preview } : {},
4662
- summary: buildAutoBaselinePlanSummary(deltaOps.length, emittedExtensionDirs.length),
4823
+ ...warnings.length > 0 ? { warnings } : {},
4824
+ summary: buildAutoBaselinePlanSummary(baselineOps.length, deltaOps.length, emittedExtensionDirs.length),
4663
4825
  timings: { total: Date.now() - startTime }
4664
4826
  });
4665
4827
  }
@@ -4677,6 +4839,7 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4677
4839
  dir: relative(cwd, packageDir),
4678
4840
  operations: [],
4679
4841
  emittedExtensionDirs,
4842
+ ...warnings.length > 0 ? { warnings } : {},
4680
4843
  pendingPlaceholders: true,
4681
4844
  ...fromDefaulted ? { fromDefaulted } : {},
4682
4845
  summary: "Planned migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit",
@@ -4698,6 +4861,7 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
4698
4861
  emittedExtensionDirs,
4699
4862
  ...preview !== void 0 ? { preview } : {},
4700
4863
  ...fromDefaulted ? { fromDefaulted } : {},
4864
+ ...warnings.length > 0 ? { warnings } : {},
4701
4865
  summary: buildPlanSummary(plannedOps.length, emittedExtensionDirs.length),
4702
4866
  timings: { total: Date.now() - startTime }
4703
4867
  });
@@ -4727,8 +4891,8 @@ function buildPlanSummary(plannedOpsCount, emittedExtensionDirsCount) {
4727
4891
  if (emittedExtensionDirsCount === 0) return base;
4728
4892
  return `${base}; materialised ${emittedExtensionDirsCount} ${emittedExtensionDirsCount === 1 ? "extension-space migration" : "extension-space migrations"}`;
4729
4893
  }
4730
- function buildAutoBaselinePlanSummary(deltaOpsCount, emittedExtensionDirsCount) {
4731
- const base = `Planned baseline + ${deltaOpsCount} operation(s)`;
4894
+ function buildAutoBaselinePlanSummary(baselineOpsCount, deltaOpsCount, emittedExtensionDirsCount) {
4895
+ const base = `Planned baseline (${baselineOpsCount} operation(s)) + ${deltaOpsCount} operation(s)`;
4732
4896
  if (emittedExtensionDirsCount === 0) return base;
4733
4897
  return `${base}; materialised ${emittedExtensionDirsCount} ${emittedExtensionDirsCount === 1 ? "extension-space migration" : "extension-space migrations"}`;
4734
4898
  }
@@ -4807,7 +4971,7 @@ async function executeRefSetCommand(name, contractInput, options) {
4807
4971
  if (!bundles.find((bundle) => bundle.metadata.to === resolvedHash)) return notOk(errorRefSetBundleNotFound(resolvedHash));
4808
4972
  const contractJsonPath = join(contractSnapshotDir(migrationsDir, resolvedHash), "contract.json");
4809
4973
  try {
4810
- await readContractSnapshotJson(migrationsDir, resolvedHash);
4974
+ await readContractSnapshotJson(migrationsDir, resolvedHash, snapshotVerifierFor(config));
4811
4975
  } catch (readError) {
4812
4976
  if (MigrationToolsError.is(readError) && readError.code === "MIGRATION.CONTRACT_SNAPSHOT_MISSING") return notOk(errorFileNotFound(contractJsonPath, {
4813
4977
  why: `Migration bundle for hash ${resolvedHash} is missing its contract snapshot at ${contractJsonPath}`,
@@ -4857,6 +5021,6 @@ async function executeRefListCommand(options) {
4857
5021
  }
4858
5022
  }
4859
5023
  //#endregion
4860
- export { listRefsByContractHash as $, errorMarkerMissing as A, sanitizeErrorMessage as At, executeContractEmit as B, errorContractValidationFailed as C, resolveFromForPlan as Ct, errorFileNotFound as D, runContractSpaceSeedPhase as Dt, errorDriverRequired as E, runCommandAction as Et, errorRunnerFailed as F, executeMigrationNewCommand as G, executeDbUpdate as H, errorRuntime as I, executeRefDeleteCommand as J, executeMigrationPlanCommand as K, errorTargetMigrationNotSupported as L, errorMigrationPlanningFailed as M, targetSupportsMigrations as Mt, errorNoMigrations as N, toDeclaredExtensionsFromRaw as Nt, errorHashMismatch as O, runMigrationCheck as Ot, errorPathUnreachable as P, hasMigrationPath as Q, errorTargetMismatch as R, errorContractArgConflict as S, resolveContractRefToSnapshot as St, errorDestructiveChanges as T, resolveToForPlan as Tt, executeDbVerify as U, executeDbInit as V, executeMigrateShowPlan as W, executeRefSetCommand as X, executeRefListCommand as Y, findPackageByDirPath as Z, enrichContract as _, refusePackageCorruptionOnAggregate as _t, appliedHashesFromLedger as a, mapContractAtError as at, errorConfigValidation$1 as b, resolveAppTargetPath as bt, buildReadAggregate as c, migrationSpaceListEntriesFromAggregate as ct, chooseAction as d, readContractEnvelope as dt, loadAggregateIntegrityViolations as et, closeQuietly as f, readMigrationRefs as ft, disposeEmitQueue as g, refuseMissingInvariantPath as gt, deriveStatusEdgeAnnotations as h, refuseMarkerOutsideGraph as ht, appContractStandInFromIdentity as i, mapCaughtMigrationError as it, errorMigrationPackageNotFound as j, statusForMigrationHash as jt, errorLegendHumanOnly as k, runMigrationList as kt, buildRefAdvancementFields as l, originHashForStatus as lt, createControlClient as m, refuseDeclaredExtensionTargetMismatch as mt, NO_REF_ADVANCEMENT as n, loadContractSpaceAggregateForCli as nt, buildContractSpaceAggregate as o, mapIntegrityViolations as ot, computeRefAdvancementName as p, refuseContractSpaceIntegrity as pt, executeRefAdvancement as q, advanceRefSafely as r, looksLikePath as rt, buildMigrationSpaceGraphEntries as s, maskConnectionUrl as st, CliStructuredError$1 as t, loadContractRawSafely as tt, checkSingleTarget as u, preflightRefAdvancement as ut, enumerateCheckSpaces as v, refuseUnknownInvariants as vt, errorDatabaseConnectionRequired as w, resolveMigrationRef as wt, errorConsentPlanMismatch as x, resolveContractRef$1 as xt, errorAdvanceRefArgConflict as y, requireLiveDatabase as yt, errorUnexpected as z };
5024
+ export { hasMigrationPath as $, errorLegendHumanOnly as A, runMigrationList as At, errorUnexpected as B, errorContractArgConflict as C, resolveContractRefToSnapshot as Ct, errorDriverRequired as D, runCommandAction as Dt, errorDestructiveChanges as E, resolveToForPlan as Et, errorPathUnreachable as F, toDeclaredExtensionsFromRaw as Ft, executeMigrateShowPlan as G, executeDbInit as H, errorRunnerFailed as I, executeRefAdvancement as J, executeMigrationNewCommand as K, errorRuntime as L, errorMigrationPackageNotFound as M, snapshotVerifierFor as Mt, errorMigrationPlanningFailed as N, statusForMigrationHash as Nt, errorFileNotFound as O, runContractSpaceSeedPhase as Ot, errorNoMigrations as P, targetSupportsMigrations as Pt, findPackageByDirPath as Q, errorTargetMigrationNotSupported as R, errorConsentPlanMismatch as S, resolveContractRef$1 as St, errorDatabaseConnectionRequired as T, resolveMigrationRef as Tt, executeDbUpdate as U, executeContractEmit as V, executeDbVerify as W, executeRefListCommand as X, executeRefDeleteCommand as Y, executeRefSetCommand as Z, disposeEmitQueue as _, refuseMissingInvariantPath as _t, appContractStandInFromIdentity as a, mapCaughtMigrationError as at, errorAdvanceRefArgConflict as b, requireLiveDatabase as bt, buildMigrationSpaceGraphEntries as c, maskConnectionUrl as ct, checkSingleTarget as d, preflightRefAdvancement as dt, listRefsByContractHash as et, chooseAction as f, readContractEnvelope as ft, deriveStatusEdgeAnnotations as g, refuseMarkerOutsideGraph as gt, createControlClient as h, refuseDeclaredExtensionTargetMismatch as ht, advanceRefSafely as i, looksLikePath as it, errorMarkerMissing as j, sanitizeErrorMessage as jt, errorHashMismatch as k, runMigrationCheck as kt, buildReadAggregate as l, migrationSpaceListEntriesFromAggregate as lt, computeRefAdvancementName as m, refuseContractSpaceIntegrity as mt, ERROR_CODE_DESTRUCTIVE_CHANGES as n, loadContractRawSafely as nt, appliedHashesFromLedger as o, mapContractAtError as ot, closeQuietly as p, readMigrationRefs as pt, executeMigrationPlanCommand as q, NO_REF_ADVANCEMENT as r, loadContractSpaceAggregateForCli as rt, buildContractSpaceAggregate as s, mapIntegrityViolations as st, CliStructuredError$1 as t, loadAggregateIntegrityViolations as tt, buildRefAdvancementFields as u, originHashForStatus as ut, enrichContract as v, refusePackageCorruptionOnAggregate as vt, errorContractValidationFailed as w, resolveFromForPlan as wt, errorConfigValidation$1 as x, resolveAppTargetPath as xt, enumerateCheckSpaces as y, refuseUnknownInvariants as yt, errorTargetMismatch as z };
4861
5025
 
4862
- //# sourceMappingURL=ref-DlKsxbtg-B55l0TCq.mjs.map
5026
+ //# sourceMappingURL=ref-D5u8Xxwc-BjjqYtnQ.mjs.map