@prisma-next/cli 0.11.0-dev.65 → 0.11.0-dev.67

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 (52) hide show
  1. package/dist/cli.mjs +3 -3
  2. package/dist/{client-CD3om3R0.mjs → client-6WehTnUh.mjs} +31 -39
  3. package/dist/client-6WehTnUh.mjs.map +1 -0
  4. package/dist/commands/contract-infer.mjs +1 -1
  5. package/dist/commands/db-init.mjs +2 -2
  6. package/dist/commands/db-schema.mjs +1 -1
  7. package/dist/commands/db-sign.mjs +1 -1
  8. package/dist/commands/db-update.mjs +2 -2
  9. package/dist/commands/db-verify.mjs +1 -1
  10. package/dist/commands/migrate.d.mts +2 -2
  11. package/dist/commands/migrate.d.mts.map +1 -1
  12. package/dist/commands/migrate.mjs +1 -1
  13. package/dist/commands/migrate.mjs.map +1 -1
  14. package/dist/commands/migration-graph.d.mts +1 -1
  15. package/dist/commands/migration-list.d.mts +1 -1
  16. package/dist/commands/migration-log.d.mts +1 -1
  17. package/dist/commands/migration-log.mjs +1 -1
  18. package/dist/commands/migration-plan.d.mts +1 -1
  19. package/dist/commands/migration-show.d.mts +1 -1
  20. package/dist/commands/migration-show.mjs +1 -1
  21. package/dist/commands/migration-status.d.mts +7 -9
  22. package/dist/commands/migration-status.d.mts.map +1 -1
  23. package/dist/commands/migration-status.mjs +5 -6
  24. package/dist/commands/migration-status.mjs.map +1 -1
  25. package/dist/commands/ref.d.mts +1 -1
  26. package/dist/{contract-infer-B5EhTqdR.mjs → contract-infer-BLiomU8g.mjs} +2 -2
  27. package/dist/{contract-infer-B5EhTqdR.mjs.map → contract-infer-BLiomU8g.mjs.map} +1 -1
  28. package/dist/{db-verify-B7fbkGnp.mjs → db-verify-D44Qj3w9.mjs} +2 -2
  29. package/dist/{db-verify-B7fbkGnp.mjs.map → db-verify-D44Qj3w9.mjs.map} +1 -1
  30. package/dist/exports/control-api.d.mts +3 -3
  31. package/dist/exports/control-api.mjs +1 -1
  32. package/dist/{inspect-live-schema-CQJnuPgD.mjs → inspect-live-schema-Ccnmg5bz.mjs} +2 -2
  33. package/dist/{inspect-live-schema-CQJnuPgD.mjs.map → inspect-live-schema-Ccnmg5bz.mjs.map} +1 -1
  34. package/dist/{migration-command-scaffold-CE931d1-.mjs → migration-command-scaffold-C_KuV0Gm.mjs} +2 -2
  35. package/dist/{migration-command-scaffold-CE931d1-.mjs.map → migration-command-scaffold-C_KuV0Gm.mjs.map} +1 -1
  36. package/dist/migration-plan-ZZm8C0s-.mjs.map +1 -1
  37. package/dist/migrations-CjO1DsYe.mjs.map +1 -1
  38. package/dist/{types-DK-ge7eR.d.mts → types-BNqTw3ek.d.mts} +18 -19
  39. package/dist/{types-DK-ge7eR.d.mts.map → types-BNqTw3ek.d.mts.map} +1 -1
  40. package/package.json +18 -18
  41. package/src/commands/migrate.ts +2 -2
  42. package/src/commands/migration-plan.ts +1 -1
  43. package/src/commands/migration-status.ts +11 -14
  44. package/src/control-api/operations/{apply-aggregate.ts → apply.ts} +44 -75
  45. package/src/control-api/operations/{db-apply-aggregate.ts → db-apply.ts} +19 -19
  46. package/src/control-api/operations/db-init.ts +4 -4
  47. package/src/control-api/operations/db-update.ts +4 -4
  48. package/src/control-api/operations/db-verify.ts +6 -6
  49. package/src/control-api/operations/migration-apply.ts +20 -24
  50. package/src/control-api/types.ts +16 -17
  51. package/src/utils/formatters/migrations.ts +8 -8
  52. package/dist/client-CD3om3R0.mjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma-next/cli",
3
- "version": "0.11.0-dev.65",
3
+ "version": "0.11.0-dev.67",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -14,15 +14,15 @@
14
14
  "dependencies": {
15
15
  "@clack/prompts": "^1.4.0",
16
16
  "@dagrejs/dagre": "^3.0.0",
17
- "@prisma-next/config": "0.11.0-dev.65",
18
- "@prisma-next/contract": "0.11.0-dev.65",
19
- "@prisma-next/emitter": "0.11.0-dev.65",
20
- "@prisma-next/errors": "0.11.0-dev.65",
21
- "@prisma-next/framework-components": "0.11.0-dev.65",
22
- "@prisma-next/migration-tools": "0.11.0-dev.65",
23
- "@prisma-next/psl-printer": "0.11.0-dev.65",
24
- "@prisma-next/cli-telemetry": "0.11.0-dev.65",
25
- "@prisma-next/utils": "0.11.0-dev.65",
17
+ "@prisma-next/config": "0.11.0-dev.67",
18
+ "@prisma-next/contract": "0.11.0-dev.67",
19
+ "@prisma-next/emitter": "0.11.0-dev.67",
20
+ "@prisma-next/errors": "0.11.0-dev.67",
21
+ "@prisma-next/framework-components": "0.11.0-dev.67",
22
+ "@prisma-next/migration-tools": "0.11.0-dev.67",
23
+ "@prisma-next/psl-printer": "0.11.0-dev.67",
24
+ "@prisma-next/cli-telemetry": "0.11.0-dev.67",
25
+ "@prisma-next/utils": "0.11.0-dev.67",
26
26
  "arktype": "^2.2.0",
27
27
  "c12": "^3.3.4",
28
28
  "ci-info": "^4.3.1",
@@ -39,14 +39,14 @@
39
39
  "wrap-ansi": "^10.0.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@prisma-next/sql-contract": "0.11.0-dev.65",
43
- "@prisma-next/sql-contract-emitter": "0.11.0-dev.65",
44
- "@prisma-next/sql-contract-ts": "0.11.0-dev.65",
45
- "@prisma-next/sql-operations": "0.11.0-dev.65",
46
- "@prisma-next/sql-runtime": "0.11.0-dev.65",
47
- "@prisma-next/test-utils": "0.11.0-dev.65",
48
- "@prisma-next/tsconfig": "0.11.0-dev.65",
49
- "@prisma-next/tsdown": "0.11.0-dev.65",
42
+ "@prisma-next/sql-contract": "0.11.0-dev.67",
43
+ "@prisma-next/sql-contract-emitter": "0.11.0-dev.67",
44
+ "@prisma-next/sql-contract-ts": "0.11.0-dev.67",
45
+ "@prisma-next/sql-operations": "0.11.0-dev.67",
46
+ "@prisma-next/sql-runtime": "0.11.0-dev.67",
47
+ "@prisma-next/test-utils": "0.11.0-dev.67",
48
+ "@prisma-next/tsconfig": "0.11.0-dev.67",
49
+ "@prisma-next/tsdown": "0.11.0-dev.67",
50
50
  "@types/node": "25.6.0",
51
51
  "tsdown": "0.22.0",
52
52
  "typescript": "5.9.3",
@@ -11,9 +11,9 @@ import { Command } from 'commander';
11
11
  import { loadConfig } from '../config-loader';
12
12
  import { createControlClient } from '../control-api/client';
13
13
  import type {
14
- AggregatePerSpaceExecutionEntry,
15
14
  MigrationApplyFailure,
16
15
  MigrationApplyPathDecision,
16
+ PerSpaceExecutionEntry,
17
17
  } from '../control-api/types';
18
18
  import {
19
19
  CliStructuredError,
@@ -75,7 +75,7 @@ export interface MigrateResult {
75
75
  readonly operationsExecuted: number;
76
76
  }[];
77
77
  readonly summary: string;
78
- readonly perSpace: readonly AggregatePerSpaceExecutionEntry[];
78
+ readonly perSpace: readonly PerSpaceExecutionEntry[];
79
79
  readonly pathDecision?: MigrationApplyPathDecision;
80
80
  readonly timings: {
81
81
  readonly total: number;
@@ -186,7 +186,7 @@ export interface MigrationPlanResult {
186
186
  *
187
187
  * Surfacing these in the result (rather than only via `ui.step` log
188
188
  * lines) makes the cross-space side effect explicit to JSON consumers
189
- * and the success-summary renderer — the same multi-space side effect
189
+ * and the success-summary renderer — the same cross-space side effect
190
190
  * that `migrate` will replay.
191
191
  */
192
192
  readonly emittedExtensionDirs: readonly { readonly spaceId: string; readonly dirName: string }[];
@@ -190,10 +190,9 @@ export interface MigrationStatusResult {
190
190
  * migrations directory) where the existing diagnostics already
191
191
  * surface the failure.
192
192
  *
193
- * The legacy top-level fields (`migrations`, `markerHash`,
194
- * `targetHash`, `pathDecision`, …) describe the **app member**
195
- * specifically back-compat with single-space callers. Per-space
196
- * detail for extension members lives only on this list.
193
+ * The top-level fields (`migrations`, `markerHash`, `targetHash`,
194
+ * `pathDecision`, …) describe the **app member** specifically.
195
+ * Per-space detail for extension members lives only on this list.
197
196
  */
198
197
  readonly spaces?: readonly MigrationStatusSpaceEntry[];
199
198
  /** Cross-space pending-migration total (sum of `spaces[].pendingCount`). Present when `spaces` is. */
@@ -430,13 +429,12 @@ function resolveDisplayChain(
430
429
  /**
431
430
  * Build the aggregate enumeration of contract spaces for the status
432
431
  * output. Loads the aggregate from disk (lossy on failure — extension
433
- * spaces are simply omitted, the existing single-space app behaviour
434
- * keeps working), reads per-space marker rows when online, and uses
432
+ * spaces are simply omitted, the app member's output keeps working),
433
+ * reads per-space marker rows when online, and uses
435
434
  * {@link graphWalkStrategy} to compute each space's pending count.
436
435
  *
437
- * Sub-spec § `migration status` semantics the aggregate-walking
438
- * version reports per-space marker + pending state alongside the
439
- * cross-space totals.
436
+ * The aggregate-walking status reports per-space marker + pending
437
+ * state alongside the cross-space totals.
440
438
  */
441
439
  export async function loadAggregateStatusSpaces(args: {
442
440
  readonly aggregate: ContractSpaceAggregate;
@@ -452,8 +450,7 @@ export async function loadAggregateStatusSpaces(args: {
452
450
  ) {
453
451
  // Full integrity refusal (drift, layout violation, etc.) — surfacing
454
452
  // it as a status diagnostic would duplicate `migration plan`'s job.
455
- // The single-space app pipeline still runs; extensions are simply
456
- // not enumerated.
453
+ // The app pipeline still runs; extensions are simply not enumerated.
457
454
  return [];
458
455
  }
459
456
  const aggregate = args.aggregate;
@@ -795,8 +792,8 @@ async function executeMigrationStatusCommand(
795
792
  mode = 'online';
796
793
  // Read every space's marker so the aggregate enumeration can
797
794
  // surface per-space marker state. `readAllMarkers` mirrors what
798
- // `db init` / `db update` already use to drive the multi-space
799
- // planner; here it powers the aggregate status output.
795
+ // `db init` / `db update` already use to drive the planner;
796
+ // here it powers the aggregate status output.
800
797
  //
801
798
  // Probe for the method first so we only swallow the
802
799
  // unsupported-method case: older family instances may not
@@ -1258,7 +1255,7 @@ export function formatStatusSummary(result: MigrationStatusResult, colorize: boo
1258
1255
  }
1259
1256
 
1260
1257
  // Per-space section. Suppressed when there's no extension space —
1261
- // the legacy single-space output already covers the app member.
1258
+ // the top-level output already covers the app member.
1262
1259
  // When extensions exist, render every space (including the app)
1263
1260
  // for consistency, plus a cross-space pending total + apply hint.
1264
1261
  if (result.spaces?.some((s) => s.kind === 'extension')) {
@@ -3,19 +3,12 @@ import type {
3
3
  ControlDriverInstance,
4
4
  ControlFamilyInstance,
5
5
  MigrationOperationPolicy,
6
- MultiSpaceCapableRunner,
7
- MultiSpaceRunnerPerSpaceOptions,
8
6
  TargetMigrationsCapability,
9
7
  } from '@prisma-next/framework-components/control';
10
- import { hasMultiSpaceRunner } from '@prisma-next/framework-components/control';
11
- import type {
12
- AggregatePerSpacePlan,
13
- ContractSpaceAggregate,
14
- } from '@prisma-next/migration-tools/aggregate';
8
+ import type { ContractSpaceAggregate, PerSpacePlan } from '@prisma-next/migration-tools/aggregate';
15
9
  import { ifDefined } from '@prisma-next/utils/defined';
16
10
  import { notOk, ok, type Result } from '@prisma-next/utils/result';
17
- import { errorRunnerFailed } from '../../utils/cli-errors';
18
- import type { AggregatePerSpaceExecutionEntry, OnControlProgress } from '../types';
11
+ import type { OnControlProgress, PerSpaceExecutionEntry } from '../types';
19
12
 
20
13
  /**
21
14
  * Span id emitted via `onProgress` for the apply phase. Stable
@@ -28,35 +21,35 @@ const APPLY_SPAN_ID = 'apply' as const;
28
21
  * events so the parent CLI command can attribute the span correctly,
29
22
  * and used to compose action-specific summary phrasing.
30
23
  */
31
- export type AggregateApplyAction = 'dbInit' | 'dbUpdate' | 'migrationApply';
24
+ export type ApplyAction = 'dbInit' | 'dbUpdate' | 'migrationApply';
32
25
 
33
26
  /**
34
- * Failure variant emitted by {@link applyAggregate} when the multi-space
35
- * runner itself rejects the apply. Mirrors the failure shape callers
27
+ * Failure variant emitted by {@link applyMigration} when the runner
28
+ * itself rejects the apply. Mirrors the failure shape callers
36
29
  * already wrap into their own action-specific failure envelopes
37
30
  * (`DbInitFailure`, `DbUpdateFailure`, `MigrationApplyFailure`) so each
38
31
  * caller keeps owning its own discriminated failure code.
39
32
  */
40
- export interface AggregateApplyRunnerFailure {
33
+ export interface ApplyRunnerFailure {
41
34
  readonly summary: string;
42
35
  readonly why?: string;
43
36
  readonly meta: Record<string, unknown>;
44
37
  }
45
38
 
46
- export interface ApplyAggregateInputs<TFamilyId extends string, TTargetId extends string> {
39
+ export interface ApplyMigrationInputs<TFamilyId extends string, TTargetId extends string> {
47
40
  readonly aggregate: ContractSpaceAggregate;
48
41
  /**
49
42
  * Per-space plans, keyed by `spaceId`. Produced by either the full
50
- * {@link planAggregate} pipeline (`db init` / `db update` — synth
43
+ * {@link planMigration} pipeline (`db init` / `db update` — synth
51
44
  * for the app, graph-walk for extensions) or by direct
52
45
  * {@link graphWalkStrategy} calls (`migrate` — graph-walk
53
46
  * for every member). Either way, the runner consumes the same shape.
54
47
  */
55
- readonly perSpacePlans: ReadonlyMap<string, AggregatePerSpacePlan>;
48
+ readonly perSpacePlans: ReadonlyMap<string, PerSpacePlan>;
56
49
  /**
57
50
  * Canonical schedule order — extensions alphabetically by `spaceId`,
58
51
  * then app. Mirrors {@link import('@prisma-next/migration-tools/concatenate-space-apply-inputs').concatenateSpaceApplyInputs}'s
59
- * convention so `MultiSpaceRunnerFailure.failingSpace` attribution
52
+ * convention so `MigrationRunnerFailure.failingSpace` attribution
60
53
  * stays byte-for-byte stable across callers.
61
54
  */
62
55
  readonly applyOrder: readonly string[];
@@ -69,22 +62,22 @@ export interface ApplyAggregateInputs<TFamilyId extends string, TTargetId extend
69
62
  >;
70
63
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;
71
64
  readonly policy: MigrationOperationPolicy;
72
- readonly action: AggregateApplyAction;
65
+ readonly action: ApplyAction;
73
66
  readonly onProgress?: OnControlProgress;
74
67
  }
75
68
 
76
69
  /**
77
70
  * Resolved per-space plan in canonical schedule order. Surfaced from
78
- * {@link applyAggregate} to callers so each one can build its own
71
+ * {@link applyMigration} to callers so each one can build its own
79
72
  * action-specific success envelope (e.g. `DbInitSuccess` vs
80
73
  * `MigrationApplySuccess`) without re-deriving the ordering.
81
74
  */
82
75
  export interface OrderedResolution {
83
76
  readonly spaceId: string;
84
- readonly entry: AggregatePerSpacePlan;
77
+ readonly entry: PerSpacePlan;
85
78
  }
86
79
 
87
- export interface ApplyAggregateValue {
80
+ export interface ApplyMigrationValue {
88
81
  readonly orderedResolutions: readonly OrderedResolution[];
89
82
  readonly totalOpsPlanned: number;
90
83
  readonly totalOpsExecuted: number;
@@ -93,30 +86,30 @@ export interface ApplyAggregateValue {
93
86
  * envelopes. Each entry carries the post-apply marker (live storage hash
94
87
  * plus invariants) so callers can render it directly without re-reading.
95
88
  */
96
- readonly perSpace: readonly AggregatePerSpaceExecutionEntry[];
89
+ readonly perSpace: readonly PerSpaceExecutionEntry[];
97
90
  }
98
91
 
99
- export type ApplyAggregateResult = Result<ApplyAggregateValue, AggregateApplyRunnerFailure>;
92
+ export type ApplyMigrationResult = Result<ApplyMigrationValue, ApplyRunnerFailure>;
100
93
 
101
94
  /**
102
- * Runner-driving tail shared by every aggregate apply caller — `db init`,
95
+ * Runner-driving tail shared by every apply caller — `db init`,
103
96
  * `db update`, and `migrate`. Consumes already-resolved per-space
104
97
  * plans (the planner-vs-replay distinction is owned by the caller) and
105
- * dispatches them to the multi-space runner in canonical order.
98
+ * dispatches them to the runner in canonical order.
106
99
  *
107
100
  * Marker advancement is part of the runner's per-space transaction
108
101
  * (the SQL family runner writes the marker as the last step of each
109
102
  * space's transaction), so this primitive does not advance markers
110
- * separately — by the time `executeAcrossSpaces` returns ok, every
103
+ * separately — by the time `execute` returns ok, every
111
104
  * space's marker has been advanced to its plan's destination.
112
105
  *
113
106
  * Span emission (`spanStart 'apply'` / `spanEnd 'apply'`) is owned here
114
107
  * so callers don't have to duplicate it; the `action` field on each
115
108
  * progress event is taken from the caller's `action` argument.
116
109
  */
117
- export async function applyAggregate<TFamilyId extends string, TTargetId extends string>(
118
- inputs: ApplyAggregateInputs<TFamilyId, TTargetId>,
119
- ): Promise<ApplyAggregateResult> {
110
+ export async function applyMigration<TFamilyId extends string, TTargetId extends string>(
111
+ inputs: ApplyMigrationInputs<TFamilyId, TTargetId>,
112
+ ): Promise<ApplyMigrationResult> {
120
113
  const {
121
114
  aggregate,
122
115
  perSpacePlans,
@@ -133,14 +126,6 @@ export async function applyAggregate<TFamilyId extends string, TTargetId extends
133
126
  const orderedResolutions = collectOrdered(applyOrder, perSpacePlans);
134
127
 
135
128
  const runner = migrations.createRunner(familyInstance);
136
- if (!hasMultiSpaceRunner(runner)) {
137
- throw errorRunnerFailed(
138
- `Runner for target "${aggregate.targetId}" does not implement \`executeAcrossSpaces\``,
139
- {
140
- why: `${labelForAction(action)} requires multi-space-capable runners (today: every SQL family runner).`,
141
- },
142
- );
143
- }
144
129
 
145
130
  onProgress?.({
146
131
  action,
@@ -149,26 +134,21 @@ export async function applyAggregate<TFamilyId extends string, TTargetId extends
149
134
  label: progressLabelForAction(action),
150
135
  });
151
136
 
152
- const perSpaceOptions: MultiSpaceRunnerPerSpaceOptions<TFamilyId, TTargetId>[] =
153
- orderedResolutions.map((r) => ({
154
- space: r.spaceId,
155
- plan: r.entry.plan,
156
- driver,
157
- destinationContract: r.entry.destinationContract,
158
- policy,
159
- frameworkComponents,
160
- // Per-space post-apply schema verification is non-strict: each
161
- // space's `destinationContract` describes only its own slice; a
162
- // strict verifier would treat every other space's tables as
163
- // `extras`. Tolerant mode still catches missing tables / columns.
164
- // SQL family runners read `strictVerification` via structural
165
- // typing.
166
- strictVerification: false,
167
- })) as MultiSpaceRunnerPerSpaceOptions<TFamilyId, TTargetId>[];
137
+ const perSpaceOptions = orderedResolutions.map((r) => ({
138
+ space: r.spaceId,
139
+ plan: r.entry.plan,
140
+ driver,
141
+ destinationContract: r.entry.destinationContract,
142
+ policy,
143
+ frameworkComponents,
144
+ // Per-space post-apply schema verification is non-strict: each
145
+ // space's `destinationContract` describes only its own slice; a
146
+ // strict verifier would treat every other space's tables as
147
+ // `extras`. Tolerant mode still catches missing tables / columns.
148
+ strictVerification: false,
149
+ }));
168
150
 
169
- const runnerResult = await (
170
- runner as MultiSpaceCapableRunner<TFamilyId, TTargetId>
171
- ).executeAcrossSpaces({ driver, perSpaceOptions });
151
+ const runnerResult = await runner.execute({ driver, perSpaceOptions });
172
152
 
173
153
  if (!runnerResult.ok) {
174
154
  onProgress?.({ action, kind: 'spanEnd', spanId: APPLY_SPAN_ID, outcome: 'error' });
@@ -207,28 +187,28 @@ export async function applyAggregate<TFamilyId extends string, TTargetId extends
207
187
 
208
188
  /**
209
189
  * Project the planner's per-space resolutions into the
210
- * `AggregatePerSpaceExecutionEntry[]` shape the CLI surfaces.
190
+ * `PerSpaceExecutionEntry[]` shape the CLI surfaces.
211
191
  *
212
192
  * `includeMarkers` is `true` for apply-mode (each space's marker is
213
193
  * the `destination.storageHash` of its plan, which the runner
214
194
  * advances as the last step of each space's transaction) and `false`
215
195
  * for plan-mode (no marker has been written yet).
216
196
  *
217
- * Exported alongside {@link applyAggregate} so plan-mode callers can
197
+ * Exported alongside {@link applyMigration} so plan-mode callers can
218
198
  * assemble the same per-space block without going through the runner.
219
199
  */
220
200
  export function buildPerSpaceBreakdown(
221
201
  orderedResolutions: readonly OrderedResolution[],
222
202
  appSpaceId: string,
223
203
  options: { readonly includeMarkers: boolean },
224
- ): readonly AggregatePerSpaceExecutionEntry[] {
204
+ ): readonly PerSpaceExecutionEntry[] {
225
205
  return orderedResolutions.map((r) => {
226
206
  const operations = r.entry.displayOps.map((op) => ({
227
207
  id: op.id,
228
208
  label: op.label,
229
209
  operationClass: op.operationClass,
230
210
  }));
231
- const base: AggregatePerSpaceExecutionEntry = {
211
+ const base: PerSpaceExecutionEntry = {
232
212
  spaceId: r.spaceId,
233
213
  kind: r.spaceId === appSpaceId ? 'app' : 'extension',
234
214
  operations,
@@ -251,12 +231,12 @@ export function buildPerSpaceBreakdown(
251
231
  */
252
232
  export function collectOrdered(
253
233
  applyOrder: readonly string[],
254
- perSpace: ReadonlyMap<string, AggregatePerSpacePlan>,
234
+ perSpace: ReadonlyMap<string, PerSpacePlan>,
255
235
  ): readonly OrderedResolution[] {
256
236
  return applyOrder.map((spaceId) => {
257
237
  const entry = perSpace.get(spaceId);
258
238
  if (!entry) {
259
- throw new Error(`Aggregate planner output missing per-space plan for "${spaceId}"`);
239
+ throw new Error(`planner output missing per-space plan for "${spaceId}"`);
260
240
  }
261
241
  return { spaceId, entry };
262
242
  });
@@ -264,11 +244,11 @@ export function collectOrdered(
264
244
 
265
245
  /**
266
246
  * Action-appropriate label for the `spanStart` event the apply
267
- * primitive emits. `applyAggregate` is shared by `db init`, `db update`,
247
+ * primitive emits. `applyMigration` is shared by `db init`, `db update`,
268
248
  * and `migrate`; the span label tracks the user-visible action
269
249
  * so structured-progress output reads naturally for each surface.
270
250
  */
271
- export function progressLabelForAction(action: AggregateApplyAction): string {
251
+ export function progressLabelForAction(action: ApplyAction): string {
272
252
  switch (action) {
273
253
  case 'dbInit':
274
254
  return 'Initialising database across spaces';
@@ -278,14 +258,3 @@ export function progressLabelForAction(action: AggregateApplyAction): string {
278
258
  return 'Applying migration plan across spaces';
279
259
  }
280
260
  }
281
-
282
- function labelForAction(action: AggregateApplyAction): string {
283
- switch (action) {
284
- case 'dbInit':
285
- return 'db init';
286
- case 'dbUpdate':
287
- return 'db update';
288
- case 'migrationApply':
289
- return 'migrate';
290
- }
291
- }
@@ -11,9 +11,9 @@ import type {
11
11
  } from '@prisma-next/framework-components/control';
12
12
  import { hasOperationPreview } from '@prisma-next/framework-components/control';
13
13
  import {
14
- type AggregatePlannerError,
15
14
  type ContractSpaceAggregate,
16
- planAggregate,
15
+ type PlannerError,
16
+ planMigration,
17
17
  } from '@prisma-next/migration-tools/aggregate';
18
18
  import { ifDefined } from '@prisma-next/utils/defined';
19
19
  import { notOk, ok } from '@prisma-next/utils/result';
@@ -23,7 +23,6 @@ import {
23
23
  buildContractSpaceAggregate,
24
24
  } from '../../utils/contract-space-aggregate-loader';
25
25
  import type {
26
- AggregatePerSpaceExecutionEntry,
27
26
  DbInitFailure,
28
27
  DbInitResult,
29
28
  DbInitSuccess,
@@ -31,15 +30,16 @@ import type {
31
30
  DbUpdateResult,
32
31
  DbUpdateSuccess,
33
32
  OnControlProgress,
33
+ PerSpaceExecutionEntry,
34
34
  } from '../types';
35
- import { applyAggregate, buildPerSpaceBreakdown, collectOrdered } from './apply-aggregate';
35
+ import { applyMigration, buildPerSpaceBreakdown, collectOrdered } from './apply';
36
36
  import { stripOperations } from './migration-helpers';
37
37
 
38
38
  /**
39
- * Span IDs emitted via `onProgress` during the aggregate apply flow.
39
+ * Span IDs emitted via `onProgress` during the apply flow.
40
40
  * Stable identifiers consumed by the structured-output renderer and by
41
41
  * tests asserting on span ids. The `apply` span itself is owned by
42
- * the {@link applyAggregate} primitive — only the introspect / plan
42
+ * the {@link applyMigration} primitive — only the introspect / plan
43
43
  * spans are emitted directly here.
44
44
  */
45
45
  const SPAN_IDS = {
@@ -48,13 +48,13 @@ const SPAN_IDS = {
48
48
  } as const;
49
49
 
50
50
  /**
51
- * Inputs shared by `db init` and `db update` aggregate apply flows.
51
+ * Inputs shared by `db init` and `db update` apply flows.
52
52
  *
53
53
  * Accepts the already-validated app contract + descriptor list — the
54
54
  * loader gathers the rest from disk + descriptors. The CLI is the
55
55
  * descriptor-import boundary; everything downstream is descriptor-free.
56
56
  */
57
- export interface ExecuteAggregateApplyOptions<TFamilyId extends string, TTargetId extends string> {
57
+ export interface ExecuteApplyOptions<TFamilyId extends string, TTargetId extends string> {
58
58
  readonly driver: ControlDriverInstance<TFamilyId, TTargetId>;
59
59
  readonly familyInstance: ControlFamilyInstance<TFamilyId, unknown>;
60
60
  readonly contract: Contract;
@@ -83,17 +83,17 @@ export interface ExecuteAggregateApplyOptions<TFamilyId extends string, TTargetI
83
83
  * integrity violation short-circuits with a structured error.
84
84
  * 2. **Read DB state**: marker rows (`familyInstance.readAllMarkers`)
85
85
  * + introspected schema (`familyInstance.introspect`).
86
- * 3. **Plan**: {@link planAggregate} chooses graph-walk vs synth per
86
+ * 3. **Plan**: {@link planMigration} chooses graph-walk vs synth per
87
87
  * member according to `callerPolicy.ignoreGraphFor`. The app member
88
88
  * is forced through synth (today's daily-driver behaviour); every
89
89
  * extension member walks its on-disk graph.
90
90
  * 4. **Apply** (when `mode === 'apply'`): every per-space `MigrationPlan`
91
- * feeds into the runner's `executeAcrossSpaces` — one outer
91
+ * feeds into the runner's `execute` — one outer
92
92
  * transaction across every space; failure on any space rolls back
93
93
  * every space's writes.
94
94
  */
95
- export async function executeAggregateApply<TFamilyId extends string, TTargetId extends string>(
96
- options: ExecuteAggregateApplyOptions<TFamilyId, TTargetId>,
95
+ export async function executeApply<TFamilyId extends string, TTargetId extends string>(
96
+ options: ExecuteApplyOptions<TFamilyId, TTargetId>,
97
97
  ): Promise<DbInitResult | DbUpdateResult> {
98
98
  const {
99
99
  driver,
@@ -159,7 +159,7 @@ export async function executeAggregateApply<TFamilyId extends string, TTargetId
159
159
  spanId: SPAN_IDS.plan,
160
160
  label: 'Planning migration',
161
161
  });
162
- const planResult = await planAggregate<TFamilyId, TTargetId>({
162
+ const planResult = await planMigration<TFamilyId, TTargetId>({
163
163
  aggregate,
164
164
  currentDBState: { markersBySpaceId: markerRows, schemaIntrospection: schemaIR },
165
165
  familyInstance,
@@ -205,13 +205,13 @@ export async function executeAggregateApply<TFamilyId extends string, TTargetId
205
205
  });
206
206
  }
207
207
 
208
- // 5. Apply mode: hand off to the shared `applyAggregate` primitive.
208
+ // 5. Apply mode: hand off to the shared `applyMigration` primitive.
209
209
  // The runner-driving tail is identical for `db init` / `db update` /
210
210
  // `migrate` — only how each caller produces `perSpacePlans`
211
- // differs (synth + graph-walk via planAggregate here; graph-walk
211
+ // differs (synth + graph-walk via planMigration here; graph-walk
212
212
  // only for migrate). Each caller produces perSpacePlans differently;
213
213
  // this helper handles the shared apply tail.
214
- const applied = await applyAggregate({
214
+ const applied = await applyMigration({
215
215
  aggregate,
216
216
  perSpacePlans: planResult.value.perSpace,
217
217
  applyOrder: planResult.value.applyOrder,
@@ -298,7 +298,7 @@ function detectOrphanMarkers(
298
298
  });
299
299
  }
300
300
 
301
- function mapPlannerError(error: AggregatePlannerError): DbInitResult | DbUpdateResult {
301
+ function mapPlannerError(error: PlannerError): DbInitResult | DbUpdateResult {
302
302
  if (error.kind === 'appSynthFailure') {
303
303
  const failure: DbInitFailure | DbUpdateFailure = {
304
304
  code: 'PLANNING_FAILED',
@@ -337,7 +337,7 @@ function wrapPlanResult(args: {
337
337
  readonly operations: readonly MigrationPlanOperation[];
338
338
  readonly destination: { readonly storageHash: string; readonly profileHash?: string };
339
339
  readonly preview: OperationPreview | undefined;
340
- readonly perSpace: readonly AggregatePerSpaceExecutionEntry[];
340
+ readonly perSpace: readonly PerSpaceExecutionEntry[];
341
341
  readonly summary: string;
342
342
  }): DbInitResult | DbUpdateResult {
343
343
  const success: DbInitSuccess | DbUpdateSuccess = {
@@ -361,7 +361,7 @@ function wrapApplyResult(args: {
361
361
  readonly destination: { readonly storageHash: string; readonly profileHash?: string };
362
362
  readonly operationsPlanned: number;
363
363
  readonly operationsExecuted: number;
364
- readonly perSpace: readonly AggregatePerSpaceExecutionEntry[];
364
+ readonly perSpace: readonly PerSpaceExecutionEntry[];
365
365
  readonly summary: string;
366
366
  }): DbInitResult | DbUpdateResult {
367
367
  const success: DbInitSuccess | DbUpdateSuccess = {
@@ -8,20 +8,20 @@ import type {
8
8
  } from '@prisma-next/framework-components/control';
9
9
  import { ifDefined } from '@prisma-next/utils/defined';
10
10
  import type { DbInitResult, OnControlProgress } from '../types';
11
- import { executeAggregateApply } from './db-apply-aggregate';
11
+ import { executeApply } from './db-apply';
12
12
 
13
13
  /**
14
14
  * Options for executing the `db init` operation.
15
15
  *
16
16
  * `db init` runs the loader → planner → runner pipeline:
17
17
  *
18
- * 1. {@link executeAggregateApply} loads a `ContractSpaceAggregate` via
18
+ * 1. {@link executeApply} loads a `ContractSpaceAggregate` via
19
19
  * {@link import('@prisma-next/migration-tools/aggregate').loadContractSpaceAggregate}
20
20
  * from the supplied descriptor set + on-disk on-disk artefacts.
21
21
  * 2. The aggregate planner runs with `callerPolicy.ignoreGraphFor`
22
22
  * locked to the app member — synth strategy for the app, graph-walk
23
23
  * for every extension.
24
- * 3. The runner's `executeAcrossSpaces` applies the per-space plans
24
+ * 3. The runner's `execute` applies the per-space plans
25
25
  * inside one outer transaction.
26
26
  *
27
27
  * `extensionPacks` mirrors `Config.extensionPacks` (descriptor list).
@@ -68,7 +68,7 @@ export interface ExecuteDbInitOptions<TFamilyId extends string, TTargetId extend
68
68
  export async function executeDbInit<TFamilyId extends string, TTargetId extends string>(
69
69
  options: ExecuteDbInitOptions<TFamilyId, TTargetId>,
70
70
  ): Promise<DbInitResult> {
71
- const result = await executeAggregateApply<TFamilyId, TTargetId>({
71
+ const result = await executeApply<TFamilyId, TTargetId>({
72
72
  driver: options.driver,
73
73
  familyInstance: options.familyInstance,
74
74
  contract: options.contract,
@@ -9,7 +9,7 @@ import type {
9
9
  import { ifDefined } from '@prisma-next/utils/defined';
10
10
  import { notOk } from '@prisma-next/utils/result';
11
11
  import type { DbUpdateResult, OnControlProgress } from '../types';
12
- import { executeAggregateApply } from './db-apply-aggregate';
12
+ import { executeApply } from './db-apply';
13
13
 
14
14
  const DB_UPDATE_POLICY = {
15
15
  allowedOperationClasses: ['additive', 'widening', 'destructive'] as const,
@@ -71,7 +71,7 @@ export async function executeDbUpdate<TFamilyId extends string, TTargetId extend
71
71
  const gate = await guardDestructiveChanges<TFamilyId, TTargetId>(sharedInputs);
72
72
  if (gate !== null) return gate;
73
73
  }
74
- return (await executeAggregateApply<TFamilyId, TTargetId>({
74
+ return (await executeApply<TFamilyId, TTargetId>({
75
75
  ...sharedInputs,
76
76
  mode: options.mode,
77
77
  })) as DbUpdateResult;
@@ -85,9 +85,9 @@ export async function executeDbUpdate<TFamilyId extends string, TTargetId extend
85
85
  * run.
86
86
  */
87
87
  async function guardDestructiveChanges<TFamilyId extends string, TTargetId extends string>(
88
- sharedInputs: Omit<Parameters<typeof executeAggregateApply<TFamilyId, TTargetId>>[0], 'mode'>,
88
+ sharedInputs: Omit<Parameters<typeof executeApply<TFamilyId, TTargetId>>[0], 'mode'>,
89
89
  ): Promise<DbUpdateResult | null> {
90
- const planResult = (await executeAggregateApply<TFamilyId, TTargetId>({
90
+ const planResult = (await executeApply<TFamilyId, TTargetId>({
91
91
  ...sharedInputs,
92
92
  mode: 'plan',
93
93
  })) as DbUpdateResult;
@@ -7,10 +7,10 @@ import type {
7
7
  VerifyDatabaseSchemaResult,
8
8
  } from '@prisma-next/framework-components/control';
9
9
  import {
10
- type AggregateVerifierOutput,
11
10
  type ContractSpaceMember,
12
11
  requireHeadRef,
13
- verifyAggregate,
12
+ type VerifierOutput,
13
+ verifyMigration,
14
14
  } from '@prisma-next/migration-tools/aggregate';
15
15
  import { castAs } from '@prisma-next/utils/casts';
16
16
  import { notOk, ok, type Result } from '@prisma-next/utils/result';
@@ -84,7 +84,7 @@ export type ExecuteDbVerifyResult = Result<ExecuteDbVerifySuccess, CliStructured
84
84
  * structured CLI error.
85
85
  * 2. **Read DB state**: marker rows + (when `skipSchema` is `false`)
86
86
  * schema introspection.
87
- * 3. **Verify**: {@link verifyAggregate} returns per-space
87
+ * 3. **Verify**: {@link verifyMigration} returns per-space
88
88
  * `markerCheck` + per-space pre-projected `schemaCheck` (closes F23).
89
89
  * Marker mismatches map to `CliStructuredError` (code `5002`) so
90
90
  * callers (CLI command) can render and exit. Schema results are
@@ -104,7 +104,7 @@ export async function executeDbVerify<TFamilyId extends string, TTargetId extend
104
104
  : await runIntrospection({ driver, familyInstance, onProgress });
105
105
 
106
106
  emitVerifySpan(onProgress, 'spanStart');
107
- const verifyResult = verifyAggregate({
107
+ const verifyResult = verifyMigration({
108
108
  aggregate,
109
109
  markersBySpaceId,
110
110
  schemaIntrospection,
@@ -208,12 +208,12 @@ function emitVerifySpan(
208
208
  }
209
209
 
210
210
  /**
211
- * Map an {@link AggregateVerifierOutput} to the operation's
211
+ * Map an {@link VerifierOutput} to the operation's
212
212
  * {@link ExecuteDbVerifyResult}, applying the `skipMarker` policy used
213
213
  * by the CLI's `--schema-only` mode.
214
214
  */
215
215
  function finaliseVerifyResult(args: {
216
- verifyResult: AggregateVerifierOutput<VerifyDatabaseSchemaResult>;
216
+ verifyResult: VerifierOutput<VerifyDatabaseSchemaResult>;
217
217
  aggregate: {
218
218
  readonly app: { readonly spaceId: string };
219
219
  readonly extensions: ReadonlyArray<{ readonly spaceId: string }>;