Commit f061a47
TML-2835: make migration check single-target resolution multi-space (#732)
Completes the multi-space `migration check` work
[TML-2801](https://linear.app/prisma-company/issue/TML-2801) began. That
slice made the **holistic** (no-arg) check span every contract space;
its **single-target** mode (`check <ref|path>`) was deliberately left
app-space-only as a follow-up. This makes single-target resolution
multi-space too.
## Changes
- **Single-target resolves across all contract spaces**
(`migration-check.ts`, `checkSingleTarget`): a migration reference is
resolved per-space against each space's graph + refs (reusing TML-2801's
`enumerateCheckSpaces` / `CheckSpace`), and the matched package is
checked in its own space. A migration that lives in a non-app space
(e.g. an extension space) is now resolved and checked, where before it
was a `PRECONDITION` "not found on disk".
- **`--space <id>` narrows single-target** resolution to one space,
validated identically to the holistic path (`isValidSpaceId` →
`errorInvalidSpaceId`; unknown id → `errorSpaceNotFound`;
`PRECONDITION`).
- **Cross-space ambiguity is a precondition failure**: a reference
(dirName / hash-prefix) that resolves in more than one space exits
`PRECONDITION` via a new `errorAmbiguousMigrationRef` factory
(`cli-errors.ts`) that names the spaces and tells the user to qualify
with `--space`.
- **Unresolvable references keep the shared error envelope**: a
reference that resolves in no space is surfaced through
`mapRefResolutionError` (PN-RUN-3000), preserving the consistency
contract TML-2801 established — not a bespoke string.
- **Filesystem-path targets** resolve within whichever space's directory
contains them (`migration-path-target.ts`,
`resolveTargetPathAcrossSpaces`).
- Human output shows the resolved space when it isn't `app`; the
`--help` long description and examples are updated to describe
multi-space single-target; the custom exit codes (`0`/`2`/`4`) remain
documented in `--help`.
## Why
`migration check` is the integrity verb; having single-target silently
ignore non-app spaces meant a corrupted extension-space package could
pass `check <ref>` while the no-arg `check` caught it. Resolving across
spaces (with explicit ambiguity handling) closes that asymmetry and
matches the policy `list` / `graph` / `status` already follow.
**Behaviour note for reviewers:** single-target now loads the full read
aggregate (as the holistic path does) and therefore inherits the
holistic path's integrity-refusal gate, where the old single-target path
read only the app migrations directory. This is the spec's chosen design
and is arguably more correct, but it does widen single-target's
pre-resolution failure surface.
**Out of scope:** the holistic path (TML-2801, done); the other read
verbs; runtime-validatable arktype `--json` schemas
([TML-2836](https://linear.app/prisma-company/issue/TML-2836));
`--space` semantics for `show`/`log`. Exit codes and the
`MigrationCheckResult` shape are unchanged.
Closes TML-2835.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Migration check now resolves migration references across multiple
contract spaces.
* Added optional --space flag to limit resolution to a specific contract
space.
* Success output shows the resolved contract space when applicable.
* **Improvements**
* Clearer handling and messaging for ambiguous migration references;
ambiguity treated as a precondition failure with guidance.
* **Tests**
* New test suite covering multi-space resolution, ambiguity, narrowing
by --space, and related edge cases.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Will Madden <madden@prisma.io>
Co-authored-by: Will Madden <madden@prisma.io>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 1b0cdc9 commit f061a47
7 files changed
Lines changed: 749 additions & 44 deletions
File tree
- packages/1-framework/3-tooling/cli
- src
- commands
- utils
- test/commands
- projects/migration-graph-rendering/slices/check-single-target-multi-space
Lines changed: 147 additions & 44 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | 11 | | |
14 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | | - | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| 58 | + | |
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
| |||
308 | 311 | | |
309 | 312 | | |
310 | 313 | | |
| 314 | + | |
311 | 315 | | |
312 | 316 | | |
313 | 317 | | |
| |||
317 | 321 | | |
318 | 322 | | |
319 | 323 | | |
320 | | - | |
| 324 | + | |
321 | 325 | | |
322 | 326 | | |
323 | 327 | | |
| |||
337 | 341 | | |
338 | 342 | | |
339 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
340 | 351 | | |
341 | 352 | | |
| 353 | + | |
| 354 | + | |
342 | 355 | | |
343 | 356 | | |
344 | | - | |
345 | 357 | | |
346 | 358 | | |
347 | 359 | | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | 360 | | |
355 | 361 | | |
356 | 362 | | |
| |||
382 | 388 | | |
383 | 389 | | |
384 | 390 | | |
385 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
386 | 394 | | |
387 | 395 | | |
388 | | - | |
389 | 396 | | |
390 | 397 | | |
391 | 398 | | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
397 | 432 | | |
398 | 433 | | |
399 | 434 | | |
400 | | - | |
| 435 | + | |
401 | 436 | | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
| 437 | + | |
413 | 438 | | |
414 | | - | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
415 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
416 | 453 | | |
| 454 | + | |
417 | 455 | | |
418 | | - | |
419 | | - | |
420 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
421 | 477 | | |
422 | | - | |
423 | 478 | | |
424 | | - | |
425 | | - | |
426 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
427 | 521 | | |
428 | | - | |
429 | 522 | | |
430 | 523 | | |
431 | | - | |
| 524 | + | |
432 | 525 | | |
433 | 526 | | |
434 | 527 | | |
| |||
439 | 532 | | |
440 | 533 | | |
441 | 534 | | |
| 535 | + | |
| 536 | + | |
442 | 537 | | |
443 | 538 | | |
444 | 539 | | |
| |||
457 | 552 | | |
458 | 553 | | |
459 | 554 | | |
| 555 | + | |
| 556 | + | |
460 | 557 | | |
461 | 558 | | |
462 | 559 | | |
463 | 560 | | |
| 561 | + | |
464 | 562 | | |
465 | 563 | | |
466 | 564 | | |
467 | 565 | | |
468 | 566 | | |
| 567 | + | |
469 | 568 | | |
470 | 569 | | |
471 | 570 | | |
| |||
477 | 576 | | |
478 | 577 | | |
479 | 578 | | |
480 | | - | |
481 | | - | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
482 | 582 | | |
483 | 583 | | |
484 | 584 | | |
| |||
487 | 587 | | |
488 | 588 | | |
489 | 589 | | |
| 590 | + | |
490 | 591 | | |
491 | 592 | | |
492 | 593 | | |
| |||
535 | 636 | | |
536 | 637 | | |
537 | 638 | | |
538 | | - | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
539 | 642 | | |
540 | 643 | | |
541 | 644 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
377 | 400 | | |
378 | 401 | | |
379 | 402 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
33 | 54 | | |
34 | 55 | | |
35 | 56 | | |
| |||
0 commit comments