Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

TML-2697: rewrite migration list — completeness, graph context, multi-space - #603

Merged
wmadden merged 13 commits into
mainfrom
tml-2697-improve-migration-list-output
May 29, 2026
Merged

wmadden merged 13 commits into
mainfrom
tml-2697-improve-migration-list-output

Conversation

@wmadden

@wmadden wmadden commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue

Refs TML-2697

Out-of-scope follow-ups: TML-2702 (migration list --graph annotated-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:

20260422T0720_initial  sha256:4cb4256c3…  11 op(s)
20260422T0742_migration  sha256:55bada2a4…  1 op(s)
20260422T0748_migration  sha256:2f45cc7b2…  2 op(s)
20260518T1701_namespaces_bookend  sha256:804e018ad…  0 op(s)

4 migration(s) on disk

After — every migration on disk, latest first, with contract-graph context inline:

20260601T1200_backfill_emails     55bada2 ⟲          {backfill_emails_v1} (production)
20260518T1701_namespaces_bookend  2f45cc7 → 804e018  (db)
20260422T0748_migration           55bada2 → 2f45cc7  (staging)
20260422T0742_migration           4cb4256 → 55bada2  (production)
20260422T0720_initial             ∅       → 4cb4256

Reviewer notes

  1. 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/, and skills-contrib/drive-*/. The migration-list changes are in packages/1-framework/3-tooling/cli/ and packages/1-framework/3-tooling/migration/. Reviewers focused on TML-2697 can filter to those two directories.

  2. Largest single commit: 87bdaf115 (feat(cli): rewrite migration list end-to-end). This rewrites migration-list.ts, wires up runMigrationList, adds the --space flag, and contains the bulk of the integration test suite. The core is runMigrationList({ migrationsDir, spaceFilter }) — a pure-ish function testable without the CLI shell.

  3. findPath deleted. The legacy findPath(empty, leaf) call is removed. It was the source of silent omission: it only returned path-reachable migrations. Replaced by enumerateMigrationSpaces, which walks every contract space on disk.

  4. Pre-existing CI failures (out of scope):

    • @prisma-next/postgres typecheck — 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 emit fixtures:check failure — unrelated to migration-list changes.
  5. 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 at 0de8e29c8 (D3 R2). Project artefacts (projects/improve-migration-list-output/) ship in the untracked directory and are cleaned up post-merge.

  6. Type contracts promoted to the data layer. MigrationListEntry / MigrationSpaceListEntry / MigrationListResult live 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 list end-to-end:

  1. New enumerateMigrationSpaces helper in @prisma-next/migration-tools — walks every migrations/<space>/ on disk, resolves refs from migrations/<space>/refs/*.json, and returns every migration with refs[] and providedInvariants[] attached, in reverse-filename order within each space, with app first across spaces.

  2. New renderMigrationList renderer 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).

  3. Rewritten migration-list.ts — deletes findPath(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 a runMigrationList core separable from the CLI shell.

  4. Type contracts at the data layer — MigrationListEntry, MigrationSpaceListEntry, MigrationListResult promoted from CLI to @prisma-next/migration-tools/migration-list-types.

How it fits together

  1. Type contracts. packages/1-framework/3-tooling/migration/src/migration-list-types.ts defines the four types. migrationHash carries the full sha256 in JSON; the renderer abbreviates to 7 chars for human output. from: string | null captures baseline migrations (∅ in output). refs[] and providedInvariants[] are always present (empty array when absent).

  2. Enumeration. enumerateMigrationSpaces(migrationsDir) calls listContractSpaceDirectories → filters isValidSpaceId → loads each space's readMigrationsDir → resolves refs via resolveRefsByContractHash (ENOENT-tolerant, lex-sorted per hash). Sort: within a space, compareDirNamesDescending; across spaces, compareSpaceIds (app first, then lex-asc). The findPath tandem that only returned path-reachable migrations is gone.

  3. Ref resolution. resolveRefsByContractHash reads migrations/<space>/refs/*.json, indexes by destination contract hash, and returns a Map<contractHash, refName[]>. ENOENT is treated as "no refs." Each migration entry's refs[] is refsByHash.get(pkg.metadata.to) ?? []. Orphan refs (pointing at no on-disk destination) are retained in the map but never queried.

  4. Renderer. renderMigrationList(spaces) auto-sizes the dirName column to longest dirName + 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.

  5. Command wire-up. migration-list.ts exposes runMigrationList({ migrationsDir, spaceFilter }) as the pure-ish core (testable without loadConfig). createMigrationListCommand wraps it: reads config, calls process.exit. --space flag validated against isValidSpaceId first (syntactic), then against on-disk directories (semantic, with availableSpaces[] payload).

  6. Integration tests. migration-list.test.ts builds 14 migration packages spanning single-branch, sub-branches, wide-fan, sequential-diamonds, rollback, and skip-rollback shapes. The row-count-guarantee test asserts dirNames.length === specs.length for 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):

Commit What it adds
fa3a41e12 Renderer (renderMigrationList) + type contracts at CLI layer
0f8c495d0 Fix: aligns self-edge decoration column with spec worked example
a8224de25 Promotes type contracts to @prisma-next/migration-tools data layer
233a00271 enumerateMigrationSpaces + resolveRefsByContractHash + unit tests
87bdaf115 Rewrites migration-list.ts, adds --space flag, wires up all layers
0de8e29c8 Drops transient AC/dispatch IDs from test names

Drive workflow-skill commits (16): Rewrites of skills-contrib/drive-*/SKILL.md and docs/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 pass
  • pnpm --filter @prisma-next/migration-tools exec vitest run — includes enumerate-migration-spaces.test.ts (multi-space enumeration + ref resolution)
  • pnpm typecheck && pnpm lint:deps at CLI + migration-tools package scope
  • Pre-existing failures not caused by this branch: @prisma-next/postgres typecheck (pre-existing per D1 R1 reviewer triage); prisma-next-postgis-demo emit fixtures:check (unrelated to migration-list)

Follow-ups

  • TML-2702 — migration list --graph annotated-tree mode (designs preserved in projects/improve-migration-list-output/design-notes.md)
  • TML-2701 — strip vestigial labels[] from migration model

Alternatives considered

  • Retaining 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.
  • Implicit source hash (omit from, show only to). Rejected. Hiding the source hash conceals branching — two migrations sharing a source contract look identical in a to-only view. Explicit from → to chosen (matches git log --decorate semantics).
  • db ref with a special glyph (e.g. ●). Rejected. The ref mechanism already carries the db name; a special glyph adds visual noise without information gain. Uniform (refs) treatment chosen.
  • Always showing per-space headings. Rejected. The single-space case (the common case) is cleaner without a heading. Conditional rule matches git log behaviour: grouping only when meaningful.

Skill update

n/a — internal only for 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 under packages/0-shared/skills/. The @prisma-next/migration-tools/migration-list-types sub-export is net-new with no existing skill coverage.

Checklist

  • All commits are signed off (git commit -s) per the DCO. The DCO status check will block merge if any commit is missing a Signed-off-by: trailer.
  • I read CONTRIBUTING.md and the change is scoped to one logical concern.
  • Tests are updated.
  • The PR title is in TML-NNNN: <sentence-case title> form.
  • The Skill update section above is filled in (see above — follow-up PR).

Summary by CodeRabbit

  • New Features

    • Add --space flag for per-contract-space migration listing; improved multi-space organization and single-line summary.
  • Bug Fixes

    • Clearer errors for invalid or missing space IDs, including suggested valid space names.
  • Improvements

    • Consistent, column-aligned migration list formatting with optional ANSI color styling; JSON output remains structured.
  • Tests

    • Expanded test coverage validating rendering, JSON shape, filtering, refs, ordering, and error cases.

Review Change Stack

@wmadden
wmadden requested a review from a team as a code owner May 28, 2026 13:13
@coderabbitai

coderabbitai Bot commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@wmadden, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: d61a856b-d43a-4004-9aee-ef1c425ddbe6

📥 Commits

Reviewing files that changed from the base of the PR and between 4101a97 and fad81c1.

📒 Files selected for processing (21)
  • .agents/rules/prefer-direct-imports-over-module-mocks.mdc
  • .claude/rules/prefer-direct-imports-over-module-mocks.mdc
  • .cursor/rules/prefer-direct-imports-over-module-mocks.mdc
  • packages/1-framework/3-tooling/cli/src/commands/migration-list.ts
  • packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/migration-list-render.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/migration-list-styler.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-list.test.ts
  • packages/1-framework/3-tooling/cli/test/utils/formatters/migration-list-render.test.ts
  • packages/1-framework/3-tooling/cli/test/utils/formatters/migration-list-styler.test.ts
  • packages/1-framework/3-tooling/migration/package.json
  • packages/1-framework/3-tooling/migration/src/emit-contract-space-artefacts.ts
  • packages/1-framework/3-tooling/migration/src/enumerate-migration-spaces.ts
  • packages/1-framework/3-tooling/migration/src/exports/enumerate-migration-spaces.ts
  • packages/1-framework/3-tooling/migration/src/exports/migration-list-types.ts
  • packages/1-framework/3-tooling/migration/src/exports/spaces.ts
  • packages/1-framework/3-tooling/migration/src/migration-list-types.ts
  • packages/1-framework/3-tooling/migration/src/read-contract-space-head-ref.ts
  • packages/1-framework/3-tooling/migration/src/space-layout.ts
  • packages/1-framework/3-tooling/migration/test/enumerate-migration-spaces.test.ts
  • packages/1-framework/3-tooling/migration/tsdown.config.ts
📝 Walkthrough

Walkthrough

Refactors 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.

Changes

Migration CLI Refactoring: Per-Contract-Space Enumeration

Layer / File(s) Summary
Type definitions and package exports
packages/1-framework/3-tooling/migration/src/migration-list-types.ts, packages/1-framework/3-tooling/migration/src/exports/*, packages/1-framework/3-tooling/migration/package.json, packages/1-framework/3-tooling/migration/tsdown.config.ts
Defines MigrationListEntry, MigrationSpaceListEntry, and MigrationListResult; adds barrel re-exports and new package export subpaths.
Shared space layout utilities
packages/1-framework/3-tooling/migration/src/space-layout.ts, packages/1-framework/3-tooling/migration/src/exports/spaces.ts, packages/1-framework/3-tooling/migration/src/emit-contract-space-artefacts.ts, packages/1-framework/3-tooling/migration/src/read-contract-space-head-ref.ts
Centralizes per-space refs path (SPACE_REFS_DIRNAME, spaceRefsDirectory) and updates emit/read artefact code to use helpers; re-exports helpers.
Migration enumeration and ref resolution
packages/1-framework/3-tooling/migration/src/enumerate-migration-spaces.ts
Adds resolveRefsByContractHash and enumerateMigrationSpaces that read refs, attach them by destination hash, include empty spaces, skip reserved/invalid dirs, sort spaces (APP first) and migrations (latest-first).
CLI core function and error handling
packages/1-framework/3-tooling/cli/src/commands/migration-list.ts, packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts
Extracts runMigrationList with RunMigrationListInputs, validates --space via isValidSpaceId, pre-checks filesystem existence (returns MIGRATION.SPACE_NOT_FOUND with suggestions), delegates enumeration, computes summary, and simplifies the CLI shell to delegate and render via shared formatter; adds errorInvalidSpaceId and errorSpaceNotFound.
Rendering with multi-space support
packages/1-framework/3-tooling/cli/src/utils/formatters/migration-list-render.ts
Adds renderMigrationListWithStyle/renderMigrationList: fixed-width aligned rows, abbreviated sha256: hashes, arrow glyphs (including self-edge), invariant {} and refs () decorations, per-space headings (suppressed for single-space), empty-state lines, and conditional summary append.
ANSI styling
packages/1-framework/3-tooling/cli/src/utils/formatters/migration-list-styler.ts
Adds createAnsiMigrationListStyler({useColor}) returning identity styler when disabled or colored token mappings when enabled; special styling for live db ref marker.
Tests: enumeration and refs
packages/1-framework/3-tooling/migration/test/enumerate-migration-spaces.test.ts
Vitest suite validating enumeration ordering, empty-space inclusion, ref attachment by destination hash, orphan ref omission, reserved-name handling, and multi-space end-to-end scenarios.
Tests: CLI command and rendering
packages/1-framework/3-tooling/cli/test/commands/migration-list.test.ts
Vitest suite for runMigrationList + rendering: worked example, row-count mapping, multi-space headings, convergence/ref decorations, self-edge variants, empty-state behaviors, --space filtering semantics, and structured error envelopes; also JSON shape assertions.
Tests: rendering formatter
packages/1-framework/3-tooling/cli/test/utils/formatters/migration-list-render.test.ts
Unit tests for many topology scenarios: baseline, forward edges, self-edges with invariants/refs, order preservation, convergence, branching, multi-space formatting, heading suppression, and byte-for-byte examples.
Tests: ANSI styling
packages/1-framework/3-tooling/cli/test/utils/formatters/migration-list-styler.test.ts
Validates createAnsiMigrationListStyler behaviors (color toggle, exact token wrapping), styled output shape, and layout preservation when ANSI sequences are stripped.
Testing guidance
.agents/... and .cursor/.claude rule symlinks
Adds documentation recommending direct imports over module mocks in tests and records symlinked rule paths.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Suggested reviewers

  • aqrln

Poem

"I hopped through folders, tracked each ref and trace,
From app-space first to extensions' gentle pace,
I stitched the hashes, colored headings bright,
And made the migration list a rabbit's delight! 🐰"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.03% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly describes the main objective: a complete rewrite of the migration list feature to improve completeness, add contract-graph context, and enable multi-space support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tml-2697-improve-migration-list-output

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (2)
packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts (1)

132-133: ⚡ Quick win

Remove 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 win

Drop 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

📥 Commits

Reviewing files that changed from the base of the PR and between bc310d2 and 0de8e29.

📒 Files selected for processing (51)
  • docs/drive/README.md
  • docs/drive/design-decisions/2026-05-28-artifact-cascade-redesign.md
  • docs/drive/model.md
  • docs/drive/principles/brief-discipline.md
  • docs/drive/principles/decomposition-and-cost.md
  • docs/drive/principles/definition-of-ready.md
  • docs/drive/principles/protocol-as-memory.md
  • docs/drive/principles/roles-and-personas.md
  • docs/drive/principles/sizing.md
  • docs/drive/principles/spikes.md
  • docs/drive/workflow.md
  • drive/calibration/dod.md
  • drive/calibration/failure-modes.md
  • drive/calibration/sizing.md
  • drive/health/README.md
  • packages/1-framework/3-tooling/cli/src/commands/migration-list.ts
  • packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/migration-list-render.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-list.test.ts
  • packages/1-framework/3-tooling/cli/test/utils/formatters/migration-list-render.test.ts
  • packages/1-framework/3-tooling/migration/package.json
  • packages/1-framework/3-tooling/migration/src/enumerate-migration-spaces.ts
  • packages/1-framework/3-tooling/migration/src/exports/enumerate-migration-spaces.ts
  • packages/1-framework/3-tooling/migration/src/exports/migration-list-types.ts
  • packages/1-framework/3-tooling/migration/src/migration-list-types.ts
  • packages/1-framework/3-tooling/migration/test/enumerate-migration-spaces.test.ts
  • packages/1-framework/3-tooling/migration/tsdown.config.ts
  • skills-contrib/drive-bootstrap-context/SKILL.md
  • skills-contrib/drive-bootstrap-context/templates/plan.md
  • skills-contrib/drive-bootstrap-context/templates/spec.md
  • skills-contrib/drive-build-workflow/SKILL.md
  • skills-contrib/drive-build-workflow/templates/dispatch-brief.template.md
  • skills-contrib/drive-check-health/SKILL.md
  • skills-contrib/drive-check-health/templates/rollup.template.md
  • skills-contrib/drive-create-plan/SKILL.md
  • skills-contrib/drive-create-project/SKILL.md
  • skills-contrib/drive-create-spec/SKILL.md
  • skills-contrib/drive-deliver-workflow/SKILL.md
  • skills-contrib/drive-discussion/SKILL.md
  • skills-contrib/drive-plan-project/SKILL.md
  • skills-contrib/drive-plan-project/templates/plan.template.md
  • skills-contrib/drive-plan-slice/SKILL.md
  • skills-contrib/drive-plan-slice/templates/plan.template.md
  • skills-contrib/drive-run-retro/SKILL.md
  • skills-contrib/drive-run-retro/templates/retro-entry.template.md
  • skills-contrib/drive-specify-project/SKILL.md
  • skills-contrib/drive-specify-project/templates/spec.template.md
  • skills-contrib/drive-specify-slice/SKILL.md
  • skills-contrib/drive-specify-slice/templates/spec.template.md
  • skills-contrib/drive-start-workflow/SKILL.md
  • skills-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

@wmadden
wmadden force-pushed the tml-2697-improve-migration-list-output branch from 0de8e29 to 52a3493 Compare May 28, 2026 14:23
@pkg-pr-new

pkg-pr-new Bot commented May 28, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

npm i https://pkg.pr.new/@prisma-next/extension-author-tools@603

@prisma-next/mongo-runtime

npm i https://pkg.pr.new/@prisma-next/mongo-runtime@603

@prisma-next/family-mongo

npm i https://pkg.pr.new/@prisma-next/family-mongo@603

@prisma-next/sql-runtime

npm i https://pkg.pr.new/@prisma-next/sql-runtime@603

@prisma-next/family-sql

npm i https://pkg.pr.new/@prisma-next/family-sql@603

@prisma-next/extension-arktype-json

npm i https://pkg.pr.new/@prisma-next/extension-arktype-json@603

@prisma-next/extension-cipherstash

npm i https://pkg.pr.new/@prisma-next/extension-cipherstash@603

@prisma-next/middleware-cache

npm i https://pkg.pr.new/@prisma-next/middleware-cache@603

@prisma-next/mongo

npm i https://pkg.pr.new/@prisma-next/mongo@603

@prisma-next/extension-paradedb

npm i https://pkg.pr.new/@prisma-next/extension-paradedb@603

@prisma-next/extension-pgvector

npm i https://pkg.pr.new/@prisma-next/extension-pgvector@603

@prisma-next/extension-postgis

npm i https://pkg.pr.new/@prisma-next/extension-postgis@603

@prisma-next/postgres

npm i https://pkg.pr.new/@prisma-next/postgres@603

@prisma-next/sql-orm-client

npm i https://pkg.pr.new/@prisma-next/sql-orm-client@603

@prisma-next/sqlite

npm i https://pkg.pr.new/@prisma-next/sqlite@603

@prisma-next/target-mongo

npm i https://pkg.pr.new/@prisma-next/target-mongo@603

@prisma-next/adapter-mongo

npm i https://pkg.pr.new/@prisma-next/adapter-mongo@603

@prisma-next/driver-mongo

npm i https://pkg.pr.new/@prisma-next/driver-mongo@603

@prisma-next/contract

npm i https://pkg.pr.new/@prisma-next/contract@603

@prisma-next/utils

npm i https://pkg.pr.new/@prisma-next/utils@603

@prisma-next/config

npm i https://pkg.pr.new/@prisma-next/config@603

@prisma-next/errors

npm i https://pkg.pr.new/@prisma-next/errors@603

@prisma-next/framework-components

npm i https://pkg.pr.new/@prisma-next/framework-components@603

@prisma-next/operations

npm i https://pkg.pr.new/@prisma-next/operations@603

@prisma-next/ts-render

npm i https://pkg.pr.new/@prisma-next/ts-render@603

@prisma-next/contract-authoring

npm i https://pkg.pr.new/@prisma-next/contract-authoring@603

@prisma-next/ids

npm i https://pkg.pr.new/@prisma-next/ids@603

@prisma-next/psl-parser

npm i https://pkg.pr.new/@prisma-next/psl-parser@603

@prisma-next/psl-printer

npm i https://pkg.pr.new/@prisma-next/psl-printer@603

@prisma-next/cli

npm i https://pkg.pr.new/@prisma-next/cli@603

@prisma-next/cli-telemetry

npm i https://pkg.pr.new/@prisma-next/cli-telemetry@603

@prisma-next/emitter

npm i https://pkg.pr.new/@prisma-next/emitter@603

@prisma-next/migration-tools

npm i https://pkg.pr.new/@prisma-next/migration-tools@603

prisma-next

npm i https://pkg.pr.new/prisma-next@603

@prisma-next/vite-plugin-contract-emit

npm i https://pkg.pr.new/@prisma-next/vite-plugin-contract-emit@603

@prisma-next/mongo-codec

npm i https://pkg.pr.new/@prisma-next/mongo-codec@603

@prisma-next/mongo-contract

npm i https://pkg.pr.new/@prisma-next/mongo-contract@603

@prisma-next/mongo-value

npm i https://pkg.pr.new/@prisma-next/mongo-value@603

@prisma-next/mongo-contract-psl

npm i https://pkg.pr.new/@prisma-next/mongo-contract-psl@603

@prisma-next/mongo-contract-ts

npm i https://pkg.pr.new/@prisma-next/mongo-contract-ts@603

@prisma-next/mongo-emitter

npm i https://pkg.pr.new/@prisma-next/mongo-emitter@603

@prisma-next/mongo-schema-ir

npm i https://pkg.pr.new/@prisma-next/mongo-schema-ir@603

@prisma-next/mongo-query-ast

npm i https://pkg.pr.new/@prisma-next/mongo-query-ast@603

@prisma-next/mongo-orm

npm i https://pkg.pr.new/@prisma-next/mongo-orm@603

@prisma-next/mongo-query-builder

npm i https://pkg.pr.new/@prisma-next/mongo-query-builder@603

@prisma-next/mongo-lowering

npm i https://pkg.pr.new/@prisma-next/mongo-lowering@603

@prisma-next/mongo-wire

npm i https://pkg.pr.new/@prisma-next/mongo-wire@603

@prisma-next/sql-contract

npm i https://pkg.pr.new/@prisma-next/sql-contract@603

@prisma-next/sql-errors

npm i https://pkg.pr.new/@prisma-next/sql-errors@603

@prisma-next/sql-operations

npm i https://pkg.pr.new/@prisma-next/sql-operations@603

@prisma-next/sql-schema-ir

npm i https://pkg.pr.new/@prisma-next/sql-schema-ir@603

@prisma-next/sql-contract-psl

npm i https://pkg.pr.new/@prisma-next/sql-contract-psl@603

@prisma-next/sql-contract-ts

npm i https://pkg.pr.new/@prisma-next/sql-contract-ts@603

@prisma-next/sql-contract-emitter

npm i https://pkg.pr.new/@prisma-next/sql-contract-emitter@603

@prisma-next/sql-lane-query-builder

npm i https://pkg.pr.new/@prisma-next/sql-lane-query-builder@603

@prisma-next/sql-relational-core

npm i https://pkg.pr.new/@prisma-next/sql-relational-core@603

@prisma-next/sql-builder

npm i https://pkg.pr.new/@prisma-next/sql-builder@603

@prisma-next/target-postgres

npm i https://pkg.pr.new/@prisma-next/target-postgres@603

@prisma-next/target-sqlite

npm i https://pkg.pr.new/@prisma-next/target-sqlite@603

@prisma-next/adapter-postgres

npm i https://pkg.pr.new/@prisma-next/adapter-postgres@603

@prisma-next/adapter-sqlite

npm i https://pkg.pr.new/@prisma-next/adapter-sqlite@603

@prisma-next/driver-postgres

npm i https://pkg.pr.new/@prisma-next/driver-postgres@603

@prisma-next/driver-sqlite

npm i https://pkg.pr.new/@prisma-next/driver-sqlite@603

commit: 48b13a3

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Actionable comments posted: 0

wmadden added 13 commits May 29, 2026 09:01
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]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant