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

TML-2801: bring the six migration read commands into consistency - #726

Merged
wmadden-electric merged 12 commits into
mainfrom
worktree/beautiful-curran-0fe9fd
Jun 5, 2026
Merged

wmadden-electric merged 12 commits into
mainfrom
worktree/beautiful-curran-0fe9fd

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Brings the migration read-verb family — status, list, graph, log, show, check — into line on the axes a prior audit flagged (projects/migration-graph-rendering/read-command-consistency-audit.md, findings F1–F7): JSON envelope shape, error path, params, decoration flags, help text, and multi-space behaviour. Most of it is wiring existing shared primitives into the commands that had drifted; one piece (multi-space check) is a real behaviour change. An extended parity test locks the conventions so they can't re-drift.

Changes

  • Unified --json envelopes (F3): migration log emitted a bare array and migration graph built its JSON inline; both now emit a { ok, … } object with a co-located exported type (MigrationLogResult → { ok, entries } incl. the empty case; MigrationGraphJsonResult). The other four already conformed.
  • One error path (F5): migration check's inline ref-resolution error strings now route through the shared mapRefResolutionError (matching show/status), preserving its PRECONDITION exit. A new requireLiveDatabase helper (cli-errors.ts) gives log and status one identical missing-DB envelope with meta.missingFlags.
  • Shared path grammar (F2): show's path-resolution helpers move to migration-path-target.ts and are now shared with check, so migration check <path> resolves a migration directory like show does; both positional help strings describe the same forms.
  • --ascii where glyphs are drawn (F4): status (which hardcoded unicode) and log's table now honour --ascii, matching list/graph. show/check draw no laned-tree glyphs and are unchanged.
  • Help-text polish (F6): check's see-also now links migration show; every JSON-emitting verb has a --json example; offline/live phrasing is uniform across the family.
  • migration check is multi-space (F1, the spine): the holistic check validated only the app space; it now validates every contract space by default, with --space <id> to narrow — reusing the same aggregate.spaces() enumeration and isValidSpaceId / errorInvalidSpaceId / errorSpaceNotFound machinery list uses. --space also runs the aggregate integrity pass filtered to that space, so narrowing never weakens validation. Single-target mode stays app-only (noted as a follow-up); exit codes and result shape are unchanged.
  • Parity test as the lock (D7): migration-read-commands-parity.test.ts (previously rendering-only) now asserts the { ok, … } envelope, see-also symmetry, the shared missing-DB error shape, and check's multi-space behaviour across all six verbs.

Why

The read-command redesign shipped list/graph/status/log as separate verbs incrementally, so consistency drifted: the same conceptual input (name a migration, name a contract space, hit a missing DB) was handled differently per command. Routing each command through the primitives that already existed — rather than inventing per-command behaviour — is both the fix and the guard against recurrence, which is why the parity test is part of the slice rather than a follow-up. The one genuine behaviour change, multi-space check, also closes a latent gap: integrity problems in non-app spaces previously passed silently.

check keeps its command-specific exit codes (OK/PRECONDITION/INTEGRITY_FAILED) — that's Style-Guide-sanctioned for a verify verb and intentionally left as-is.

Out of scope: migrate and the authoring verbs; the control-api ↔ CLI surface reconciliation (TML-2780); ref list; whether show/check should accept the contract-reference grammar; real --space on show (rejected — it resolves a single pinned migration).

Note for CI: the @prisma-next/cli package runs vitest with isolate: false, and there's a pre-existing order-dependent flake in test/control-api/client.test.ts (and occasionally migration-list-json-golden.test.ts) from config-loader mock bleed across files. It reproduces on the base tree with this branch's test files stashed, so it is not introduced here; the package typecheck, lint:deps, and targeted suites are clean, and the full suite passes on the large majority of runs.

Closes TML-2801.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added --ascii rendering; migration show accepts a migration directory path; migration check supports --space and multi-space checks.
  • Bug Fixes

    • Clearer missing-DB errors that include which flags are missing.
  • Refactor

    • Standardized JSON envelopes for read commands (ok + typed payloads) and more consistent CLI output and exit behavior; JSON output shapes for migration graph/log refined.

wmadden and others added 9 commits June 4, 2026 16:42
Make migration log emit { ok: true, entries: [...] } (including the empty
case) via an exported MigrationLogResult type, replacing the bare-array
output. Lift migration graph's inline --json envelope into an exported
MigrationGraphJsonResult type (wire shape unchanged). Update affected
JSON tests to the new log shape.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ssing-DB precondition (D2)

Route migration check ref-resolution failures through the shared
mapRefResolutionError factory (same envelope as show/status), preserving
check's PRECONDITION exit semantics. Extract a single requireLiveDatabase
precondition helper (connection + driver) emitting one PN-CLI-4005 envelope
with meta.missingFlags, called by both migration log and migration status;
status keeps its offline --from path.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Extract looksLikePath / resolveAppTargetPath / findPackageByDirPath from
migration-show into src/utils/migration-path-target.ts and import them in
both show and check. Give check filesystem-path support: when its positional
looks like a path it resolves via the shared helper, otherwise it falls back
to parseMigrationRef (D2 error routing) as before; no-arg whole-graph mode and
exit codes are unchanged. Align both positional argument help strings to the
identical accepted forms (directory name, hash/prefix, ref, or path).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
status hardcoded resolveGlyphMode(false) at both the legend and tree
render sites, so it could never produce ASCII output; thread
options.ascii === true into both. log table now takes a glyphMode and
swaps box-drawing divider/arrow/empty-source glyphs for ASCII when set.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ffline/live phrasing (D5)

check now links migration show in its see-also so the read-verb
cross-reference graph is symmetric. show and status gain --json
examples (every JSON-emitting read verb now demonstrates --json).
Offline verbs (list/graph/show/check) state "Offline — does not
consult the database." in one unbroken sentence; live verbs
(status/log) state "Requires a database connection."; log also notes
it merges all spaces. A focused help-text test locks these edits.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: wmadden-electric <[email protected]>
…ce to narrow) (D6)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: wmadden-electric <[email protected]>
…ions (D7)

Extends migration-read-commands-parity.test.ts with four new describe
blocks that lock the conventions established by D1–D6 against regressions:

- D1 lock (JSON envelope shape): verifies each of the six read verbs
  emits an object with an `ok` discriminator when called with `--json`
  rather than a bare array. Drives list, graph, status (--from), and
  check via the CLI shell with a vi.spyOn config mock; verifies show and
  log against their exported result types (type-level lock backed by
  per-command golden tests).

- D5 lock (see-also symmetry): asserts check links migration show in its
  see-also, every verb references ≥2 siblings, and the see-also graph
  has back-links (no one-way orphan entries).

- D2 lock (missing-DB error shape parity): asserts migration log and
  migration status both produce PN-CLI-4005 with meta.missingFlags:
  ['--db'] when no database is configured, confirming the shared
  requireLiveDatabase precondition produces identical envelopes.

- D6 lock (check multi-space): confirms enumerateCheckSpaces enumerates
  all spaces by default (app + postgis from the fixture), --space app
  narrows, and --space <unknown> emits a structured CliErrorEnvelope
  (not a bare array).

The existing pretty-rendering parity assertions are intact.

Mock isolation: the new tests use vi.spyOn (not vi.mock) so they add no
new mock-hoisting registrations and require only vi.restoreAllMocks() in
afterEach/afterAll — no additional afterAll cleanup needed.

Full-suite flake status: the pre-existing order-dependent flake in
migration-list-json-golden.test.ts and client.test.ts reproduces on the
base tree without these test files (verified via git stash); it is not
caused by this slice's additions.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: wmadden-electric <[email protected]>
…--space (F-1)

When --space <id> was passed, loadAggregateIntegrityViolations was entirely
skipped, meaning hash-mismatch and other aggregate-catalogue violations were
never checked for the narrowed space. Fix: always run loadAggregateIntegrityViolations,
then filter to violations attributable to the narrowed space (all variants with
spaceId === options.space, excluding disjointness which is inherently cross-space
with no single spaceId). The no-arg path keeps the unfiltered aggregate pass.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: wmadden-electric <[email protected]>
…pec/plan, review notes

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: wmadden-electric <[email protected]>
@wmadden-electric
wmadden-electric requested a review from a team as a code owner June 4, 2026 16:16
@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 7e63765d-5965-4612-8e5d-cd0afa73cb69

📥 Commits

Reviewing files that changed from the base of the PR and between bbeb25f and cb8f073.

📒 Files selected for processing (3)
  • packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-log.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-show.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/1-framework/3-tooling/cli/test/commands/migration-log.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-show.test.ts
  • packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts

📝 Walkthrough

Walkthrough

This PR refactors the migration check command to support multi-space integrity validation, standardizes JSON output across migration read commands with typed envelopes, adds ASCII-friendly glyph rendering, extracts path resolution utilities to a shared module, and extends error handling with consolidated database requirement checking.

Changes

CLI Commands & Features

Layer / File(s) Summary
Database Requirement Error Handling
packages/1-framework/1-core/errors/src/control.ts, packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts, packages/1-framework/3-tooling/cli/test/utils/require-live-database.test.ts
errorDatabaseConnectionRequired now accepts optional missingFlags array. New requireLiveDatabase helper consolidates DB connection and driver availability checks, returning a structured error with missingFlags metadata (e.g., ['--db']) when prerequisites are missing.
Migration Check Multi-Space Policy Core
packages/1-framework/3-tooling/cli/src/commands/migration-check.ts (core logic), packages/1-framework/3-tooling/cli/test/commands/migration-check-multi-space.test.ts
CheckSpace interface projects aggregate spaces into on-disk check inputs. enumerateCheckSpaces() discovers per-space migrations/refs/graphs. Per-space validators check manifest presence, package reachability via hash metadata, and dangling refs. runMigrationCheck() aggregates failures and supports optional space filtering.
Migration Check Command Execution & Integration
packages/1-framework/3-tooling/cli/src/commands/migration-check.ts, packages/1-framework/3-tooling/cli/test/commands/migration-check-{path-target,multi-space-command,ref-error}.test.ts
executeMigrationCheckCommand() returns outcome-based { result?, error?, exitCode } structure. Implements checkSingleTarget() to resolve and validate a single package via path or ref. CLI handler formats errors via formatErrorJson/formatErrorOutput and uses outcome exit code. Integration tests validate multi-space CLI behavior, path resolution, and error envelope output.
Path Resolution Utilities & Migration Show Refactoring
packages/1-framework/3-tooling/cli/src/utils/migration-path-target.ts, packages/1-framework/3-tooling/cli/src/commands/migration-show.ts, packages/1-framework/3-tooling/cli/test/commands/migration-show.test.ts
New utility module exports looksLikePath, resolveAppTargetPath, and findPackageByDirPath. Refactors migration-show to import these helpers instead of defining inline. Updates help text to mark command as offline and adds --json example. Tests validate path argument resolution.
JSON Envelope Standardization Across Read Commands
packages/1-framework/3-tooling/cli/src/commands/migration-graph.ts, packages/1-framework/3-tooling/cli/src/commands/migration-log.ts, packages/1-framework/3-tooling/cli/test/commands/{migration-graph,migration-log}.test.ts, packages/1-framework/3-tooling/cli/test/commands/read-commands-json-golden.test.ts
Introduces typed result interfaces: MigrationGraphJsonEdge/MigrationGraphJsonResult (graph output), MigrationLogResult (log output with ok: true and entries array). Refactors command --json output to serialize wrapped envelopes instead of raw data. Tests validate envelope structure and field types.
ASCII Glyph Rendering Mode Support
packages/1-framework/3-tooling/cli/src/utils/formatters/migration-log-table.ts, packages/1-framework/3-tooling/cli/src/commands/migration-log.ts, packages/1-framework/3-tooling/cli/src/commands/migration-status.ts, packages/1-framework/3-tooling/cli/test/commands/migration-legend-commands.test.ts, packages/1-framework/3-tooling/cli/test/utils/formatters/migration-log-table.test.ts
RenderMigrationLogTableOptions and formatter functions (formatHashEndpoint, formatHashTransition, styleHashTransition) now accept optional glyphMode parameter. When glyphMode: 'ascii', dividers use '-' and transitions render as - -> <hash> instead of box-drawing glyphs. --ascii flag added to migration-status and migration-log commands.
Read Verb Consistency & Parity Test Locks
packages/1-framework/3-tooling/cli/test/commands/migration-read-commands-parity.test.ts, packages/1-framework/3-tooling/cli/test/commands/migration-read-help-text.test.ts
Establishes D1 (JSON envelope { ok } shape), D2 (matching error codes for missing DB), D5 (symmetric see-also links), and D6 (multi-space check behavior) consistency locks across read verbs. Validates that every verb exposes --json example and correct offline/live-database wording in help text.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • prisma/prisma-next#704: Both PRs modify the migration log output pipeline—this PR adds --ascii/glyphMode support via glyph-aware migration-log-table hash formatting and JSON envelope shape, while the retrieved PR rewrites migration log to render a flat ledger-based table through the same formatter functions.

Suggested reviewers

  • wmadden

Poem

🐰 Spaces unite in harmony true,
Glyphs now speak in ASCII too,
Envelopes wrapped, so tidy and neat,
Check multi-space—integrity's sweet!
Paths resolved, and errors well-dressed,
This migration CLI just passed the test! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.38% 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 title directly and specifically summarizes the main objective: aligning six migration read commands with consistency findings, which matches the substantial refactoring across multiple command files, new helpers, and parity tests throughout the changeset.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree/beautiful-curran-0fe9fd

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

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

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

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

@prisma-next/middleware-cache

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/extension-postgis

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/cli-telemetry

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: cb8f073

@github-actions

github-actions Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 145.22 KB (0%)
postgres / emit 117.03 KB (0%)
mongo / no-emit 75.97 KB (0%)
mongo / emit 70.78 KB (0%)
cf-worker / no-emit 174.93 KB (0%)
cf-worker / emit 143.71 KB (+0.01% 🔺)

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

🧹 Nitpick comments (4)
packages/1-framework/3-tooling/cli/test/commands/migration-status-missing-db.test.ts (1)

6-12: ⚡ Quick win

Prefer vi.spyOn on a direct config-loader import instead of module-level vi.mock.

This mock/unmock pattern introduces cross-test lifecycle coupling; a direct import with vi.spyOn keeps the setup local and avoids worker-leak cleanup code.

Refactor sketch
+import * as configLoader from '../../src/config-loader';
 import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
 ...
-const mocks = vi.hoisted(() => ({
-  loadConfig: vi.fn(),
-}));
-
-vi.mock('../../src/config-loader', () => ({
-  loadConfig: mocks.loadConfig,
-}));
 ...
   beforeEach(() => {
-    vi.resetModules();
+    vi.spyOn(configLoader, 'loadConfig');
     const commandMocks = setupCommandMocks();
     consoleOutput = commandMocks.consoleOutput;
     cleanup = commandMocks.cleanup;
   });
 ...
-  afterAll(() => {
-    // Repo-wide vitest runs with `isolate: false`, so the `vi.mock` leaks
-    // into the next file in the same worker; unmock to restore it.
-    vi.doUnmock('../../src/config-loader');
-    vi.resetModules();
-  });
 ...
-    mocks.loadConfig.mockResolvedValue({ ...baseConfig, db: {} });
+    vi.mocked(configLoader.loadConfig).mockResolvedValue({ ...baseConfig, db: {} });
 ...
-    mocks.loadConfig.mockResolvedValue({ ...baseConfig, driver: undefined });
+    vi.mocked(configLoader.loadConfig).mockResolvedValue({ ...baseConfig, driver: undefined });

As per coding guidelines: **/*.{test,spec}.{ts,tsx,js,jsx}: Prefer direct imports over module mocks in test files.

Also applies to: 59-63

🤖 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/test/commands/migration-status-missing-db.test.ts`
around lines 6 - 12, Replace the module-level vi.mock of
'../../src/config-loader' with a direct import of the actual module and use
vi.spyOn to stub the loadConfig export; locate the current mocks.loadConfig
usage and remove the hoisted mocks object and vi.mock call, import { loadConfig
} from '../../src/config-loader' instead, and replace references to
mocks.loadConfig with a vi.spyOn(loadConfigModule,
'loadConfig').mockImplementation(...) (or mockResolvedValue) in the test setup
so the stub is local to the test and avoids cross-test lifecycle coupling.
packages/1-framework/3-tooling/cli/test/commands/migration-read-commands-parity.test.ts (2)

468-511: ⚡ Quick win

Remove newly added section/explanatory comments and rely on test names.

These comments are avoidable here since the surrounding describe/it blocks already express intent.

As per coding guidelines "Don't add comments if avoidable, prefer code that expresses its intent."

Also applies to: 588-590, 637-640, 706-708, 722-724, 781-783

🤖 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/test/commands/migration-read-commands-parity.test.ts`
around lines 468 - 511, Remove the newly added explanatory comment blocks that
sit above the test sections (the multi-line header comments like the one
immediately above the "D1 lock" tests) and rely on the surrounding describe/it
titles to convey intent; locate the block using nearby symbols such as
makeOfflineConfig and runAndCaptureExit and delete that comment section, and do
the same for the other similar comment blocks called out in the review (the
additional explanatory headers near other consistency-lock/read tests) so only
test code and descriptive test names remain.

474-496: ⚡ Quick win

Avoid whole-object as unknown as LoadedConfig casts in test fixtures.

These double-casts can hide config-shape drift; use typed literals (const cfg: LoadedConfig = …) so fixture mismatches fail at compile time.

As per coding guidelines "Minimize type casts: prefer explicit types that make casts unnecessary… never cast a whole object/class when casting one property would suffice."

Also applies to: 732-746

🤖 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/test/commands/migration-read-commands-parity.test.ts`
around lines 474 - 496, The test fixture uses a broad "as unknown as
LoadedConfig" cast in makeOfflineConfig which hides shape mismatches; change it
to construct a properly typed value (e.g., declare const cfg: LoadedConfig = {
... } and return cfg) or, if only a specific property is unrepresentable, cast
that single property only (e.g., mock returns typed as needed) instead of the
whole object; apply the same change to the other fixture instance noted (the
similar block around the later test). Ensure you keep the existing mocks
(vi.fn()) but surface any compile-time type errors by using the explicit
LoadedConfig type on the returned object rather than the double-cast.
packages/1-framework/3-tooling/cli/test/commands/migration-graph.test.ts (1)

22-28: ⚡ Quick win

Prefer direct import stubbing over module-level vi.mock in this test.

Please switch this setup to a direct import + vi.spyOn(...) stubbing pattern instead of hoisted module mocking, to keep test wiring closer to runtime behavior and align with repo test conventions.

Suggested refactor
-import { afterAll, afterEach, describe, expect, it, vi } from 'vitest';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import * as configLoader from '../../src/config-loader';
 ...
-const graphMocks = vi.hoisted(() => ({
-  loadConfig: vi.fn(),
-}));
-
-vi.mock('../../src/config-loader', () => ({
-  loadConfig: graphMocks.loadConfig,
-}));
+const loadConfigSpy = vi.spyOn(configLoader, 'loadConfig');
 ...
-  graphMocks.loadConfig.mockResolvedValue(graphBaseConfig(contractPath));
+  loadConfigSpy.mockResolvedValue(graphBaseConfig(contractPath));
   return contractPath;
 }
 ...
-  afterAll(() => {
-    vi.doUnmock('../../src/config-loader');
-  });
-
   afterEach(async () => {
 ...
-    vi.clearAllMocks();
+    vi.restoreAllMocks();
   });
As per coding guidelines, `**/*.{test,spec}.{ts,tsx,js,jsx}`: Prefer direct imports over module mocks in test files.
🤖 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/test/commands/migration-graph.test.ts`
around lines 22 - 28, Replace the hoisted module mock with a direct import and
spy: remove graphMocks and vi.mock('../../src/config-loader', ...) and instead
import { loadConfig } from '../../src/config-loader' at top of the test file,
then use vi.spyOn(module, 'loadConfig').mockImplementation(...) (or
mockResolvedValue/mockReturnValue as appropriate) to stub behavior; ensure any
cleanup uses vi.restoreAllMocks() or spy.mockRestore() so tests don't leak.
🤖 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.

Nitpick comments:
In `@packages/1-framework/3-tooling/cli/test/commands/migration-graph.test.ts`:
- Around line 22-28: Replace the hoisted module mock with a direct import and
spy: remove graphMocks and vi.mock('../../src/config-loader', ...) and instead
import { loadConfig } from '../../src/config-loader' at top of the test file,
then use vi.spyOn(module, 'loadConfig').mockImplementation(...) (or
mockResolvedValue/mockReturnValue as appropriate) to stub behavior; ensure any
cleanup uses vi.restoreAllMocks() or spy.mockRestore() so tests don't leak.

In
`@packages/1-framework/3-tooling/cli/test/commands/migration-read-commands-parity.test.ts`:
- Around line 468-511: Remove the newly added explanatory comment blocks that
sit above the test sections (the multi-line header comments like the one
immediately above the "D1 lock" tests) and rely on the surrounding describe/it
titles to convey intent; locate the block using nearby symbols such as
makeOfflineConfig and runAndCaptureExit and delete that comment section, and do
the same for the other similar comment blocks called out in the review (the
additional explanatory headers near other consistency-lock/read tests) so only
test code and descriptive test names remain.
- Around line 474-496: The test fixture uses a broad "as unknown as
LoadedConfig" cast in makeOfflineConfig which hides shape mismatches; change it
to construct a properly typed value (e.g., declare const cfg: LoadedConfig = {
... } and return cfg) or, if only a specific property is unrepresentable, cast
that single property only (e.g., mock returns typed as needed) instead of the
whole object; apply the same change to the other fixture instance noted (the
similar block around the later test). Ensure you keep the existing mocks
(vi.fn()) but surface any compile-time type errors by using the explicit
LoadedConfig type on the returned object rather than the double-cast.

In
`@packages/1-framework/3-tooling/cli/test/commands/migration-status-missing-db.test.ts`:
- Around line 6-12: Replace the module-level vi.mock of
'../../src/config-loader' with a direct import of the actual module and use
vi.spyOn to stub the loadConfig export; locate the current mocks.loadConfig
usage and remove the hoisted mocks object and vi.mock call, import { loadConfig
} from '../../src/config-loader' instead, and replace references to
mocks.loadConfig with a vi.spyOn(loadConfigModule,
'loadConfig').mockImplementation(...) (or mockResolvedValue) in the test setup
so the stub is local to the test and avoids cross-test lifecycle coupling.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 83d23237-043d-4e0d-a5d5-b6eca1fc094d

📥 Commits

Reviewing files that changed from the base of the PR and between b9c7119 and 1c60f50.

⛔ Files ignored due to path filters (5)
  • projects/migration-graph-rendering/read-command-consistency-audit.md is excluded by !projects/**
  • projects/migration-graph-rendering/read-command-consistency-followups.md is excluded by !projects/**
  • projects/migration-graph-rendering/slices/read-command-consistency/code-review.md is excluded by !projects/**
  • projects/migration-graph-rendering/slices/read-command-consistency/plan.md is excluded by !projects/**
  • projects/migration-graph-rendering/slices/read-command-consistency/spec.md is excluded by !projects/**
📒 Files selected for processing (23)
  • packages/1-framework/1-core/errors/src/control.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-check.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-graph.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-log.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-show.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-status.ts
  • packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/migration-log-table.ts
  • packages/1-framework/3-tooling/cli/src/utils/migration-path-target.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-check-multi-space-command.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-check-multi-space.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-check-path-target.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-check-ref-error.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-graph.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-legend-commands.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-log.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-read-commands-parity.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-read-help-text.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-show.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-status-missing-db.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/read-commands-json-golden.test.ts
  • packages/1-framework/3-tooling/cli/test/utils/formatters/migration-log-table.test.ts
  • packages/1-framework/3-tooling/cli/test/utils/require-live-database.test.ts

…or self-contained mock

migration-status-missing-db.test.ts was not self-contained: it used a
static import of createMigrationStatusCommand at the top of the file.
With isolate:false, if migration-status.ts was already loaded by a prior
file (without the config-loader mock active), vi.mock hoisting could not
re-patch the already-bound loadConfig reference. In CI's file ordering
(migration-read-help-text.test.ts precedes it and loads migration-status
without any mock), loadConfig ran for real, found no config file, and
threw errorConfigFileNotFound before reaching the requireLiveDatabase
precondition the tests assert.

Fix: remove the static import; use dynamic import inside each test body
(after vi.resetModules() in beforeEach). This ensures each test gets a
fresh module load where vi.mock intercepts config-loader correctly.

The pattern mirrors cross-consumer-integrity.test.ts and the other
well-behaved cli test files.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
wmadden and others added 2 commits June 5, 2026 06:01
…olate:false cleanup)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…rran-0fe9fd

Signed-off-by: Will Madden <[email protected]>

# Conflicts:
#	packages/1-framework/3-tooling/cli/src/utils/cli-errors.ts
@wmadden
wmadden force-pushed the worktree/beautiful-curran-0fe9fd branch from 98be567 to cb8f073 Compare June 5, 2026 04:05
@wmadden-electric
wmadden-electric merged commit e32d06b into main Jun 5, 2026
20 checks passed
@wmadden-electric
wmadden-electric deleted the worktree/beautiful-curran-0fe9fd branch June 5, 2026 04:17
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.

2 participants