Repository navigation
TML-2697: rewrite migration list — completeness, graph context, multi-space - #603
Conversation
|
Warning Review limit reached
More reviews will be available in 38 minutes and 51 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (21)
📝 WalkthroughWalkthroughRefactors the migration-list CLI to enumerate on-disk contract spaces, attach refs, return typed results, render fixed-width multi-space output with optional ANSI styling, validate/signal missing or invalid spaces via structured errors, and adds comprehensive unit tests and package export entries. ChangesMigration CLI Refactoring: Per-Contract-Space Enumeration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (2)
packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts (1)
132-133: ⚡ Quick winRemove spec-section attribution from this source comment.
Keep the explanation, but avoid referencing spec sections in code comments.
As per coding guidelines, source-code comments should describe constraints directly without transient spec/prose attributions.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts` around lines 132 - 133, Edit the inline comment that currently starts with "slice spec § Empty-state." in cli-errors.ts: remove the "spec-section" attribution and the "§ Empty-state" marker so the comment reads as a plain explanation that this error fires only when `<projectMigrationsDir>/<spaceId>` does not exist on disk; keep the explanatory text but strip any reference to spec sections or special symbols.packages/1-framework/3-tooling/cli/src/commands/migration-list.ts (1)
136-137: ⚡ Quick winDrop the “spec § …” attribution from source comments.
The behavior note is useful, but the comment should describe the constraint directly without spec-section attribution.
As per coding guidelines, source-code comments must not include prose attributions to transient spec artifacts.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/1-framework/3-tooling/cli/src/commands/migration-list.ts` around lines 136 - 137, Remove the prose attribution "spec § Empty-state + the `migrations/` missing edge case" from the inline comment in migration-list.ts and rewrite the comment to state the constraint directly: explain that the renderer's empty-state path may point to a directory (for example when it is "migrations/") and that callers must handle that missing-edge-case accordingly. Update the comment near the existing "renderer's empty-state path" note so it no longer references a spec section and clearly describes the directory-name/migrations/ missing-edge-case constraint.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/1-framework/3-tooling/cli/src/commands/migration-list.ts`:
- Around line 82-88: The isEnoent function currently uses a blind cast (error as
{ code?: unknown }) to read error.code; change it to avoid casting by first
ensuring error is a non-null object (e.g., typeof error === 'object' && error
!== null) and then read the property without a cast using Reflect.get(error,
'code') === 'ENOENT' (or equivalent cast-free check); update the isEnoent
implementation to remove the blind cast and rely on Reflect.get/error narrowing
while keeping the same overall boolean logic.
- Around line 213-223: Replace the conditional object spread for spaceFilter
with the ifDefined helper: change the spread currently built from options.space
(used when calling runMigrationList) to use ...ifDefined('spaceFilter',
options.space) so the helper's ifDefined(key, value) return shape is used
correctly; leave the conditional array spread used for details as-is (do not
change the details: [...] conditional). Ensure references affected are the call
to runMigrationList and the options.space usage in migration-list.ts.
In `@packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts`:
- Around line 119-120: Update the invalid-space guidance strings to accurately
reflect the isValidSpaceId rule: start with a lowercase letter, allow only
lowercase letters, digits, underscores and hyphens, and limit to 64 characters.
Locate the object entry that contains the current why and fix strings (the same
block where those two properties are defined) and change why to describe the
actual pattern (e.g., "Space ids must start with a lowercase letter and may
contain lowercase letters, digits, '_' or '-', max 64 chars") and change fix to
suggest passing a space id conforming to that rule or omitting --space;
reference the isValidSpaceId validator in the message if helpful.
In `@packages/1-framework/3-tooling/cli/test/commands/migration-list.test.ts`:
- Around line 131-137: The comment block above the writePackage call in
migration-list.test.ts uses transient artifact attributions like “slice spec”,
“DoD checklist”, and “Spec rule”; replace those phrases with direct behavioral
descriptions of the expected output (e.g., describe the five-row migration
format, the fields shown, and their meaning such as id, SHA, direction/arrows,
tags and environment) so the comment explains constraints and expected behavior
for the test around migrationsRoot and the writePackage invocation without
referencing transient artifacts; apply the same rewording to the other comment
locations noted (lines referenced in the review).
- Around line 79-84: The inline cast on op should be removed and replaced with a
small runtime/type guard so mapping is type-safe: add a predicate (e.g.
hasInvariantId or isWithInvariantId) that narrows an element to { invariantId?:
string } or directly to { invariantId: string } and use
ops.filter(hasInvariantId).map(op => op.invariantId) (or filter after map with a
type-preserving predicate) when building providedInvariants; update the
providedInvariants expression to use that guard instead of (op as {
invariantId?: string }).invariantId so the types are correct without casts.
In `@packages/1-framework/3-tooling/migration/src/enumerate-migration-spaces.ts`:
- Around line 23-24: Replace the prose attributions in comments that reference
transient artifacts with direct behavioral descriptions: remove phrases like
"slice's edge-case ruling" and "slice spec calls out" and instead state the
concrete behavior (e.g., "ignore rows without a `(refs)` decoration" and "this
function treats missing refs as non-migration candidates"). Edit the comment
blocks that contain those quoted phrases in enumerate-migration-spaces.ts so
they describe the rule/behavior itself rather than attributing it to a spec or
slice.
---
Nitpick comments:
In `@packages/1-framework/3-tooling/cli/src/commands/migration-list.ts`:
- Around line 136-137: Remove the prose attribution "spec § Empty-state + the
`migrations/` missing edge case" from the inline comment in migration-list.ts
and rewrite the comment to state the constraint directly: explain that the
renderer's empty-state path may point to a directory (for example when it is
"migrations/") and that callers must handle that missing-edge-case accordingly.
Update the comment near the existing "renderer's empty-state path" note so it no
longer references a spec section and clearly describes the
directory-name/migrations/ missing-edge-case constraint.
In `@packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts`:
- Around line 132-133: Edit the inline comment that currently starts with "slice
spec § Empty-state." in cli-errors.ts: remove the "spec-section" attribution and
the "§ Empty-state" marker so the comment reads as a plain explanation that this
error fires only when `<projectMigrationsDir>/<spaceId>` does not exist on disk;
keep the explanatory text but strip any reference to spec sections or special
symbols.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 06abe126-4bea-462e-a80e-201e7c7dc3df
📒 Files selected for processing (51)
docs/drive/README.mddocs/drive/design-decisions/2026-05-28-artifact-cascade-redesign.mddocs/drive/model.mddocs/drive/principles/brief-discipline.mddocs/drive/principles/decomposition-and-cost.mddocs/drive/principles/definition-of-ready.mddocs/drive/principles/protocol-as-memory.mddocs/drive/principles/roles-and-personas.mddocs/drive/principles/sizing.mddocs/drive/principles/spikes.mddocs/drive/workflow.mddrive/calibration/dod.mddrive/calibration/failure-modes.mddrive/calibration/sizing.mddrive/health/README.mdpackages/1-framework/3-tooling/cli/src/commands/migration-list.tspackages/1-framework/3-tooling/cli/src/utils/cli-errors.tspackages/1-framework/3-tooling/cli/src/utils/formatters/migration-list-render.tspackages/1-framework/3-tooling/cli/test/commands/migration-list.test.tspackages/1-framework/3-tooling/cli/test/utils/formatters/migration-list-render.test.tspackages/1-framework/3-tooling/migration/package.jsonpackages/1-framework/3-tooling/migration/src/enumerate-migration-spaces.tspackages/1-framework/3-tooling/migration/src/exports/enumerate-migration-spaces.tspackages/1-framework/3-tooling/migration/src/exports/migration-list-types.tspackages/1-framework/3-tooling/migration/src/migration-list-types.tspackages/1-framework/3-tooling/migration/test/enumerate-migration-spaces.test.tspackages/1-framework/3-tooling/migration/tsdown.config.tsskills-contrib/drive-bootstrap-context/SKILL.mdskills-contrib/drive-bootstrap-context/templates/plan.mdskills-contrib/drive-bootstrap-context/templates/spec.mdskills-contrib/drive-build-workflow/SKILL.mdskills-contrib/drive-build-workflow/templates/dispatch-brief.template.mdskills-contrib/drive-check-health/SKILL.mdskills-contrib/drive-check-health/templates/rollup.template.mdskills-contrib/drive-create-plan/SKILL.mdskills-contrib/drive-create-project/SKILL.mdskills-contrib/drive-create-spec/SKILL.mdskills-contrib/drive-deliver-workflow/SKILL.mdskills-contrib/drive-discussion/SKILL.mdskills-contrib/drive-plan-project/SKILL.mdskills-contrib/drive-plan-project/templates/plan.template.mdskills-contrib/drive-plan-slice/SKILL.mdskills-contrib/drive-plan-slice/templates/plan.template.mdskills-contrib/drive-run-retro/SKILL.mdskills-contrib/drive-run-retro/templates/retro-entry.template.mdskills-contrib/drive-specify-project/SKILL.mdskills-contrib/drive-specify-project/templates/spec.template.mdskills-contrib/drive-specify-slice/SKILL.mdskills-contrib/drive-specify-slice/templates/spec.template.mdskills-contrib/drive-start-workflow/SKILL.mdskills-contrib/drive-triage-work/SKILL.md
💤 Files with no reviewable changes (2)
- skills-contrib/drive-create-plan/SKILL.md
- skills-contrib/drive-create-spec/SKILL.md
0de8e29 to
52a3493
Compare
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/extension-cipherstash
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/emitter
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
|
Actionable comments posted: 0 |
Introduce MigrationListEntry/MigrationSpaceListEntry/MigrationListResult types and a pure renderMigrationList() formatter with snapshot tests covering baseline, self-edge, convergence, branching, multi-space, and empty-state shapes. Command wire-up remains for a follow-up dispatch. Signed-off-by: Will Madden <[email protected]>
Use a uniform 2-space prefix between the destination column (hash or
blank) and the {invariants}/(refs) block, so self-edge rows align with
non-self rows at the decoration boundary. Add a byte-for-byte fixture
pinning the slice-spec 5-row worked example to catch future drift.
Signed-off-by: Will Madden <[email protected]>
Move MigrationListEntry / MigrationSpaceListEntry / MigrationListResult from @prisma-next/cli into @prisma-next/migration-tools under the new ./migration-list-types sub-export. Types now sit with the data layer that produces them rather than the presentation layer that consumes them; this also lets the upcoming enumeration helper return them without inverting the package-level dependency direction. The renderer's import path is the only consumer that changes. Behaviour and public renderer signature are unchanged; D1 renderer tests pass as-is. Signed-off-by: Will Madden <[email protected]>
Add enumerateMigrationSpaces() and resolveRefsByContractHash() under a new @prisma-next/migration-tools/enumerate-migration-spaces sub-export. Per contract space under <projectMigrationsDir>/, the enumerator loads the on-disk packages, attaches every ref name whose hash matches each migration's destination contract, sorts within the space by dirName descending (latest first), and orders the resulting spaces with app first when present then lex-asc on remaining space ids. A space dir with no migrations becomes an empty MigrationSpaceListEntry so the renderer's empty-state path can surface it. Orphan refs (refs pointing at a hash no migration on disk produces) are intentionally absent from the output per the slice spec's edge table — `migration list` lists migrations, not refs. Signed-off-by: Will Madden <[email protected]>
Wires D1's renderer and D2's enumerator into `prisma-next migration
list`, deleting the buggy `findPath(empty, leaf)` code path that
silently omitted every migration except the longest chain. The shell
now reads every on-disk migration across every contract space, latest
first, with full graph context per row (source → destination, self-edge
glyph, `{invariants}`, `(refs)`).
Refactor highlights:
- Extracts a pure-ish `runMigrationList({ migrationsDir, spaceFilter })`
core that owns enumeration, --space narrowing, empty-state synthesis,
and structured-error surfacing. The CLI shell wires `loadConfig` →
`resolveMigrationPaths` → core → renderer in a one-screen body. The
core has no dependency on `loadConfig` or the command builder, which
keeps AC tests free of `vi.mock` plumbing.
- Adds `--space <id>` flag. Invalid syntax → `MIGRATION.INVALID_SPACE_ID`;
unknown space dir → `MIGRATION.SPACE_NOT_FOUND` (with available-space
suggestions). Empty-state for an existing-but-empty space dir still
exits 0 per spec § Empty-state.
- Deletes the legacy `MigrationListEntry` / `MigrationListResult` inline
types (now sourced from `@prisma-next/migration-tools/migration-list-types`
per D2's Option D promotion).
- Adds the JSON output guarantee: unconditionally grouped by contract
space, matching `MigrationListResult` exactly, full sha256 hashes
preserved (no abbreviation).
- Useless self-edge (`from === to`, zero `providedInvariants`) lists
like any other migration with an empty decoration column, per the
amended spec edge-case table.
Tests target the core directly (no module mocks), build real fixture
trees in tmpdirs, and verify human output via the shared renderer.
15 tests pin AC-16/17/18 plus the slice DoD shapes (single-branch,
sub-branches, wide-fan, sequential-diamonds, rollback, skip-rollback),
multi-contract-space, self-edge with invariants, useless self-edge,
convergence, and empty-state. The byte-for-byte spec worked-example
fixture is asserted via `.toBe(...)` so the renderer can't silently
re-anchor it.
Signed-off-by: Will Madden <[email protected]>
Rewrites the file-level JSDoc opener and six describe/it strings in migration-list.test.ts to describe what each test exercises rather than which AC/dispatch ID pins it. Transient project-planning IDs (AC-7, AC-10, AC-13, AC-16, AC-17, AC-18, D3) decay silently once the slice closes; their describe/it parentheticals leave readers chasing identifiers with no live home. Test bodies, assertions, and fixtures are untouched. Signed-off-by: Will Madden <[email protected]>
…esson
- Retro lesson 2 lands as .cursor/rules/prefer-direct-imports-over-module-mocks.mdc:
prefer extracting a pure-ish core function so tests import it directly,
rather than reaching for vi.mock / vi.resetModules / vi.setConfig.
Canonical repo precedent: runMigrationList({ migrationsDir, spaceFilter })
in packages/1-framework/3-tooling/cli/test/commands/migration-list.test.ts.
- projects/improve-migration-list-output/ deleted (transient per Drive
close-out convention; no long-lived methodology artefacts to migrate).
- Ref scans (rg -l 'improve-migration-list-output' outside the project dir)
returned zero hits — no external references to strip.
Signed-off-by: Will Madden <[email protected]>
…umeration
The enumerator was treating `migrations/refs/` as a phantom contract
space because `isValidSpaceId` is a purely syntactic check — it does
not know that `refs/` is the per-space reserved subdirectory name
(`migrations/<space>/refs/*.json`). A project with a top-level
`migrations/refs/` directory (e.g. ref files at the wrong layer, or a
user-named space called `refs`) ended up with output like:
refs:
There are no migrations in migrations/refs/ yet
Promotes the literal `refs` to a single source of truth in
`space-layout.ts` (`SPACE_REFS_DIRNAME`, `RESERVED_SPACE_SUBDIR_NAMES`,
`spaceRefsDirectory`) and consolidates the previously-duplicated string
across `enumerate-migration-spaces.ts`,
`read-contract-space-head-ref.ts`, and `emit-contract-space-artefacts.ts`.
The enumerator now filters reserved names out of the contract-space
candidate list before the `isValidSpaceId` check — applied
unconditionally, so a populated `migrations/refs/<...>/migration.json`
tree is also filtered (the recommended remediation is to rename the
space).
Regression coverage:
- `enumerate-migration-spaces.test.ts` now covers both
`refs/` containing a stray ref file alongside a valid `app/` space,
and `refs/` containing a migration-shaped subdirectory.
Signed-off-by: Will Madden <[email protected]>
Distinguishes hashes from dirNames from refs from invariants so the
output scans cleanly, in the spirit of `git log --decorate`. Colors
are suppressed for non-TTY stdout, `--no-color`, and `NO_COLOR=1` —
the JSON path is unaffected.
Palette:
- dirName: bold
- source contract hash: dim cyan
- destination contract hash: bright cyan
- `→` / `⟲` / `∅` glyphs: dim
- `{invariants}`: yellow
- `(refs)`: green; the live-DB `db` marker inside is green-bold
- `<spaceId>:` heading: bold
- summary line: dim
- empty-state line: dim
Factoring: the renderer at
`packages/1-framework/3-tooling/cli/src/utils/formatters/migration-list-render.ts`
gains a `MigrationListStyler` interface and a new
`renderMigrationListWithStyle(result, style)` entry point; the existing
`renderMigrationList(result): string` delegates with an identity
styler so the pure-text path (used by snapshot tests and the JSON
serializer fallback) is unchanged. A new
`migration-list-styler.ts` builds the ANSI styler from the
existing `TerminalUI.useColor` flag — that flag already respects
`--color`, `--no-color`, `NO_COLOR`, and TTY detection, so non-TTY
output is plain text by construction. Padding is always raw spaces
outside styled tokens so the visible column widths stay stable
regardless of what the styler emits.
Tests: existing renderer tests (15) continue to assert the pure-text
shape unchanged. A new `migration-list-styler.test.ts` pins per-token
SGR placement, the green-bold `db` special-case, the identity
collapse when `useColor: false`, and the visible-width invariant
(stripping ANSI from the styled output yields the plain-text
output).
Uses the repo-resident `colorette` package — no new dependencies.
Signed-off-by: Will Madden <[email protected]>
Per AGENTS.md, canonical rule home is .agents/rules/<rule>.mdc, with .cursor/rules/ and .claude/rules/ as presentation-symlink trees pointing into .agents/rules/ via relative paths (../../.agents/rules/<rule>.mdc). The previous close-out commit (6e96d45) placed the rule directly in .cursor/rules/ — correct body, wrong location. This fixup: - Moves the canonical file: .cursor/rules/... → .agents/rules/... - Adds symlink: .cursor/rules/prefer-direct-imports-over-module-mocks.mdc → ../../.agents/rules/prefer-direct-imports-over-module-mocks.mdc - Adds symlink: .claude/rules/prefer-direct-imports-over-module-mocks.mdc → ../../.agents/rules/prefer-direct-imports-over-module-mocks.mdc Scope: one rule only. Broader migration of the ~70 existing .cursor/rules/ real files to symlinks is out of scope for this commit. Signed-off-by: Will Madden <[email protected]>
`ensureSpaceExists` performed an independent `stat` call that disagreed with the enumerator's reserved-name exclusion: `refs/` is a valid directory on disk but is excluded by `enumerateMigrationSpaces` as a reserved per-space subdirectory. The mismatch meant `--space refs` bypassed `SPACE_NOT_FOUND` and fell through to the app empty-state instead of emitting a structured error. Fixed by deriving space existence, the available-spaces candidate list, and the scoped result entirely from the single `enumerateMigrationSpaces` traversal — the same source the renderer uses. This also removes the redundant extra disk walk that `ensureSpaceExists` was doing. Deleted: `ensureSpaceExists`, `isEnoent`, and the unused imports (`stat`, `listContractSpaceDirectories`, `spaceMigrationDirectory`). `SPACE_NOT_FOUND.availableSpaces` is now derived from `spaces.map(s => s.spaceId).sort()`. Regression test added: `emits MIGRATION.SPACE_NOT_FOUND for --space refs (reserved per-space subdirectory name)`. Signed-off-by: Will Madden <[email protected]>
- Replace manual spaceFilter object-spread with ifDefined helper
- Correct errorInvalidSpaceId why text to match isValidSpaceId ([a-z][a-z0-9_-]{0,63})
- Replace inline cast in migration-list test with runtime type guard
- Strip transient-artefact phrasing from enumerate-migration-spaces comments
- Lint: removed slice-spec references from migration-tools source comments (CI transient-ID rule)
Signed-off-by: Will Madden <[email protected]>
The rule file landed without YAML frontmatter, which pnpm lint:rules rejects; add the frontmatter block so the rules-lint check passes. Signed-off-by: Will Madden <[email protected]>
48b13a3 to
fad81c1
Compare
Linked issue
Refs TML-2697
Out-of-scope follow-ups: TML-2702 (
migration list --graphannotated-tree mode), TML-2701 (labels[]removal from migration model).At a glance
Before — silently incomplete; only migrations along the
findPath(empty, leaf)chain appear; refs and graph structure are invisible:After — every migration on disk, latest first, with contract-graph context inline:
Reviewer notes
This PR bundles two logical units. The 6 TML-2697 migration-list commits sit on top of 16 Drive workflow-skill commits that accumulated in this worktree's branch during the slice's implementation cycle. The Drive commits touch
docs/drive/,drive/, andskills-contrib/drive-*/. The migration-list changes are inpackages/1-framework/3-tooling/cli/andpackages/1-framework/3-tooling/migration/. Reviewers focused on TML-2697 can filter to those two directories.Largest single commit:
87bdaf115(feat(cli): rewrite migration list end-to-end). This rewritesmigration-list.ts, wires uprunMigrationList, adds the--spaceflag, and contains the bulk of the integration test suite. The core isrunMigrationList({ migrationsDir, spaceFilter })— a pure-ish function testable without the CLI shell.findPathdeleted. The legacyfindPath(empty, leaf)call is removed. It was the source of silent omission: it only returned path-reachable migrations. Replaced byenumerateMigrationSpaces, which walks every contract space on disk.Pre-existing CI failures (out of scope):
@prisma-next/postgrestypecheck — module-resolution failure confirmed pre-existing by the reviewer in D1 R1 of the code-review log; this branch touches no postgres package files.prisma-next-postgis-demo emitfixtures:check failure — unrelated to migration-list changes.18 acceptance criteria verified, 0 failing — full scoreboard and reviewer narrative in
projects/improve-migration-list-output/reviews/code-review.md. Final reviewer verdict: LGTM at0de8e29c8(D3 R2). Project artefacts (projects/improve-migration-list-output/) ship in the untracked directory and are cleaned up post-merge.Type contracts promoted to the data layer.
MigrationListEntry/MigrationSpaceListEntry/MigrationListResultlive at@prisma-next/migration-tools/migration-list-types, not inside the CLI package. This is a net-new sub-export with no breaking changes.Decision
This PR rewrites
prisma-next migration listend-to-end:New
enumerateMigrationSpaceshelper in@prisma-next/migration-tools— walks everymigrations/<space>/on disk, resolves refs frommigrations/<space>/refs/*.json, and returns every migration withrefs[]andprovidedInvariants[]attached, in reverse-filename order within each space, withappfirst across spaces.New
renderMigrationListrenderer in@prisma-next/cli— pure function, no I/O. Formats per-line output:<dirName> <from> → <to> {invariants} (refs), with⟲for self-edges,∅for baseline migrations, and conditional per-space headings (shown only when output spans more than one contract space).Rewritten
migration-list.ts— deletesfindPath(empty, leaf), adds--space <id>flag with structured CLI errors (MIGRATION.INVALID_SPACE_ID,MIGRATION.SPACE_NOT_FOUND), and wires up the enumeration + renderer in arunMigrationListcore separable from the CLI shell.Type contracts at the data layer —
MigrationListEntry,MigrationSpaceListEntry,MigrationListResultpromoted from CLI to@prisma-next/migration-tools/migration-list-types.How it fits together
Type contracts.
packages/1-framework/3-tooling/migration/src/migration-list-types.tsdefines the four types.migrationHashcarries the full sha256 in JSON; the renderer abbreviates to 7 chars for human output.from: string | nullcaptures baseline migrations (∅in output).refs[]andprovidedInvariants[]are always present (empty array when absent).Enumeration.
enumerateMigrationSpaces(migrationsDir)callslistContractSpaceDirectories→ filtersisValidSpaceId→ loads each space'sreadMigrationsDir→ resolves refs viaresolveRefsByContractHash(ENOENT-tolerant, lex-sorted per hash). Sort: within a space,compareDirNamesDescending; across spaces,compareSpaceIds(appfirst, then lex-asc). ThefindPathtandem that only returned path-reachable migrations is gone.Ref resolution.
resolveRefsByContractHashreadsmigrations/<space>/refs/*.json, indexes by destination contract hash, and returns aMap<contractHash, refName[]>. ENOENT is treated as "no refs." Each migration entry'srefs[]isrefsByHash.get(pkg.metadata.to) ?? []. Orphan refs (pointing at no on-disk destination) are retained in the map but never queried.Renderer.
renderMigrationList(spaces)auto-sizes thedirNamecolumn to longestdirName+ 2 spaces; hash columns fixed at 7 chars. Multi-space conditional heading is applied at the start of the render pass. Per-line:{invariants}before(refs), uniform 2-space decoration prefix.Command wire-up.
migration-list.tsexposesrunMigrationList({ migrationsDir, spaceFilter })as the pure-ish core (testable withoutloadConfig).createMigrationListCommandwraps it: reads config, callsprocess.exit.--spaceflag validated againstisValidSpaceIdfirst (syntactic), then against on-disk directories (semantic, withavailableSpaces[]payload).Integration tests.
migration-list.test.tsbuilds 14 migration packages spanning single-branch, sub-branches, wide-fan, sequential-diamonds, rollback, and skip-rollback shapes. The row-count-guarantee test assertsdirNames.length === specs.lengthfor both human and JSON output paths. JSON test asserts unconditional grouping, full sha256 hashes, and all metadata fields.What lands in this PR
TML-2697 migration-list commits (6):
fa3a41e12renderMigrationList) + type contracts at CLI layer0f8c495d0a8224de25@prisma-next/migration-toolsdata layer233a00271enumerateMigrationSpaces+resolveRefsByContractHash+ unit tests87bdaf115migration-list.ts, adds--spaceflag, wires up all layers0de8e29c8Drive workflow-skill commits (16): Rewrites of
skills-contrib/drive-*/SKILL.mdanddocs/drive/— lean shape, sibling templates, orphan-slice triage model, sizing by logical coherence. These are logically independent of TML-2697.18 acceptance criteria verified across all 6 TML-2697 commits (18 PASS / 0 FAIL) — full scoreboard in
projects/improve-migration-list-output/reviews/code-review.md.Testing performed
pnpm --filter @prisma-next/cli exec vitest run— 15/15 pass (migration-list.test.ts)pnpm --filter @prisma-next/cli exec vitest run test/utils/formatters/migration-list-render.test.ts— 12/12 passpnpm --filter @prisma-next/migration-tools exec vitest run— includesenumerate-migration-spaces.test.ts(multi-space enumeration + ref resolution)pnpm typecheck && pnpm lint:depsat CLI + migration-tools package scope@prisma-next/postgrestypecheck (pre-existing per D1 R1 reviewer triage);prisma-next-postgis-demo emitfixtures:check (unrelated to migration-list)Follow-ups
migration list --graphannotated-tree mode (designs preserved inprojects/improve-migration-list-output/design-notes.md)labels[]from migration modelAlternatives considered
findPath-based enumeration with a completeness overlay. Rejected. Walking the graph from empty to a chosen leaf is a path-selection algorithm, not a migration-survey; it cannot be patched to guarantee completeness without effectively replacing it.from, show onlyto). Rejected. Hiding the source hash conceals branching — two migrations sharing a source contract look identical in ato-only view. Explicitfrom → tochosen (matchesgit log --decoratesemantics).dbref with a special glyph (e.g.●). Rejected. The ref mechanism already carries thedbname; a special glyph adds visual noise without information gain. Uniform(refs)treatment chosen.git logbehaviour: grouping only when meaningful.Skill update
n/a — internal onlyfor the CLI output shape change. The new per-line format,--space <id>flag, and multi-contract-space behaviour should be documented in a follow-up skill update underpackages/0-shared/skills/. The@prisma-next/migration-tools/migration-list-typessub-export is net-new with no existing skill coverage.Checklist
git commit -s) per the DCO. The DCO status check will block merge if any commit is missing aSigned-off-by:trailer.TML-NNNN: <sentence-case title>form.Summary by CodeRabbit
New Features
Bug Fixes
Improvements
Tests