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

feat(cli): add graph renderer for migration status - #258

Merged
saevarb merged 29 commits into
mainfrom
feat/graph-renderer
Mar 27, 2026
Merged

saevarb merged 29 commits into
mainfrom
feat/graph-renderer

Conversation

@saevarb

@saevarb saevarb commented Mar 27, 2026 •

Copy link
Copy Markdown
Contributor

closes TML-2100

Intent

Replace the table-based migration status output with an ASCII graph renderer so users can see migration topology — branches, forks, diamonds, and rollback cycles — directly in their terminal. The default view answers "what would migration apply do?" by showing only the relevant subgraph (the apply path plus any forks that explain why action is needed). An opt-in --graph flag shows the full migration graph. This eliminates the AMBIGUOUS_LEAF crash on divergent graphs and introduces three-state edge status (applied/pending/unreachable) so users can see exactly which migrations are actionable.

Change map

The story

  1. Introduce a domain-agnostic graph renderer. A new graph-render.ts module uses Dagre for Sugiyama-style layout (rank assignment + coordinate placement), then stamps the result onto a CharGrid — a sparse character canvas that resolves box-drawing junctions, color priority, and label placement. The renderer knows nothing about migrations; it accepts RenderGraph (nodes with markers, edges with optional labels and color hints) and produces ASCII output. This is the bulk of new code (~1300 lines).

  2. Define generic graph types as a stable interface boundary. graph-types.ts introduces RenderGraph (immutable directed graph with adjacency-list indexing), GraphNode (with typed markers: db, contract, ref, custom), GraphEdge (with colorHint for CVD-safe edge coloring), and GraphRenderOptions (spine target, truncation limit, dagre overrides). These types form the contract between the migration-specific mapper and the domain-agnostic renderer.

  3. Build the migration-to-graph mapping layer. graph-migration-mapper.ts translates MigrationGraph + CLI status info into RenderGraph. It computes relevant paths with continuity-aware routing (tries marker→contract and ref→contract independently, not BFS shortest path from root), bakes status icons (✓/⧗/✗) into edge labels, sets colorHint for CVD-safe coloring, and attaches typed markers (db, contract, ref) to nodes.

  4. Rewrite target resolution to eliminate findLeaf. The old code called findLeaf(graph) as a fallback, which threw AMBIGUOUS_LEAF on divergent graphs. The new resolution chain is: --ref hash → contract hash (if in graph) → single reachable leaf → diverged full-graph fallback with a MIGRATION.DIVERGED diagnostic. This means migration status never crashes on a valid graph shape.

  5. Add three-state edge status derivation. deriveEdgeStatuses uses path analysis across the full graph to assign per-edge status: applied (root→marker path), pending (marker→target path, plus target→contract when a ref is active), and unreachable (root→target edges that are neither applied nor pending — the DB is on a different branch). Empty DB treats root as the effective marker.

  6. Replace the CLI output pipeline. The old formatMigrationStatusOutput (table-based formatter) is removed. The CLI handler now: (a) maps the status result to RenderGraph via migrationGraphToRenderInput, (b) extracts the relevant subgraph for the default view or passes the full graph for --graph, (c) detects linear graphs to use compact layout (ranksep: 1), (d) renders via graphRenderer.render(), and (e) appends a legend and summary with diagnostics. --limit/--all flags control truncation (default 10).

  7. Handle edge cases with early bail-outs and diagnostics. Marker-not-in-graph (DB managed via db update) bails out early with recovery hints. Contract-ahead fires when no migration produces the current contract hash. Detached contract nodes render with dashed connectors when the contract is not in the graph.

  8. Add prefix matching for migration plan --from. As a cross-command improvement discovered during testing, --from now supports prefix matching (with or without sha256: scheme), with disambiguation when multiple candidates match.

Behavior changes & evidence

Compatibility / migration / risk

  • Breaking change to CLI output format: migration status output changes from a table to an ASCII graph. Scripts parsing the old table format will break. The --json output is preserved and should be used for programmatic consumption.
  • JSON output shape expanded: MigrationStatusResult gains internal fields (graph, bundles, edgeStatuses, activeRefHash, activeRefName, diverged) but they are stripped before JSON serialization. The --json output shape is backward-compatible except that MigrationStatusEntry.status now includes 'unreachable' in addition to 'applied' | 'pending' | 'unknown'.
  • Diagnostic code renamed: MIGRATION.MARKER_DIVERGED → MIGRATION.MARKER_NOT_IN_GRAPH. Any automation matching on diagnostic codes will need updating.
  • findLeaf no longer called from migration status: The AMBIGUOUS_LEAF error can no longer be triggered by migration status. This is intentional — divergent graphs now render successfully.
  • New dependency: @dagrejs/dagre ^3.0.0 added to the CLI package. Pure JS, no native modules.
  • Performance: Dagre performance with 1000+ nodes is untested (spec targets <100ms). This is noted as an open item.

Known issues

  • deriveEdgeStatuses uses graph path, not ledger, for applied status (high): After db update, edges show as ✓ applied even though no migrations were executed. Requires adding readLedger() to the control plane stack and threading dirName/migrationId through the runner. See issue triage.
  • Cross-branch contract diagnostic gap (medium): When --ref staging is used and the contract is reachable only from a different branch, no diagnostic fires. The detached contract node also renders on the wrong branch.
  • Unreachable vs. backward edge color overlap (low): Both use magenta. These are different concepts and should be visually distinct.
  • MigrationStatusResult conflates internal and public shapes (medium): The --json handler manually strips internal fields. A dedicated public shape type would provide compile-time safety.

Follow-ups

  • User-facing language audit: Deferred to a separate PR (TML-2097) — some internal terms ("spine", "leaf") may still appear in edge cases.
  • JSON output field names: Exact shape agreed conceptually but not finalized.
  • migration plan needs optional --db support: So --from defaults to the DB marker when online, preventing unusable migrations.
  • Integration/journey tests for migration status: Added — 13 diagnostic journey tests in migration-status-diagnostics.e2e.test.ts.

Non-goals / intentionally out of scope

  • Interactive TUI: No scrolling, selection, or keyboard navigation.
  • Graphviz/DOT/SVG export: ASCII only; DOT renderer was deleted.
  • Graph editing/manipulation: Read-only display.
  • Rewriting findLeaf / findPath: These remain for migration plan and migration apply.

Made with Cursor

Summary by CodeRabbit

  • New Features

    • Prefix-based migration hash matching in migration plan.
    • New migration-status options: --graph, --limit, --all; terminal graph rendering with spine/truncation and legend.
    • Improved diagnostics and early-recovery guidance for DB/marker/contract inconsistencies.
    • JSON output now omits internal graph/debug fields.
  • Bug Fixes

    • Status text normalized to lowercase for consistent output.
  • Tests

    • Extensive unit and end-to-end tests added for graph rendering, edge-status derivation, and status diagnostics.
  • Chores

    • Added graph-rendering runtime dependency.

@coderabbitai

coderabbitai Bot commented Mar 27, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 238 files, which is 88 over the limit of 150.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 63a5fb66-26bb-40f5-a410-96f8cfbdb762

📥 Commits

Reviewing files that changed from the base of the PR and between 4a3aea3 and e5856b8.

⛔ Files ignored due to path filters (1)
  • packages/1-framework/3-tooling/cli/test/utils/formatters/__snapshots__/graph-render.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (238)
  • examples/prisma-next-demo/migration-fixtures/complex/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260302T1000_alice_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260302T1100_bob_add_avatar/ops.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260302T1200_staging_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260302T1200_staging_posts/ops.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260303T1000_merge_alice/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260303T1000_merge_alice/ops.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260303T1100_merge_bob/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260303T1100_merge_bob/ops.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260304T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260304T1000_add_comments/ops.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260305T1000_add_tags/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/20260305T1000_add_tags/ops.json
  • examples/prisma-next-demo/migration-fixtures/complex/refs.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260302T1000_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260302T1100_add_posts/ops.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260302T1200_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260302T1200_add_avatar/ops.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260303T1000_merge_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260303T1000_merge_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260303T1100_merge_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260303T1100_merge_posts/ops.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260303T1200_merge_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/20260303T1200_merge_avatar/ops.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/refs.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260302T1000_alice_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260302T1100_bob_add_avatar/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260302T1200_bob_experiment/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260302T1200_bob_experiment/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260303T1000_merge_alice/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260303T1000_merge_alice/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260303T1100_merge_bob/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260303T1100_merge_bob/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260303T1200_bob_experiment_2/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/20260303T1200_bob_experiment_2/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/refs.json
  • examples/prisma-next-demo/migration-fixtures/diamond/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/20260302T1000_alice_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/20260302T1100_bob_add_avatar/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond/20260303T1000_merge_alice/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/20260303T1000_merge_alice/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond/20260303T1100_merge_bob/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/20260303T1100_merge_bob/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond/refs.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260302T1000_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260302T1100_widen_email/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260302T1100_widen_email/ops.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260303T1000_email_default/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260303T1000_email_default/ops.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260304T1000_change_default/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260304T1000_change_default/ops.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260305T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260305T1000_add_posts/ops.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260306T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260306T1000_add_comments/ops.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260307T1000_kitchen_sink/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260307T1000_kitchen_sink/ops.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260308T1000_rollback/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260308T1000_rollback/ops.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260326T1428_migration/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/20260326T1428_migration/ops.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/refs.json
  • examples/prisma-next-demo/migration-fixtures/linear/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/linear/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/linear/20260302T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/linear/20260302T1000_add_posts/ops.json
  • examples/prisma-next-demo/migration-fixtures/linear/refs.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260302T1000_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260303T1000_add_bio/ops.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260304T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260304T1000_add_posts/ops.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260305T1000_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260305T1000_add_avatar/ops.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260306T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260306T1000_add_comments/ops.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260307T1000_add_tags/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260307T1000_add_tags/ops.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260307T1100_late_branch/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260307T1100_late_branch/ops.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260308T1000_add_everything/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/20260308T1000_add_everything/ops.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/refs.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260302T1000_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260302T1100_add_posts/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260302T1200_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260302T1200_add_avatar/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260303T1000_add_bio/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260326T1430_migration/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260326T1430_migration/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260326T1431_foobar/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260326T1431_foobar/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260326T1431_migration/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260326T1431_migration/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260326T1432_foobar/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/20260326T1432_foobar/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/refs.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260302T1000_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260302T1100_staging/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260302T1100_staging/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260303T1000_add_bio/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260304T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260304T1000_add_comments/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260305T1000_add_tags/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260305T1000_add_tags/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260306T1000_rollback_to_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/20260306T1000_rollback_to_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/refs.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/20260302T1000_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/20260303T1000_add_bio/ops.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/20260304T1000_rollback_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/20260304T1000_rollback_bio/ops.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/20260305T1000_rollback_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/20260305T1000_rollback_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/20260306T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/20260306T1000_add_posts/ops.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/refs.json
  • examples/prisma-next-demo/migration-fixtures/rollback/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/rollback/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/20260302T1000_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/rollback/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/20260303T1000_add_bio/ops.json
  • examples/prisma-next-demo/migration-fixtures/rollback/20260304T1000_rollback_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/20260304T1000_rollback_bio/ops.json
  • examples/prisma-next-demo/migration-fixtures/rollback/20260305T1000_rollback_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/20260305T1000_rollback_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260302T1000_alice_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260302T1100_bob_add_avatar/ops.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260303T1000_merge_1a/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260303T1000_merge_1a/ops.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260303T1100_merge_1b/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260303T1100_merge_1b/ops.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260304T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260304T1000_add_comments/ops.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260304T1100_add_posts_branch/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260304T1100_add_posts_branch/ops.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260305T1000_merge_2a/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260305T1000_merge_2a/ops.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260305T1100_merge_2b/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/20260305T1100_merge_2b/ops.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/refs.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/20260302T1000_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/20260302T1100_add_posts/ops.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/20260303T1000_add_bio/ops.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/refs.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/20260302T1000_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/20260303T1000_add_bio/ops.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/20260304T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/20260304T1000_add_posts/ops.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/20260305T1000_rollback_to_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/20260305T1000_rollback_to_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/20260306T1000_rollback_to_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/20260306T1000_rollback_to_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/20260302T1000_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/20260302T1100_add_posts/ops.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/20260303T1000_add_bio/ops.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/20260303T1100_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/20260303T1100_add_avatar/ops.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/refs.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/20260302T1000_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/20260302T1100_add_posts/ops.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/20260302T1200_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/20260302T1200_add_avatar/ops.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/20260302T1300_add_category/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/20260302T1300_add_category/ops.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/20260302T1400_add_settings/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/20260302T1400_add_settings/ops.json
  • examples/prisma-next-demo/prisma-next.config.ts
  • packages/1-framework/3-tooling/cli/package.json
  • packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-status.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/graph-migration-mapper.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/graph-render.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/graph-types.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/migrations.ts
  • packages/1-framework/3-tooling/cli/test/commands/derive-edge-statuses.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-plan.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-status.test.ts
  • packages/1-framework/3-tooling/cli/test/utils/formatters/graph-migration-mapper.test.ts
  • packages/1-framework/3-tooling/cli/test/utils/formatters/graph-render.test.ts
  • packages/1-framework/3-tooling/cli/test/utils/formatters/test-graphs.ts
  • packages/1-framework/3-tooling/cli/test/utils/graph-helpers.ts

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds graph rendering and mapping modules, integrates dagre for layout, refactors migration-status to compute per-edge statuses and render optional terminal graphs, introduces prefix-based migration bundle resolution, and adds extensive unit and integration tests for graph rendering and status diagnostics.

Changes

Cohort / File(s) Summary
Dependencies
packages/1-framework/3-tooling/cli/package.json
Added runtime dependency @dagrejs/dagre@^3.0.0.
Migration-plan
packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts
Added resolveBundleByPrefix exported helper; supports exact-or-prefix (auto-normalizes sha256:) resolution and distinct failure reasons (ambiguous / not found).
Migration-status CLI
packages/1-framework/3-tooling/cli/src/commands/migration-status.ts
Reworked to derive per-edge statuses via deriveEdgeStatuses, changed result/options types to include graph/edgeStatuses/refs/diverged, added early diagnostics for marker/contract inconsistencies, optional --graph/--all/--limit flags, and made some previously-exported helpers file-private.
Graph domain & mapping
packages/1-framework/3-tooling/cli/src/utils/formatters/graph-types.ts, .../graph-migration-mapper.ts
New typed graph model (RenderGraph, GraphNode, GraphEdge, NodeMarker), EdgeStatus/EdgeStatusKind, and migrationGraphToRenderInput mapping that builds nodes/edges, overlays markers, computes relevant paths and spine target.
Terminal graph renderer
packages/1-framework/3-tooling/cli/src/utils/formatters/graph-render.ts
New CharGrid-based terminal renderer with dagre-based layout integration, edge polyline stamping, label placement, colorized output, truncation/spine windowing, subgraph extraction, and public graphRenderer API plus helpers (truncateGraph, extractSubgraph, isLinearGraph).
Formatter cleanup
packages/1-framework/3-tooling/cli/src/utils/formatters/migrations.ts
Removed legacy formatMigrationStatusOutput and related status-entry rendering; remaining helpers simplified and color imports trimmed.
Tests — CLI/unit
packages/1-framework/3-tooling/cli/test/commands/*.test.ts
Added tests for deriveEdgeStatuses and resolveBundleByPrefix; reduced legacy migration-status unit tests to focus on refs error handling.
Tests — Graph renderer
packages/1-framework/3-tooling/cli/test/utils/formatters/graph-render.test.ts, .../test-graphs.ts
Added comprehensive graph fixtures (many named graphs), snapshot tests for rendering determinism and no-color mode, and tests for subgraph extraction, truncation behavior, and linearity detection.
Integration/E2E tests
test/integration/test/cli-journeys/*.e2e.test.ts
Added migration-status diagnostics e2e suite covering online/offline/marker/contract divergence scenarios; updated divergent-ref behavior and lowercased status text expectations across several journeys.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI
    participant FS as File/Bundle Reader
    participant Graph as Migration Graph Service
    participant Deriver as deriveEdgeStatuses
    participant Mapper as migrationGraphToRenderInput
    participant Layout as dagre (layout)
    participant Renderer as graphRenderer.render
    CLI->>FS: load refs, bundles, manifests
    CLI->>Graph: load migration graph, marker, contractHash
    CLI->>Deriver: deriveEdgeStatuses(graph, target, contract, marker, mode)
    Deriver-->>CLI: EdgeStatus[] (applied/pending/unreachable)
    CLI->>Mapper: map graph + EdgeStatus[] + refs + mode
    Mapper->>Layout: request node/edge layout
    Layout-->>Mapper: positioned polylines
    Mapper->>Renderer: render positioned graph with colors/labels/truncation
    Renderer-->>CLI: rendered terminal string
    CLI->>User: display output / JSON (omit internal fields in JSON)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Poem

🐇 I nibble nodes and hop on lines,

Applied and pending, little signs.
Dagre maps the winding trail,
Edges glow and stories tell—
The CLI hums, the rabbit smiles.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.93% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and specifically describes the main feature: adding a graph-based renderer for migration status output, replacing the previous table-based display.

✏️ 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 feat/graph-renderer

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 Mar 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/runtime-executor

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/runtime-executor@258

@prisma-next/sql-runtime

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/contract-authoring

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

@prisma-next/contract-ts

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/cli

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

@prisma-next/emitter

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

@prisma-next/eslint-plugin

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/eslint-plugin@258

@prisma-next/migration-tools

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

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

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

@prisma-next/family-sql

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

@prisma-next/sql-kysely-lane

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-kysely-lane@258

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

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

@prisma-next/sql-relational-core

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

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

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

@prisma-next/sql-lane

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-lane@258

@prisma-next/target-postgres

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

@prisma-next/adapter-postgres

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

@prisma-next/driver-postgres

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

@prisma-next/core-control-plane

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/core-control-plane@258

@prisma-next/core-execution-plane

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/core-execution-plane@258

@prisma-next/config

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

@prisma-next/contract

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

@prisma-next/operations

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

@prisma-next/plan

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

@prisma-next/utils

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

commit: e5856b8

@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: 2

🧹 Nitpick comments (4)
test/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.ts (1)

1-607: Consider splitting if this file grows further.

At ~608 lines, this file is slightly above the 500-line guideline. Given the comprehensive end-to-end nature covering 13 distinct diagnostic scenarios, it's acceptable as-is. However, if additional scenarios are added, consider splitting by category (offline/online/divergent).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.ts`
around lines 1 - 607, The test file describe('migration status diagnostics') is
long (~608 lines) and should be split if it grows further: extract grouped
describes into separate test files (e.g., offline scenarios, online scenarios,
divergent graph scenarios) while keeping shared helpers (setupJourney,
runMigrationStatus, runContractEmit, runMigrationPlan, runMigrationApply,
runDbUpdate, swapContract, useDevDatabase, timeouts) imported from
../utils/journey-test-helpers; preserve the top-level withTempDir wrapper or
replicate it in each new file to create temp dirs, and move related it(...)
blocks (like the offline "no migrations..." tests, the online "fresh DB..."
through "JSON output shape" tests, and the divergent/ref tests) into their own
files so each file stays under ~500 lines and test semantics remain identical.
packages/1-framework/3-tooling/cli/src/commands/migration-status.ts (1)

785-815: Minor inconsistency: formatStatusSummary uses result.migrations status but counts could differ from edgeStatuses.

buildMigrationEntries computes status via chain traversal, while deriveEdgeStatuses uses path analysis. For complex graphs (diamonds, forks), these could produce different counts.

Consider using edgeStatuses for consistency if mode === 'online':

💡 Suggested fix for consistent status counts
 function formatStatusSummary(result: MigrationStatusResult, colorize: boolean): string {
   const c = (fn: (s: string) => string, s: string) => (colorize ? fn(s) : s);
   const lines: string[] = [];

-  const hasUnknown = result.migrations.some((e) => e.status === 'unknown');
-  const pendingCount = result.migrations.filter((e) => e.status === 'pending').length;
+  const hasUnknown = result.mode === 'offline' || result.migrations.some((e) => e.status === 'unknown');
+  const pendingCount = result.edgeStatuses?.filter((e) => e.status === 'pending').length ?? 0;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/1-framework/3-tooling/cli/src/commands/migration-status.ts` around
lines 785 - 815, formatStatusSummary currently computes hasUnknown and
pendingCount from result.migrations which can differ from the edge-level
statuses produced by deriveEdgeStatuses/buildMigrationEntries for complex
graphs; update formatStatusSummary to use result.edgeStatuses (or
deriveEdgeStatuses result) when result.mode === 'online' to compute
hasUnknown/pendingCount so the summary reflects edge-level status counts
consistently, and guard for missing edgeStatuses by falling back to
result.migrations if needed (referencing formatStatusSummary, result.migrations,
result.edgeStatuses, deriveEdgeStatuses, buildMigrationEntries).
packages/1-framework/3-tooling/cli/src/utils/formatters/graph-migration-mapper.ts (1)

192-197: Fallback path uses last forward chain edge — verify this is always valid.

When no relevant paths are found, the code falls back to the tip of the forward chain. If forwardChain is empty, lastEdge is undefined and fallbackHash becomes EMPTY_CONTRACT_HASH, which may result in a single-node path.

This is acceptable as a defensive fallback, but consider adding a comment explaining this edge case.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/1-framework/3-tooling/cli/src/utils/formatters/graph-migration-mapper.ts`
around lines 192 - 197, The fallback branch handling relevantPaths === 0
currently takes the lastEdge from graph.forwardChain and uses
EMPTY_CONTRACT_HASH when forwardChain is empty, which can produce a single-node
path; update the block around relevantPaths, graph.forwardChain, lastEdge,
fallbackHash and addPathFromRoot to include a concise comment explaining that
when forwardChain is empty we intentionally fall back to EMPTY_CONTRACT_HASH
resulting in a single-node path as a defensive default, and ensure the comment
documents why that behavior is acceptable and when it will occur.
packages/1-framework/3-tooling/cli/src/utils/formatters/graph-render.ts (1)

792-824: Exponential variant enumeration is O(2^N) — acceptable for typical graphs.

The selectBestVariant function enumerates all 2^N combinations of bend directions. For typical migration graphs where dagre produces mostly orthogonal layouts, N (diagonal count) is usually 0-3, making this fine in practice.

Consider adding a guard if concerned about adversarial inputs:

💡 Optional safeguard for large diagonal counts
+  // Cap variant enumeration to avoid exponential blowup on pathological inputs
+  const MAX_DIAGONALS = 10;
+  if (diagCount > MAX_DIAGONALS) {
+    // Fall back to horizontal-first for all diagonals
+    const poly = buildVariant(rawPoints, bitsToBends(0, diagCount));
+    const labelPos = label ? findLabelPlacement(poly, label, grid, src.y) : undefined;
+    return { poly, labelPos };
+  }
+
   const numVariants = 1 << diagCount;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/1-framework/3-tooling/cli/src/utils/formatters/graph-render.ts`
around lines 792 - 824, selectBestVariant currently enumerates 2^diagCount
combinations via bitsToBends/buildVariant which can blow up for large or
adversarial diagCount; add a protective guard in selectBestVariant to cap work:
if diagCount exceeds a safe threshold (e.g., 10) then fall back to a
deterministic or greedy strategy (for example use bitsToBends(0) and a few
random/heuristic variants) or limit numVariants to a maximum and sample variants
instead of full enumeration; reference selectBestVariant, diagCount,
bitsToBends, buildVariant, countCorners, polyLength, and findLabelPlacement when
implementing the guard so the early-return or sampling uses the same scoring
logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/1-framework/3-tooling/cli/test/commands/migration-plan.test.ts`:
- Around line 338-387: The test currently only verifies there are two matching
candidates (candidates / prefix) but doesn't exercise the resolver or assert the
promised failure; replace or extend the test to call the actual resolver used
for `--from` resolution (the code that consumes readMigrationsDir results) with
the prefix 'sha256:abc' and assert it rejects/throws the ambiguity error (i.e.,
the ambiguous-prefix error path) instead of just checking candidates length;
locate the resolution logic that handles `--from` (the function invoked by the
migration plan command that resolves a migration by prefix) and make the test
assert that calling it with the packages and prefix results in the expected
thrown/rejected error.
- Around line 275-337: The "without sha256: scheme" test is tautological because
it used a needle that already contained "sha256:"; change it to use a plain
prefix (e.g. const prefix = 'abcdef') and then locate the migration by matching
the manifest.to with the scheme added (e.g. find package where
p.manifest.to.startsWith(`sha256:${prefix}`)), keeping the manifest.to assertion
and toContract equality; update the test named it('matches by prefix without
sha256: scheme', ...) to use that plain prefix and the adjusted find predicate
so the test verifies resolver behavior rather than mirroring the fixture.

---

Nitpick comments:
In `@packages/1-framework/3-tooling/cli/src/commands/migration-status.ts`:
- Around line 785-815: formatStatusSummary currently computes hasUnknown and
pendingCount from result.migrations which can differ from the edge-level
statuses produced by deriveEdgeStatuses/buildMigrationEntries for complex
graphs; update formatStatusSummary to use result.edgeStatuses (or
deriveEdgeStatuses result) when result.mode === 'online' to compute
hasUnknown/pendingCount so the summary reflects edge-level status counts
consistently, and guard for missing edgeStatuses by falling back to
result.migrations if needed (referencing formatStatusSummary, result.migrations,
result.edgeStatuses, deriveEdgeStatuses, buildMigrationEntries).

In
`@packages/1-framework/3-tooling/cli/src/utils/formatters/graph-migration-mapper.ts`:
- Around line 192-197: The fallback branch handling relevantPaths === 0
currently takes the lastEdge from graph.forwardChain and uses
EMPTY_CONTRACT_HASH when forwardChain is empty, which can produce a single-node
path; update the block around relevantPaths, graph.forwardChain, lastEdge,
fallbackHash and addPathFromRoot to include a concise comment explaining that
when forwardChain is empty we intentionally fall back to EMPTY_CONTRACT_HASH
resulting in a single-node path as a defensive default, and ensure the comment
documents why that behavior is acceptable and when it will occur.

In `@packages/1-framework/3-tooling/cli/src/utils/formatters/graph-render.ts`:
- Around line 792-824: selectBestVariant currently enumerates 2^diagCount
combinations via bitsToBends/buildVariant which can blow up for large or
adversarial diagCount; add a protective guard in selectBestVariant to cap work:
if diagCount exceeds a safe threshold (e.g., 10) then fall back to a
deterministic or greedy strategy (for example use bitsToBends(0) and a few
random/heuristic variants) or limit numVariants to a maximum and sample variants
instead of full enumeration; reference selectBestVariant, diagCount,
bitsToBends, buildVariant, countCorners, polyLength, and findLabelPlacement when
implementing the guard so the early-return or sampling uses the same scoring
logic.

In `@test/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.ts`:
- Around line 1-607: The test file describe('migration status diagnostics') is
long (~608 lines) and should be split if it grows further: extract grouped
describes into separate test files (e.g., offline scenarios, online scenarios,
divergent graph scenarios) while keeping shared helpers (setupJourney,
runMigrationStatus, runContractEmit, runMigrationPlan, runMigrationApply,
runDbUpdate, swapContract, useDevDatabase, timeouts) imported from
../utils/journey-test-helpers; preserve the top-level withTempDir wrapper or
replicate it in each new file to create temp dirs, and move related it(...)
blocks (like the offline "no migrations..." tests, the online "fresh DB..."
through "JSON output shape" tests, and the divergent/ref tests) into their own
files so each file stays under ~500 lines and test semantics remain identical.
🪄 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: c9badc60-f015-41d1-a925-527d89d064e8

📥 Commits

Reviewing files that changed from the base of the PR and between 9fd4f0c and cc0cd9d.

⛔ Files ignored due to path filters (5)
  • packages/1-framework/3-tooling/cli/test/utils/formatters/__snapshots__/graph-render.test.ts.snap is excluded by !**/*.snap
  • projects/graph-based-migrations/issue-triage.md is excluded by !projects/**
  • projects/graph-based-migrations/plans/migration-status-graph-rendering-plan.md is excluded by !projects/**
  • projects/graph-based-migrations/specs/migration-status-graph-rendering.spec.md is excluded by !projects/**
  • projects/graph-based-migrations/specs/target-resolution-design.md is excluded by !projects/**
📒 Files selected for processing (14)
  • packages/1-framework/3-tooling/cli/package.json
  • packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-status.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/graph-migration-mapper.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/graph-render.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/graph-types.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/migrations.ts
  • packages/1-framework/3-tooling/cli/src/utils/global-flags.ts
  • packages/1-framework/3-tooling/cli/test/commands/derive-edge-statuses.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-plan.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-status.test.ts
  • packages/1-framework/3-tooling/cli/test/utils/formatters/graph-render.test.ts
  • packages/1-framework/3-tooling/cli/test/utils/formatters/test-graphs.ts
  • test/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.ts

@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 (1)
test/integration/test/cli-journeys/divergence-and-refs.e2e.test.ts (1)

77-78: Use one object matcher for related status payload fields.

These are related checks on the same object and can be consolidated for consistency with test style rules.

♻️ Suggested refactor
-        expect(statusData.ok, 'L.04: ok').toBe(true);
-        expect(statusData.targetHash, 'L.04: target is C3 (contract hash)').toBe(c3Hash);
+        expect(statusData, 'L.04: status payload').toMatchObject({
+          ok: true,
+          targetHash: c3Hash,
+        });

As per coding guidelines, "**/*.test.ts: Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/integration/test/cli-journeys/divergence-and-refs.e2e.test.ts` around
lines 77 - 78, Replace the two separate assertions on the status payload with a
single object matcher: update the assertions on statusData (currently using
expect(statusData.ok) and expect(statusData.targetHash)) to one
expect(statusData).toMatchObject({ ok: true, targetHash: c3Hash }) so the
related fields are asserted together consistent with test style; ensure you
import or use toMatchObject from the test framework if needed and keep the
original message context if required.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/integration/test/cli-journeys/divergence-and-refs.e2e.test.ts`:
- Around line 77-78: Replace the two separate assertions on the status payload
with a single object matcher: update the assertions on statusData (currently
using expect(statusData.ok) and expect(statusData.targetHash)) to one
expect(statusData).toMatchObject({ ok: true, targetHash: c3Hash }) so the
related fields are asserted together consistent with test style; ensure you
import or use toMatchObject from the test framework if needed and keep the
original message context if required.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 2fcf4b13-4c44-4113-aeca-2c9006ed33b9

📥 Commits

Reviewing files that changed from the base of the PR and between cc0cd9d and 43f441a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • test/integration/test/cli-journeys/divergence-and-refs.e2e.test.ts
  • test/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.ts
  • test/integration/test/cli-journeys/multi-step-migration.e2e.test.ts
  • test/integration/test/cli-journeys/schema-evolution-migrations.e2e.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.ts

@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 (2)
packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts (2)

445-446: Avoid hardcoding the hash scheme at Line [445].

'sha256:' is duplicated here and can drift from the canonical hash format. Derive the scheme from a shared constant/helper instead.

Proposed refactor
 export function resolveBundleByPrefix<T extends { manifest: { to: string } }>(
   bundles: readonly T[],
   needle: string,
 ): Result<T, PrefixResolutionFailure> {
   const exact = bundles.find((p) => p.manifest.to === needle);
   if (exact) return ok(exact);

-  const prefixWithScheme = needle.startsWith('sha256:') ? needle : `sha256:${needle}`;
+  const hashScheme = EMPTY_CONTRACT_HASH.split(':', 1)[0]!;
+  const prefixWithScheme = needle.startsWith(`${hashScheme}:`)
+    ? needle
+    : `${hashScheme}:${needle}`;
   const candidates = bundles.filter((p) => p.manifest.to.startsWith(prefixWithScheme));

   if (candidates.length === 1) return ok(candidates[0]!);
   if (candidates.length > 1) return notOk({ reason: 'ambiguous', count: candidates.length });
   return notOk({ reason: 'not-found' });
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts` around
lines 445 - 446, The code hardcodes 'sha256:' when building prefixWithScheme and
filtering bundles; replace the literal with the canonical shared constant or
helper (e.g., HASH_SCHEME or getHashPrefix()) so the logic uses the single
source of truth: import the shared constant/helper and change the check/concat
around needle (the prefixWithScheme creation) and the bundles.filter predicate
(manifest.to.startsWith(prefixWithScheme)) to use that constant/helper instead
of the literal 'sha256:'.

428-437: Consider removing the long JSDoc for this internal helper.

The name/signature already communicates intent; this comment is likely unnecessary churn in command code.

As per coding guidelines: "Don't add comments if avoidable; prefer code which expresses its intent."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts` around
lines 428 - 437, Remove the long JSDoc block that begins "/** Resolve a
migration bundle by exact hash or prefix match..." which documents the internal
helper that resolves a migration bundle; instead delete the multi-line comment
block and, if a short hint is needed, replace it with a single-line comment or
rely on the function name/signature itself (the internal helper exported for
testing) to convey intent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts`:
- Around line 445-446: The code hardcodes 'sha256:' when building
prefixWithScheme and filtering bundles; replace the literal with the canonical
shared constant or helper (e.g., HASH_SCHEME or getHashPrefix()) so the logic
uses the single source of truth: import the shared constant/helper and change
the check/concat around needle (the prefixWithScheme creation) and the
bundles.filter predicate (manifest.to.startsWith(prefixWithScheme)) to use that
constant/helper instead of the literal 'sha256:'.
- Around line 428-437: Remove the long JSDoc block that begins "/** Resolve a
migration bundle by exact hash or prefix match..." which documents the internal
helper that resolves a migration bundle; instead delete the multi-line comment
block and, if a short hint is needed, replace it with a single-line comment or
rely on the function name/signature itself (the internal helper exported for
testing) to convey intent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 2e66855d-299b-4dab-8e5e-bbebd6bec652

📥 Commits

Reviewing files that changed from the base of the PR and between 43f441a and 4a3aea3.

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

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

Pre-emptive approval

This is a pre-emptive approval — the architecture is sound, the test coverage is strong, and the implementation is generally clean. Please address the inline comments below or respond explaining why you'd prefer not to, then merge without waiting for re-review.

Full review artifacts are on the branch at projects/graph-based-migrations/specs/reviews/pr-258/:

  • system-design-review.md
  • code-review.md (findings below are from this file)
  • walkthrough.md

What looks solid

  • Renderer architecture: CharGrid with direction bitmasks → box-drawing character resolution is elegant and correct. The color-priority system and ANSI run-batching are well-implemented.
  • 35+ topology test fixtures: The test-graphs.ts catalog is thorough and well-organized from simple to complex. The snapshot-based testing approach is appropriate for visual output.
  • deriveEdgeStatuses test coverage: 14 focused tests with clear scenario descriptions (not just "should X" — they explain the user situation).
  • E2e journey tests: 13 realistic end-to-end scenarios covering the full diagnostic matrix. These provide strong confidence in user-visible behavior.
  • Spec alignment: All checkable acceptance criteria are implemented and checked off.
  • CVD-safe palette: No red/green. Icons carry meaning independent of color. --no-color output is fully functional.
  • Commit history: Clean, logical commits with intent-focused messages. Each commit is a coherent unit.

Finding index

ID Severity Summary
F01 blocking formatStatusSummary uses result.migrations counts, diverges from edgeStatuses
F02 blocking Global-flags behavioral change is cross-cutting and underscoped
F03 non-blocking migration-plan.test.ts prefix tests are tautological
F04 non-blocking No unit tests for migrationGraphToRenderInput
F05 non-blocking MigrationStatusResult conflates internal and public shapes
F06 non-blocking Fallback path uses last forward-chain edge — fragile default
F07 non-blocking Exponential variant enumeration has no cap

Sævar Berg added 24 commits March 27, 2026 14:21
Add an ASCII graph renderer for `migration status` that visualizes the
migration DAG in the terminal. Uses dagre for automatic layout, then
stamps orthogonal polylines onto a CharGrid with box-drawing characters.

Key features:
- Default view shows relevant subgraph (union of paths to contract, DB, ref)
- `--graph` flag shows the full migration graph with all branches
- Applied/pending/diverged status icons (✓/⧗/✗) with CVD-safe colors
- Truncation with `--limit N` (default 10) and marker-aware expansion
- Detached contract node rendering when contract is ahead of migrations
- Prefix matching for `migration plan --from` flag

Includes project spec, plan, target resolution design doc, and issue triage.

Made-with: Cursor
- Fix empty DB (no marker) showing no status icons: treat root as
  effective marker so all edges to target are marked pending
- Fix marker-in-graph check: use graph.nodes.has() instead of checking
  the display chain, so DB on a different branch is recognized
- Fix relevant path computation: prefer ref→contract and marker→contract
  routes over independent BFS root→contract which may pick wrong branch
- Fix edge status derivation: also mark target→contract edges as pending
  when contract is reachable from the ref target
- Fix detached contract node alignment: align with bottom-most node
  instead of spine target
- Fix contract diagnostic: fire in diverged early-return path and when
  a ref is active, consolidate to fewer locations
- Bold node hashes for nodes with markers regardless of spine membership
- Legend always shows all statuses, rendered right after graph
- Improve diagnostic wording: "No migration exists for the current
  contract", "No path between database marker and ref", "multiple
  valid migration paths"

Made-with: Cursor
Bring spec and plan up to date with all implemented changes:
- Single renderer architecture (no registry, no --renderer flag)
- Three-state edge status (applied/pending/diverged via deriveEdgeStatuses)
- Continuity-aware relevant path computation
- Detached node alignment, legend, diagnostics
- All deleted files documented

Delete render-fixture.ts — fixture testing is done through the CLI
directly with switched migration dirs.

Made-with: Cursor
- Add dagreOptions to GraphRenderOptions for caller-controlled layout
- Default ranksep: 4 (branching), caller passes ranksep: 1 for linear
- Add isLinearGraph() to detect single-chain graphs at call site
- Delete graph-layout.ts (dead code from pre-Dagre layout engine)
- Remove dead types: BranchTree, LayoutNode, LayoutEdge, GraphLayout

Made-with: Cursor
…igration

Previously compared contractHash !== targetHash, which falsely fired
when --ref pointed to a different branch but the contract already had
a planned migration in the graph.

Made-with: Cursor
…ct node

- Bail out early when DB marker is not in the graph and differs from the
  contract hash (DB was updated outside the migration system). Shows a
  clear diagnostic with actionable hints instead of a confusing graph.
- When marker === contract and both are off-graph, proceed normally —
  the detached contract node now carries both db and contract markers.
- Fix summary icon: use warning when diagnostics contain warnings,
  not green checkmark.
- Triage: document ledger read gap (deriveEdgeStatuses uses graph path
  instead of ledger for applied status).

Made-with: Cursor
- Extract EdgeStatusKind ('applied' | 'pending' | 'diverged') and use
  it in EdgeStatus, MigrationStatusEntry, and STATUS_ICON map
- Replace conditional icon chain with STATUS_ICON record lookup
- Fix graph jargon: 'edge(s)' -> 'migration(s)' in summarizeRefDistance

Made-with: Cursor
'Unreachable' more accurately describes edges that apply cannot reach
from the current DB marker position. Update source, spec, and plan.

Made-with: Cursor
- Remove hasUnreachable from formatStatusSummary — buildMigrationEntries
  never sets 'unreachable', so the check was always false
- Guard CONTRACT.AHEAD diagnostic to only fire when targetHash is
  resolved, avoiding redundant diagnostic alongside MIGRATION.DIVERGED

Made-with: Cursor
- deriveEdgeStatuses: 14 tests covering linear chain, empty DB
  (undefined and root marker), fully applied, branching with marker
  on different branch, diamond deduplication, ref target with contract
  beyond, and off-graph contract
- isLinearGraph: 5 tests covering single node, linear chain, branching,
  detached nodes, and empty graph
- Add db update hint to MARKER_NOT_IN_GRAPH diagnostic
- Note test-graphs cleanup as open item in plan

Made-with: Cursor
- Rewrite test comments to explain user scenarios, not implementation
- Remove unreachable 'marker equals root' test (db sign always uses
  the contract hash, never the empty sentinel)
- Add 'empty contract hash' test for the beyondTarget guard
- Add 'diamond deduplication' test for assignedKeys correctness
- Triage: detached contract node placement with --ref on wrong branch

Made-with: Cursor
Spec:
- Fix remaining 'Diverged' → 'Unreachable' in edge status and palette
- Add known-gap note: CONTRACT.AHEAD missing when contract unreachable
  from chosen --ref branch

Plan:
- Remove completed 'reduce vertical spacing' from deferred items
- Add deriveEdgeStatuses and isLinearGraph to test coverage table

Issue triage:
- Delete resolved issues (branch labels, backward labels, target
  resolution) — all were bugs in the deleted edge-centric renderer
- Update backward edge misalignment with annotated snapshot
- Update spine terminology issue with current function names
- Add new issue: detached contract node placement with --ref

Made-with: Cursor
…ode review issues

Replace findDiagonalIndices index array with countDiagonals + inline
detection, eliminating a cross-array indexing pattern that was correct
but easy to misread. Introduce BendDirection type and bitsToBends helper
to replace raw numeric choices with self-documenting values.

Fix test-graphs node() helper to use GraphNode['style'] instead of
hardcoded 'detached' literal.

Triage two code review issues: lastEdge fallback (root fix is to make
unreadable contract a hard error) and MigrationStatusResult conflating
internal/public shapes.

Made-with: Cursor
The early bail-out at lines 522-561 already exits when the marker is
off-graph and differs from the contract. After that guard,
markerAccountedFor is always true, making both !markerAccountedFor
branches (summary and diagnostic) unreachable dead code.

Made-with: Cursor
…tries

The summary text ('N pending migrations') was computed from
buildMigrationEntries (chain-based logic), while the visual graph used
deriveEdgeStatuses (full-graph path analysis). When the DB marker was on
a different branch, the chain-based logic produced 'unknown' statuses
and the summary incorrectly said 'up to date'.

Move deriveEdgeStatuses call into executeMigrationStatusCommand so both
the summary and the visual use the same source of truth. Store edge
statuses on the result to avoid recomputation in the CLI handler.
Remove dead knownStatuses/hasKnownStatus functions.

Made-with: Cursor
- Fix --limit help text: default is 10, not 'show all'
- Replace green with cyan for summary checkmark (CVD-safe palette)
- Fix contract path routing: try both marker->contract and ref->contract
  independently so diamond collaboration graphs show both legs
- Merge double JSDoc on deriveEdgeStatuses into single block

Made-with: Cursor
- Check off all implemented acceptance criteria in spec
- Fix relevant-path wording to match implementation (tries both
  marker→contract and ref→contract independently)
- Add rationale for why the default view isn't a simple linear list
- Expand ledger issue with schema gap analysis and full fix plan
- Resolve spec TODOs, refine summary framing, add deferred items
- Update plan to reflect all code review fixes

Made-with: Cursor
…ract case

- Summary is now neutral ("N migration(s) on disk") instead of mixing
  explanation with action guidance
- Marker-not-in-graph diagnostic promoted to warn so hint renders in
  terminal output
- CONTRACT.AHEAD suppressed when marker === contract (both off-graph)
  to avoid redundant "run migration plan" guidance
- Extract determineLimit() helper for --limit flag parsing

Made-with: Cursor
13 end-to-end scenarios covering the summary, diagnostics, and hints
produced by `migration status` across realistic user situations:
offline empty, offline with contract, offline with migrations, fresh
DB, happy path, pending, contract ahead, marker off-graph (both
variants), JSON output shape, divergent graph, wrong-branch marker,
and ref resolution.

Also adds the MIGRATION.NO_MARKER diagnostic for fresh databases
(no marker row), which one of the journey tests exercises.

Made-with: Cursor
- Consolidate offline scenarios into single it() to fix chdir race
- Add timeout for offline test (runs emit + plan)
- Update divergence test: status auto-resolves via contract hash
- Lowercase status assertions to match new graph legend format

Made-with: Cursor
Extract inline --from prefix resolution into a testable function using
Result<T, PrefixResolutionFailure>. Update the ambiguous-prefix test to
call the actual resolver and assert the failure shape instead of just
counting candidates.

Made-with: Cursor
Sævar Berg added 5 commits March 27, 2026 14:21
Extract entry() and buildGraph() into shared test/utils/graph-helpers.ts.
Add 8 focused tests covering path computation (linear, diamond, unreachable
fallback, no-targets fallback), status icon/colorHint baking, spineTarget
resolution, ref markers, offline mode, and detached contract nodes.

Made-with: Cursor
Pass edgeStatuses into buildMigrationEntries so entries use the
graph-based status (applied/pending/unreachable) instead of the
chain-based heuristic. Eliminates divergence between summary counts
and graph display. 'unknown' now only appears in offline mode.

Made-with: Cursor
- Replace tautological Array.find() prefix tests with calls to
  resolveBundleByPrefix, exercising the actual resolver logic
- Fix "without sha256: scheme" test to actually omit the scheme
- Add timeout to graph render test describes for CI stability

Made-with: Cursor
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