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

feat(cli): color migration graph lanes + add --legend (TML-2773) - #674

Merged
wmadden merged 12 commits into
mainfrom
tml-2773-migration-graph-lane-colors-legend
Jun 2, 2026
Merged

wmadden merged 12 commits into
mainfrom
tml-2773-migration-graph-lane-colors-legend

Conversation

@wmadden-electric

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

Copy link
Copy Markdown
Contributor
SnapDragon-Cursor-2026-06-02_15-44-33

Summary

Makes migration graph --tree output readable in color and adds an optional --legend key (TML-2773).

  • Per-column vertical lanes colored from a rotating 6-hue palette; the leftmost lane (column 0) stays neutral since there's nothing to distinguish it against in the single-lane case.
  • Node glyphs (○) colored by their lane.
  • Routed back-arcs carry a single hue end-to-end, including ┼ arc-crossings (which take the owning arc's hue rather than gray).
  • Forward connectors (fork/merge/fan) read one served-lane hue end-to-end; on a ┬─ tee the trailing dash takes the right-hand branch's color.
  • Branch arrows (↑↓⟲) and migration names inherit their edge's lane hue; branched names stay bold as well as colored.
  • --legend: opt-in key explaining the glyphs/colors; auto-enables --tree.

Plain-text output (--no-color / non-TTY) is byte-identical to before — all coloring resolves to the identity styler when colorize is off, so existing goldens are untouched.

Commits

  • 2d254bebe color tree lanes by column
  • 5a99b3001 add --legend key
  • a6d58d566 refine lane colors (per-arc single hue, column-0 neutral, node-by-lane)
  • 11dd7fd2a color forward connectors by served lane
  • 78f9a4dcb color routed back-arc crossings with the arc hue
  • be90398ba color branch arrows, names, and ┬─ dashes by branch
  • 36d374c6c keep branched names bold under their lane hue

Note: this branch also carries two pre-existing TML-2769 planning-doc commits (2be8b0a31, 166cf6e75) under projects/migration-graph-rendering/ that it was based on; they're docs-only and entangled in the same project doc tree, so they ride along here.

Test plan

  • pnpm --filter @prisma-next/cli typecheck
  • pnpm --filter @prisma-next/cli test — formatter + migration-graph suites green (39/39 targeted)
  • Reviewer (opus) verdict: SLICE SATISFIED, 10/10 ACs, no open findings
  • Plain-text byte-identity verified across all commits
  • Manual spot-check of colored --tree + --legend in a real TTY

Summary by CodeRabbit

  • New Features

    • Added --legend flag to the migration graph command; legend implies tree rendering and is suppressed for JSON/DOT/quiet modes.
    • Legend renders in Unicode or ASCII modes and is emitted to stderr so stdout remains pipeable.
    • Improved tree rendering with deterministic, lane-aware colorization for clearer connector and node visuals.
  • Documentation

    • New documentation describing the legend, shown glyphs, palette selection, and stderr behavior.
  • Tests

    • Added tests covering legend behavior, visibility rules, stderr routing, and lane-color rendering.

@wmadden-electric
wmadden-electric requested a review from a team as a code owner June 1, 2026 16:29
@coderabbitai

coderabbitai Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a --legend flag to the migration-graph CLI and implements deterministic lane-aware colorization in the tree renderer. Legend output (glyphs, overlays, lane palette) is emitted to stderr; renderer, palette, CLI helpers, docs, and tests were updated accordingly.

Changes

Migration Graph Legend with Lane-Aware Colorization

Layer / File(s) Summary
Lane Colorizer Contract and Palette
packages/1-framework/3-tooling/cli/src/utils/formatters/migration-graph-lane-colors.ts
Defines LaneColorizer and exports LANE_COLOR_CYCLE; implements laneColorForColumn(column) with identity for column 0 and cyclical palette selection for positive columns.
Tree Renderer Lane-Color Resolution and ANSI Helpers
packages/1-framework/3-tooling/cli/src/utils/formatters/migration-graph-tree-render.ts
Adds createColors import and introduces lane-resolution helpers (neutral sentinel, forced-bold setup, resolveRowLaneColors/resolveConnectorLaneColors), branch-token stylers, and trimTrailingWhitespace for ANSI-safe trailing-space trimming.
Tree Renderer Connector and Node Integration with Lane Colors
packages/1-framework/3-tooling/cli/src/utils/formatters/migration-graph-tree-render.ts
Reworks connector-row rendering to iterate by column and tint junctions/dashes using resolved lane columns; updates renderCellPair usage across gutters, edges, empty and non-empty node paths; forces bold+lane hue on branched directory names when colorize is enabled; integrates ANSI-safe trimming into output assembly.
CLI --legend Flag and Legend Rendering Integration
packages/1-framework/3-tooling/cli/src/commands/migration-graph.ts
Adds --legend option to MigrationGraphOptions; exports migrationGraphUsesTree and migrationGraphShowsLegend helpers; imports renderMigrationGraphLegend and emits legend to stderr when allowed; updates examples, option wiring, and rendering condition to honor --legend.
Command Tests for Legend Behavior
packages/1-framework/3-tooling/cli/test/commands/migration-graph.test.ts
Tests migrationGraphUsesTree and migrationGraphShowsLegend behavior, and includes a behavioral test asserting legend output is written only to stderr with expected content and trailing blank line.
Renderer Tests for Lane Colors and Legend Rendering
packages/1-framework/3-tooling/cli/test/utils/formatters/migration-graph-tree-render.test.ts
Adds renderMigrationGraphTree (lane colors) suite verifying column-0 neutrality, palette rotation, connector/edge coloring semantics, bolding rules, layout preservation via stripAnsi, and single-hue routed back-arcs; extends legend tests for unicode/ASCII glyph modes and ANSI gating.
Legend Documentation
docs/reference/migration-graph-rendering.md
Documents migration graph --legend: glyph/key contents, lane palette behavior (including --ascii), stdout/stderr behavior (legend on stderr), that --legend implies --tree, suppression under --json/--dot/--quiet, and links to implementation modules.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as migration-graph command
  participant Helper as CLI helpers
  participant Renderer as renderMigrationGraphTree
  participant LaneColor as laneColorForColumn
  participant Legend as renderMigrationGraphLegend
  participant stderr as stderr

  CLI->>Helper: migrationGraphUsesTree(options)
  Helper-->>CLI: true if --tree or --legend

  alt uses tree rendering
    CLI->>Renderer: Render tree
    Renderer->>Renderer: resolveRowLaneColors()
    Renderer->>LaneColor: laneColorForColumn(col)
    LaneColor-->>Renderer: LaneColorizer
    Renderer->>Renderer: Apply colors to glyphs/cells/connectors
  end

  CLI->>Helper: migrationGraphShowsLegend(options, flags)
  Helper-->>CLI: true if --legend and not suppressed

  alt Show Legend
    CLI->>Legend: renderMigrationGraphLegend(opts)
    Legend->>stderr: Emit legend (glyphs + palette)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through lanes of colored thread,
Where glyphs and arrows softly spread,
A legend squeaks upon stderr,
So pipes remain both clean and clear,
Now migrations glow in rainbowed stead.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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
Title check ✅ Passed The title accurately describes the main changes: colorizing migration graph lanes and adding a --legend flag, matching the primary objectives and file changes.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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 tml-2773-migration-graph-lane-colors-legend

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.

@github-actions

github-actions Bot commented Jun 1, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 135.76 KB (0%)
postgres / emit 108.02 KB (0%)
mongo / no-emit 75.76 KB (0%)
mongo / emit 70.75 KB (0%)
cf-worker / no-emit 164.74 KB (0%)
cf-worker / emit 133.79 KB (0%)

@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

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

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

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

@prisma-next/middleware-cache

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/extension-postgis

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/cli-telemetry

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: 91a6cef

@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 (3)
packages/1-framework/3-tooling/cli/test/utils/formatters/migration-graph-tree-render.test.ts (1)

576-614: 💤 Low value

Extract the duplicated convergence-fan edge setup into a helper.

The same 7-edge fan graph (init … mergeAvatar) is built inline here and again at lines 596-603 and 654-660. A convergenceFanEdges() helper would mirror the existing diamondEdges()/skipArcEdges() pattern in this suite and keep the three tests focused on assertions.

♻️ Proposed helper
+  function convergenceFanEdges(): readonly MigrationEdge[] {
+    const init = edge(EMPTY_CONTRACT_HASH, 'ef9de27', 'init');
+    const addPhone = edge('ef9de27', '73e3abe', 'add_phone');
+    const addPosts = edge('ef9de27', 'a94b7b4', 'add_posts');
+    const addAvatar = edge('ef9de27', '6656a6e', 'add_avatar');
+    const mergePhone = edge('73e3abe', '3116048', 'merge_phone');
+    const mergePosts = edge('a94b7b4', '3116048', 'merge_posts');
+    const mergeAvatar = edge('6656a6e', '3116048', 'merge_avatar');
+    return [init, addPhone, addPosts, addAvatar, mergePhone, mergePosts, mergeAvatar];
+  }
🤖 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/utils/formatters/migration-graph-tree-render.test.ts`
around lines 576 - 614, Extract the repeated 7-edge fan graph into a new helper
convergenceFanEdges() that returns the array of edges currently built inline
(using edge(EMPTY_CONTRACT_HASH, 'ef9de27', 'init') ... mergeAvatar), mirror the
style of existing helpers like diamondEdges() and skipArcEdges(); then replace
the inline edge array arguments in the tests that call tree([...], { colorize:
true }) with convergenceFanEdges() and keep the rest of the assertions
(references: functions/values edge, tree, laneColorForColumn and the tests that
assert on fanLine and hues).
packages/1-framework/3-tooling/cli/src/utils/formatters/migration-graph-tree-render.ts (1)

538-543: 💤 Low value

Static analysis false positive — ANSI_ESCAPE is a compile-time constant.

The flagged pattern is safe: ANSI_ESCAPE (line 538) is a literal '\x1b', not runtime/user input. The resulting regex has no overlapping quantifiers that could cause catastrophic backtracking.

Minor note: the RegExp is instantiated on every call. Hoisting it to module scope would avoid the repeated construction, but this is a non-hot rendering path so it's negligible.

♻️ Optional: hoist the regex to module scope
 const ANSI_ESCAPE = '\x1b';
+const TRAILING_SPACE_BEFORE_RESET = new RegExp(`[\\t ]+((?:${ANSI_ESCAPE}\\[[0-9;]*m)+)$`);

 function trimTrailingWhitespace(line: string): string {
-  const trailingSpaceBeforeReset = new RegExp(`[\\t ]+((?:${ANSI_ESCAPE}\\[[0-9;]*m)+)$`);
-  return line.replace(trailingSpaceBeforeReset, '$1').replace(/\s+$/, '');
+  return line.replace(TRAILING_SPACE_BEFORE_RESET, '$1').replace(/\s+$/, '');
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/1-framework/3-tooling/cli/src/utils/formatters/migration-graph-tree-render.ts`
around lines 538 - 543, The static analyzer warning is a false positive; to
silence it and avoid reconstructing the regex on every call, hoist the
dynamically-built RegExp out of trimTrailingWhitespace into module scope: create
a module-level constant (e.g., TRAILING_SPACE_BEFORE_RESET) constructed once
using the existing ANSI_ESCAPE and the same pattern, then update
trimTrailingWhitespace to use that constant instead of creating new RegExp each
call; keep the replacement logic identical and retain the ANSI_ESCAPE const and
function name trimTrailingWhitespace.
packages/1-framework/3-tooling/cli/test/commands/migration-graph.test.ts (1)

64-64: 💤 Low value

Consider including glyphMode parameter for consistency with command usage.

The command invokes renderMigrationGraphLegend({ colorize, glyphMode }) (lines 95-98 in migration-graph.ts), but this test calls it with only { colorize: false }. While the test's primary focus is routing behavior (stderr vs. stdout), including the glyphMode parameter would better mirror production usage and avoid potential type errors if glyphMode becomes required.

♻️ Suggested update
-    ui.stderr(renderMigrationGraphLegend({ colorize: false }));
+    ui.stderr(renderMigrationGraphLegend({ colorize: false, glyphMode: ui.resolveGlyphMode(false) }));
🤖 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` at
line 64, The test calls renderMigrationGraphLegend with only { colorize: false }
but production usage passes both colorize and glyphMode; update the test
invocation in migration-graph.test.ts to include glyphMode (e.g.,
renderMigrationGraphLegend({ colorize: false, glyphMode })) so the call
signature matches renderMigrationGraphLegend in migration-graph.ts and prevents
future type/behavior mismatches; ensure glyphMode value mirrors the command
usage or test default used elsewhere in the file.
🤖 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/src/utils/formatters/migration-graph-tree-render.ts`:
- Around line 538-543: The static analyzer warning is a false positive; to
silence it and avoid reconstructing the regex on every call, hoist the
dynamically-built RegExp out of trimTrailingWhitespace into module scope: create
a module-level constant (e.g., TRAILING_SPACE_BEFORE_RESET) constructed once
using the existing ANSI_ESCAPE and the same pattern, then update
trimTrailingWhitespace to use that constant instead of creating new RegExp each
call; keep the replacement logic identical and retain the ANSI_ESCAPE const and
function name trimTrailingWhitespace.

In `@packages/1-framework/3-tooling/cli/test/commands/migration-graph.test.ts`:
- Line 64: The test calls renderMigrationGraphLegend with only { colorize: false
} but production usage passes both colorize and glyphMode; update the test
invocation in migration-graph.test.ts to include glyphMode (e.g.,
renderMigrationGraphLegend({ colorize: false, glyphMode })) so the call
signature matches renderMigrationGraphLegend in migration-graph.ts and prevents
future type/behavior mismatches; ensure glyphMode value mirrors the command
usage or test default used elsewhere in the file.

In
`@packages/1-framework/3-tooling/cli/test/utils/formatters/migration-graph-tree-render.test.ts`:
- Around line 576-614: Extract the repeated 7-edge fan graph into a new helper
convergenceFanEdges() that returns the array of edges currently built inline
(using edge(EMPTY_CONTRACT_HASH, 'ef9de27', 'init') ... mergeAvatar), mirror the
style of existing helpers like diamondEdges() and skipArcEdges(); then replace
the inline edge array arguments in the tests that call tree([...], { colorize:
true }) with convergenceFanEdges() and keep the rest of the assertions
(references: functions/values edge, tree, laneColorForColumn and the tests that
assert on fanLine and hues).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: a3f4c7dc-21c7-4d94-81d8-47d224a7a244

📥 Commits

Reviewing files that changed from the base of the PR and between 7ff5200 and 8fbb5e0.

⛔ Files ignored due to path filters (8)
  • projects/migration-graph-rendering/README.md is excluded by !projects/**
  • projects/migration-graph-rendering/decisions.md is excluded by !projects/**
  • projects/migration-graph-rendering/mockups.md is excluded by !projects/**
  • projects/migration-graph-rendering/slices/lane-colors-and-legend/spec.md is excluded by !projects/**
  • projects/migration-graph-rendering/slices/ledger-foundation/spec.md is excluded by !projects/**
  • projects/migration-graph-rendering/slices/list-renders-tree/spec.md is excluded by !projects/**
  • projects/migration-graph-rendering/slices/migration-graph-space-flag/spec.md is excluded by !projects/**
  • projects/migration-graph-rendering/slices/remove-list-graph-renderer/spec.md is excluded by !projects/**
📒 Files selected for processing (6)
  • docs/reference/migration-graph-rendering.md
  • packages/1-framework/3-tooling/cli/src/commands/migration-graph.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/migration-graph-lane-colors.ts
  • packages/1-framework/3-tooling/cli/src/utils/formatters/migration-graph-tree-render.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-graph.test.ts
  • packages/1-framework/3-tooling/cli/test/utils/formatters/migration-graph-tree-render.test.ts

wmadden added 11 commits June 2, 2026 13:32
Folds in the cross-cutting design decisions for the migration read-command
family (list / graph / status / log) and the ledger foundation that status and
log depend on:

- decisions.md: D1-D10 (command-family model, shared renderer, space policy B,
  list/graph split, list->tree, ledger foundation, log, status reframe with
  --from/--to, and where path/invariants live).
- New slice specs: migration-graph-space-flag (TML-2767), list-renders-tree
  (TML-2768).
- README: full slice list incl. ledger (TML-2769), status (TML-2748), log
  (TML-2770) and the future siblings (TML-2771, TML-2772).

Signed-off-by: Will Madden <[email protected]>
Investigation found the on-apply ledger records one collapsed row per
space-apply (not per migration) and the three target schemas have diverged
(PG/SQLite lack a space column; Mongo lacks operations). status and log both
need one row per migration edge, so the foundation slice is a restructure into a
per-edge journal (space + name + hash per row), not an additive field bump.

- New slice spec: slices/ledger-foundation/spec.md.
- decisions.md D7 rewritten to the per-migration-journal restructure.

Signed-off-by: Will Madden <[email protected]>
Per-column rotating hues replace flat dim gutter styling when colorize
is on; node markers and direction arrows stay bright. Plain output is
unchanged when colorize is false.

Signed-off-by: Will Madden <[email protected]>
--legend prints a palette- and color-aware key for the --tree visual
language (node marker, direction arrows, empty baseline, data arrow,
(refs) overlay, and the rotating per-column lane palette). It prints to
stderr alongside the command header, implies --tree, and is suppressed
under --json / --dot / --quiet. Reuses the D1 lane-color helpers.

Signed-off-by: Will Madden <[email protected]>
Color each routed back-arc in one hue (its owning back-lane), keeping
crossings neutral; leave the leftmost lane (column 0) uncolored so the
common linear graph reads monochrome; and color the contract node glyph
by its lane while direction arrows stay bright.

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

Add the in-project slice spec (chosen design, dispatch plan, and the
operator-confirmed color refinements: per-arc single hue, neutral leftmost
lane, node glyph colored by lane), link it from the project README, and
record the colored-lane extension to the locked visual language in mockups.md.

Signed-off-by: Will Madden <[email protected]>
…ML-2773)

Forward branch/merge connector runs (├─┬─╮, ├───╯) rendered each cell by its pass-through column, so a fork or merge spine read as gray-then-per-column rather than as one line. Resolve each connector cell to the lane it serves: corners and intermediate tees own their column, while the leading tee and horizontal segments inherit the nearest branch point to their right, so a run into a branch — or collapsing into a merge corner — is a single hue end-to-end. Vertical lanes, node glyphs, arrows, routed back-arcs, neutral crossings, and column-0 neutrality are unchanged.

Signed-off-by: Will Madden <[email protected]>
A routed back-arc's horizontal bridge cells (─ segments and the source-tee ○─ connector) already took the arc's owning-lane hue, but its ┼ arc-crossing cells stayed dim — so the run read as one hue broken by gray gaps. A crossing can only be one colour and is unavoidably wrong for one of the two crossing lines, so leaving it dim is wrong for both; color it the arc owning the horizontal run (the nearest corner to its right) instead. The crossed forward-vertical lane is simply occluded at that one cell and reappears on the next row, and the whole arc run now reads as one continuous colour. Crossings, bridges, corners, and node-by-lane otherwise unchanged.

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

Three colorized-output refinements to the migration graph tree. A branch connector tee's trailing `─` now takes the hue of the branch on its right (the lane it leads into) rather than the tee's own left lane, so a `┬─` reads "this lane, then onward". Direction arrows (↑ ↓ ⟲) and the migration name now take their edge's lane hue instead of staying bright/bold, so a branched row reads in one branch colour; column-0 edges keep their default styling, so a linear chain stays uncoloured. Plain (colorize:false) output is byte-identical, and node-by-lane, vertical lanes, routed-arc hue, and legend are unchanged.

Signed-off-by: Will Madden <[email protected]>
A branched edge name (lane >= 1) took on its lane colour but lost its
bold in the colorized tree. Compose a forced bold with the lane hue so
the name renders bold AND coloured, matching the lane and arrow it sits
with; column-0 names keep their default bold-only styling. Arrows stay
lane-coloured (not bold). Plain-text output is unchanged.

Refs TML-2773

Signed-off-by: Will Madden <[email protected]>
Tighten the --tree legend per review: drop "node" from the contract
marker, spell out self-edges as "migration without schema change", call
the empty source an "empty database (baseline)", and trim the (refs)
line to "db / contract markers". Remove the data-column "from -> to"
entry and the rotating lane sample, and add a worked hash-arrow sample
("aaaaaa -> bbbbbb   migration from contract aaaaaa to bbbbbb"). Spread
the entries over several lines and emit a trailing blank line so the
stderr key is visibly separated from the graph on stdout. The colorize
gate and glyph-mode honoring are unchanged.

Refs TML-2773

Signed-off-by: Will Madden <[email protected]>
@wmadden-electric
wmadden-electric force-pushed the tml-2773-migration-graph-lane-colors-legend branch from 8fbb5e0 to 60edee5 Compare June 2, 2026 11:32
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