Skip to content

refactor(migration): rename graph-theory jargon to domain language#265

Merged
saevarb merged 11 commits into
mainfrom
chore/tml-2097-jargon-cleanup
Mar 31, 2026
Merged

refactor(migration): rename graph-theory jargon to domain language#265
saevarb merged 11 commits into
mainfrom
chore/tml-2097-jargon-cleanup

Conversation

@saevarb
Copy link
Copy Markdown
Contributor

@saevarb saevarb commented Mar 30, 2026

closes TML-2097

Intent

Replace graph-theory vocabulary (DAG, leaf, chain, self-loop, root) with domain language (migration graph, target, history, branch tip) across all user-facing surfaces — error codes, CLI messages, and documentation. Users and CI consumers should never encounter CS-algorithm jargon when interacting with the migration system. Internal implementation names (findLeaf, MigrationChainEntry, dag.ts) are intentionally left unchanged; the boundary is user-visible surface vs internal code.

The story

  1. Rename five migration error codes to use domain language instead of graph-theory terms: SELF_LOOPSAME_SOURCE_AND_TARGET, AMBIGUOUS_LEAFAMBIGUOUS_TARGET, NO_ROOTNO_INITIAL_MIGRATION, NO_RESOLVABLE_LEAFNO_TARGET, MARKER_NOT_IN_GRAPHMARKER_NOT_IN_HISTORY. Update all call sites, error factory functions, and detail field names (leavesbranchTips, reachableNodesreachableHashes).

  2. Update user-facing CLI text — command descriptions, --from help text, error why/fix messages, and diagnostic codes. "leaf" → "target", "chain" → "history" in every string a user would see.

  3. Sweep documentation — rename ADR 039 file and title, replace ~60 occurrences of "DAG" with "migration graph" across 14 ADRs and subsystem docs, update stale error codes in ADR 027/169/Subsystem 7, fix stale field names (fromStorageHashfrom), and clean up residual plural forms (DAGs, chains).

  4. Address review feedback — rename internal variable toStorageHashtoHash and leafPkglatestPkg in migration-plan.ts, fix remaining plural "DAGs"/"chains" in ADR 102, update dag.ts JSDoc to say "branch tips" instead of "leaf nodes", rename Mermaid diagram node variable, rename errorDivergentBrancheserrorAmbiguousTarget to match the error code naming pattern.

Behavior changes & evidence

Compatibility / migration / risk

  • Breaking: The five renamed error codes are stable machine-readable identifiers (ADR 027). External tooling parsing CLI JSON output for MIGRATION.AMBIGUOUS_LEAF etc. must update to the new codes. No deprecation period — this is a pre-1.0 prototype.
  • ADR 039 file rename: Any external bookmarks or links to the old filename will break. All in-repo cross-references are updated.

ADR staleness observed during this work

Several ADRs contain content that does not reflect the current implementation. This PR intentionally did not attempt to fix ADR content beyond what was directly related to the terminology changes. Notable examples:

  • ADR 039 documents integrity check error codes (ERR_MIG_GRAPH_INDEX_STALE, ERR_MIG_GRAPH_PARALLEL_EDGE, WARN_MIG_GRAPH_CYCLE, WARN_MIG_ORPHAN_EDGE, ERR_MIG_GRAPH_DANGLING_TARGET) that do not exist in the codebase.
  • ADR 123 uses drift type keys with dag/ prefixes (dag/orphan-database, dag/no-path, dag/cycle) — unclear whether these are stable machine-readable identifiers or stale naming.
  • Subsystem 7 had stale field names (fromStorageHash/toStorageHash) that were corrected as part of this PR, suggesting other content may also be out of date.

A broader ADR accuracy sweep should be a separate effort.

Non-goals / intentionally out of scope

  • Internal API renames: findLeaf, findReachableLeaves, MigrationChainEntry, forwardChain/reverseChain, dag.ts filename — these are implementation-internal and do not affect users.
  • File rename dag.tsgraph.ts: Listed in the ticket but deferred; would touch many import paths for no user-facing benefit.
  • errorUnknownRef extraction: Listed in the ticket but unrelated to the jargon rename.
  • ADR content accuracy: Beyond terminology, ADR content was not audited for correctness. See "ADR staleness" above.

Made with Cursor

Summary by CodeRabbit

  • Documentation

    • Refined migration system architecture documentation with improved terminology consistency across architectural decision records and subsystem guides.
  • Refactor

    • Standardized migration error codes and diagnostic messages for better consistency.
    • Updated CLI command descriptions, help text, and error output to align with documentation terminology.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: d7ccb880-eac2-49a8-9621-b823916c8239

📥 Commits

Reviewing files that changed from the base of the PR and between 34b5dd4 and a04c959.

📒 Files selected for processing (29)
  • docs/architecture docs/ADR-INDEX.md
  • docs/architecture docs/adrs/ADR 001 - Migrations as Edges.md
  • docs/architecture docs/adrs/ADR 027 - Error Envelope Stable Codes.md
  • docs/architecture docs/adrs/ADR 028 - Migration Structure & Operations.md
  • docs/architecture docs/adrs/ADR 038 - Operation idempotency classification & enforcement.md
  • docs/architecture docs/adrs/ADR 039 - Migration graph path resolution & integrity.md
  • docs/architecture docs/adrs/ADR 041 - Custom operation loading via local packages + preflight bundles.md
  • docs/architecture docs/adrs/ADR 051 - PPg preflight-as-a-service contract.md
  • docs/architecture docs/adrs/ADR 097 - Tooling runs on canonical JSON only.md
  • docs/architecture docs/adrs/ADR 101 - Advisors Framework.md
  • docs/architecture docs/adrs/ADR 102 - Squash-first policy & squash advisor.md
  • docs/architecture docs/adrs/ADR 122 - Database Initialization & Adoption.md
  • docs/architecture docs/adrs/ADR 123 - Drift Detection, Recovery & Reconciliation.md
  • docs/architecture docs/adrs/ADR 169 - On-disk migration persistence.md
  • docs/architecture docs/subsystems/7. Migration System.md
  • packages/1-framework/3-tooling/cli/README.md
  • packages/1-framework/3-tooling/cli/src/commands/migration-apply.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-show.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-status.ts
  • packages/1-framework/3-tooling/cli/src/utils/command-helpers.ts
  • packages/1-framework/3-tooling/migration/README.md
  • packages/1-framework/3-tooling/migration/src/dag.ts
  • packages/1-framework/3-tooling/migration/src/errors.ts
  • packages/1-framework/3-tooling/migration/test/dag.test.ts
  • test/integration/test/cli-journeys/README.md
  • test/integration/test/cli-journeys/drift-deleted-root.e2e.test.ts
  • test/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.ts
  • test/integration/test/cli-journeys/rollback-cycle.e2e.test.ts
✅ Files skipped from review due to trivial changes (18)
  • packages/1-framework/3-tooling/cli/src/commands/migration-apply.ts
  • docs/architecture docs/adrs/ADR 038 - Operation idempotency classification & enforcement.md
  • docs/architecture docs/adrs/ADR 041 - Custom operation loading via local packages + preflight bundles.md
  • docs/architecture docs/adrs/ADR 122 - Database Initialization & Adoption.md
  • packages/1-framework/3-tooling/migration/README.md
  • test/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.ts
  • docs/architecture docs/adrs/ADR 051 - PPg preflight-as-a-service contract.md
  • docs/architecture docs/ADR-INDEX.md
  • docs/architecture docs/adrs/ADR 001 - Migrations as Edges.md
  • packages/1-framework/3-tooling/cli/src/utils/command-helpers.ts
  • test/integration/test/cli-journeys/rollback-cycle.e2e.test.ts
  • docs/architecture docs/adrs/ADR 028 - Migration Structure & Operations.md
  • test/integration/test/cli-journeys/README.md
  • docs/architecture docs/adrs/ADR 101 - Advisors Framework.md
  • packages/1-framework/3-tooling/cli/src/commands/migration-show.ts
  • packages/1-framework/3-tooling/migration/test/dag.test.ts
  • docs/architecture docs/adrs/ADR 102 - Squash-first policy & squash advisor.md
  • docs/architecture docs/subsystems/7. Migration System.md
🚧 Files skipped from review as they are similar to previous changes (7)
  • docs/architecture docs/adrs/ADR 097 - Tooling runs on canonical JSON only.md
  • docs/architecture docs/adrs/ADR 039 - Migration graph path resolution & integrity.md
  • packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts
  • docs/architecture docs/adrs/ADR 123 - Drift Detection, Recovery & Reconciliation.md
  • docs/architecture docs/adrs/ADR 027 - Error Envelope Stable Codes.md
  • packages/1-framework/3-tooling/cli/README.md
  • packages/1-framework/3-tooling/migration/src/dag.ts

📝 Walkthrough

Walkthrough

This PR systematically replaces "DAG" terminology with "migration graph" language across documentation, CLI help text, error codes, and comments. It also updates related user-facing terminology ("chain leaf" → "migration target", "chain" → "migration history") and renames error functions with corresponding code updates.

Changes

Cohort / File(s) Summary
Documentation & Architecture Decision Records
docs/architecture/ADR-INDEX.md, docs/architecture/adrs/ADR 001...md, docs/architecture/adrs/ADR 028...md, docs/architecture/adrs/ADR 038...md, docs/architecture/adrs/ADR 039...md, docs/architecture/adrs/ADR 041...md, docs/architecture/adrs/ADR 051...md, docs/architecture/adrs/ADR 097...md, docs/architecture/adrs/ADR 101...md, docs/architecture/adrs/ADR 102...md, docs/architecture/adrs/ADR 122...md, docs/architecture/adrs/ADR 123...md, docs/architecture/adrs/ADR 169...md, docs/architecture/subsystems/7. Migration System.md
Replaced "DAG" terminology with "migration graph" across all ADRs and documentation. Updated error code names in ADR 027 (e.g., MIGRATION.SELF_LOOPMIGRATION.SAME_SOURCE_AND_TARGET, MIGRATION.AMBIGUOUS_LEAFMIGRATION.AMBIGUOUS_TARGET). Updated cross-references and related language ("leaf nodes" → "branch tips", "chain" → "history/graph").
CLI Commands & Help Text
packages/1-framework/3-tooling/cli/README.md, packages/1-framework/3-tooling/cli/src/commands/migration-apply.ts, packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts, packages/1-framework/3-tooling/cli/src/commands/migration-show.ts, packages/1-framework/3-tooling/cli/src/commands/migration-status.ts, packages/1-framework/3-tooling/cli/src/utils/command-helpers.ts
Updated CLI help text and command descriptions: "chain leaf" → "migration target", "migration chain" → "migration history". Renamed diagnostic code MARKER_NOT_IN_GRAPHMARKER_NOT_IN_HISTORY. Updated error messages for ambiguity and resolution failures.
Migration Tooling Core
packages/1-framework/3-tooling/migration/README.md, packages/1-framework/3-tooling/migration/src/dag.ts, packages/1-framework/3-tooling/migration/src/errors.ts
Renamed error functions: errorSelfLooperrorSameSourceAndTarget, errorAmbiguousLeaferrorAmbiguousTarget, errorNoRooterrorNoInitialMigration, errorNoResolvableLeaferrorNoTarget. Updated error detail payloads: leavesbranchTips, leaftip. Updated JSDoc and error messages. Note: Public function signatures in dag.ts unchanged; error function exports modified.
Unit & Integration Tests
packages/1-framework/3-tooling/migration/test/dag.test.ts, test/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.ts, test/integration/test/cli-journeys/rollback-cycle.e2e.test.ts, test/integration/test/cli-journeys/drift-deleted-root.e2e.test.ts, test/integration/test/cli-journeys/README.md
Updated test assertions to expect new error codes and messages. Changed expected patterns from NO_RESOLVABLE_LEAF/AMBIGUOUS_LEAF to NO_TARGET/AMBIGUOUS_TARGET. Updated test descriptions and documentation table to reflect new error identifiers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Hops through the migration graph with glee,
Old "DAG" leaves now branch tips we see,
Error codes renamed, terminology blessed,
From "leaf" to "target"—a semantic quest,
History flows through each test and CLI!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.32% 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 title 'refactor(migration): rename graph-theory jargon to domain language' accurately and clearly summarizes the main change—a comprehensive terminology update across user-facing surfaces replacing graph-theory terms with domain language.

✏️ 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 chore/tml-2097-jargon-cleanup

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
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 30, 2026

Open in StackBlitz

@prisma-next/runtime-executor

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

@prisma-next/sql-runtime

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/contract-authoring

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

@prisma-next/contract-ts

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/emitter

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

@prisma-next/eslint-plugin

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

@prisma-next/migration-tools

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

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

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

@prisma-next/family-sql

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

@prisma-next/sql-kysely-lane

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder-new

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

@prisma-next/sql-lane

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

@prisma-next/target-postgres

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

@prisma-next/adapter-postgres

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

@prisma-next/driver-postgres

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

@prisma-next/core-control-plane

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

@prisma-next/core-execution-plane

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

@prisma-next/config

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

@prisma-next/contract

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

@prisma-next/operations

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

@prisma-next/plan

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

@prisma-next/utils

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

commit: 2139cce

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
examples/prisma-next-demo/destructive-scenarios.md (1)

40-40: Avoid hardcoding credentials in command examples.

Using explicit postgres:postgres in repeated snippets normalizes unsafe copy/paste. Prefer a single env-var driven example and keep the concrete local default as optional context.

Suggested doc tweak
-- **Database:** `postgresql://postgres:postgres@localhost:5432/prisma_next` (docker-compose pgvector/pg16)
+- **Database:** Use `DATABASE_URL` (for local demo, e.g. `postgresql://postgres:postgres@localhost:5432/prisma_next` with docker-compose pgvector/pg16)

 Reset between scenarios:
 ```bash
-DATABASE_URL="postgresql://postgres:postgres@localhost:5432/prisma_next" ../../reset-db.sh --full
+../../reset-db.sh --full

Bootstrap (used by most scenarios):

pnpm prisma-next contract emit
pnpm prisma-next migration plan --name init
-DATABASE_URL="postgresql://postgres:postgres@localhost:5432/prisma_next" pnpm prisma-next migration apply
+pnpm prisma-next migration apply
</details>


Also applies to: 46-47, 53-54

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @examples/prisma-next-demo/destructive-scenarios.md at line 40, Replace
hardcoded Postgres credentials in command examples with an env-var driven
pattern: show setting and using DATABASE_URL (or mention an optional local
default) instead of embedding postgres:postgres directly; update the reset-db
invocation (../../reset-db.sh --full) and the migration apply command (pnpm prisma-next migration apply) to assume DATABASE_URL is set externally (or
demonstrate a single example of exporting DATABASE_URL once) and remove repeated
inline
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/prisma_next"
usages throughout the document (including the bootstrap section and the other
instances noted) so examples encourage safe copy/paste.


</details>

</blockquote></details>
<details>
<summary>test/integration/test/cli-journeys/rollback-cycle.e2e.test.ts (1)</summary><blockquote>

`76-78`: **Consider simplifying the regex pattern.**

The pattern `no.*target.*resolved` seems verbose. Since the error formatter includes the code `NO_TARGET` in parentheses, you could simplify to `/no.*target|cycle|NO_TARGET/i` for clearer intent.



<details>
<summary>♻️ Proposed simplification</summary>

```diff
-        expect(failOutput, 'J.04: error mentions no target').toMatch(
-          /no.*target.*resolved|cycle|NO_TARGET/i,
-        );
+        expect(failOutput, 'J.04: error mentions no target').toMatch(
+          /no.*target|cycle|NO_TARGET/i,
+        );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/integration/test/cli-journeys/rollback-cycle.e2e.test.ts` around lines
76 - 78, The test's expect regex is overly verbose; update the assertion that
checks failOutput (the expect call referencing failOutput and message 'J.04:
error mentions no target') to use a simplified regex like
/no.*target|cycle|NO_TARGET/i so it matches "no ... target" or "cycle" or the
literal "NO_TARGET" more clearly and concisely.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@examples/prisma-next-demo/destructive-scenarios.md`:
- Line 198: The Goal sentence is a fragment; update the line that currently
reads "**Goal:** Relax a NOT NULL constraint. Should be a widening operation."
to a single complete sentence such as "**Goal:** Relax a NOT NULL constraint.
This should be a widening operation." so the second clause is a full sentence
(locate the exact line containing that Goal heading and replace the fragment).
- Line 64: The instruction list uses the short name "contract.ts" at Line 64 but
earlier defines the contract under a full-module name; update the wording so the
reference at the removal step matches the canonical contract module name used
earlier (i.e., replace the short "contract.ts" mention with the same full
contract reference used at the earlier definition) to ensure consistent,
unambiguous references to the contract throughout the document.

In `@packages/1-framework/3-tooling/migration/src/dag.ts`:
- Around line 279-283: Update the JSDoc to reflect the current exception names:
replace the stale DIVERGENT_BRANCHES reference with MIGRATION.AMBIGUOUS_TARGET
(and ensure NO_INITIAL_MIGRATION remains correct) in the docblock describing the
function that finds the target contract hash in the migration DAG; also update
the other affected docblock occurrence later in the file (the second instance
around the following doc lines) so both JSDoc comments match the actual thrown
constant MIGRATION.AMBIGUOUS_TARGET.

---

Nitpick comments:
In `@examples/prisma-next-demo/destructive-scenarios.md`:
- Line 40: Replace hardcoded Postgres credentials in command examples with an
env-var driven pattern: show setting and using DATABASE_URL (or mention an
optional local default) instead of embedding `postgres:postgres` directly;
update the reset-db invocation (`../../reset-db.sh --full`) and the migration
apply command (`pnpm prisma-next migration apply`) to assume DATABASE_URL is set
externally (or demonstrate a single example of exporting DATABASE_URL once) and
remove repeated inline
`DATABASE_URL="postgresql://postgres:postgres@localhost:5432/prisma_next"`
usages throughout the document (including the bootstrap section and the other
instances noted) so examples encourage safe copy/paste.

In `@test/integration/test/cli-journeys/rollback-cycle.e2e.test.ts`:
- Around line 76-78: The test's expect regex is overly verbose; update the
assertion that checks failOutput (the expect call referencing failOutput and
message 'J.04: error mentions no target') to use a simplified regex like
/no.*target|cycle|NO_TARGET/i so it matches "no ... target" or "cycle" or the
literal "NO_TARGET" more clearly and concisely.
🪄 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: af46efe7-887a-4b2f-a8f4-88e56fe79135

📥 Commits

Reviewing files that changed from the base of the PR and between 0e3ff28 and 34b5dd4.

⛔ Files ignored due to path filters (1)
  • projects/cli-migration-cleanup/plan.md is excluded by !projects/**
📒 Files selected for processing (28)
  • docs/architecture docs/ADR-INDEX.md
  • docs/architecture docs/adrs/ADR 001 - Migrations as Edges.md
  • docs/architecture docs/adrs/ADR 027 - Error Envelope Stable Codes.md
  • docs/architecture docs/adrs/ADR 028 - Migration Structure & Operations.md
  • docs/architecture docs/adrs/ADR 038 - Operation idempotency classification & enforcement.md
  • docs/architecture docs/adrs/ADR 039 - Migration graph path resolution & integrity.md
  • docs/architecture docs/adrs/ADR 041 - Custom operation loading via local packages + preflight bundles.md
  • docs/architecture docs/adrs/ADR 051 - PPg preflight-as-a-service contract.md
  • docs/architecture docs/adrs/ADR 097 - Tooling runs on canonical JSON only.md
  • docs/architecture docs/adrs/ADR 101 - Advisors Framework.md
  • docs/architecture docs/adrs/ADR 102 - Squash-first policy & squash advisor.md
  • docs/architecture docs/adrs/ADR 122 - Database Initialization & Adoption.md
  • docs/architecture docs/adrs/ADR 123 - Drift Detection, Recovery & Reconciliation.md
  • docs/architecture docs/adrs/ADR 169 - On-disk migration persistence.md
  • docs/architecture docs/subsystems/7. Migration System.md
  • examples/prisma-next-demo/destructive-scenarios.md
  • packages/1-framework/3-tooling/cli/README.md
  • packages/1-framework/3-tooling/cli/src/commands/migration-apply.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-show.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-status.ts
  • packages/1-framework/3-tooling/cli/src/utils/command-helpers.ts
  • packages/1-framework/3-tooling/migration/README.md
  • packages/1-framework/3-tooling/migration/src/dag.ts
  • packages/1-framework/3-tooling/migration/src/errors.ts
  • packages/1-framework/3-tooling/migration/test/dag.test.ts
  • test/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.ts
  • test/integration/test/cli-journeys/rollback-cycle.e2e.test.ts

Comment thread examples/prisma-next-demo/destructive-scenarios.md Outdated
Comment thread examples/prisma-next-demo/destructive-scenarios.md Outdated
Comment thread packages/1-framework/3-tooling/migration/src/dag.ts
@saevarb saevarb force-pushed the chore/tml-2097-jargon-cleanup branch 3 times, most recently from 5ce7c9a to d7bbdeb Compare March 30, 2026 10:03
saevarb added 7 commits March 30, 2026 12:04
…anguage

Replace graph-theory error codes with user-meaningful alternatives:
- SELF_LOOP → SAME_SOURCE_AND_TARGET
- AMBIGUOUS_LEAF → AMBIGUOUS_TARGET
- NO_RESOLVABLE_LEAF → NO_TARGET
- NO_ROOT → NO_INITIAL_MIGRATION
- MARKER_NOT_IN_GRAPH → MARKER_NOT_IN_HISTORY

Update error messages to remove "leaf nodes", "root", and "no node has
zero outgoing edges" phrasing. Add jargon audit script for tracking
remaining terminology cleanup (TML-2097).

Made-with: Cursor
…r-facing text

Update CLI help text, error messages, command descriptions, and README
to use 'migration history' instead of 'migration chain' and 'latest
migration target' instead of 'chain leaf'. No internal code renames.

Made-with: Cursor
Rename ADR 039 from 'DAG path resolution' to 'Migration graph path
resolution' and update all cross-references. Replace 'DAG' with
'migration graph', update stale error codes (SELF_LOOP, AMBIGUOUS_LEAF,
NO_RESOLVABLE_LEAF) to match renamed codes, and replace 'leaf'/'chain'
with 'target'/'history' in user-facing prose across ADRs, subsystem
docs, and package READMEs. Fix stale field names (fromStorageHash →
from) in Subsystem 7.

Made-with: Cursor
- Rename toStorageHash/leafPkg variables in migration-plan.ts
- Fix residual plural DAGs/chains in ADR 102
- Revert accidental 'older history' scope narrowing in ADR 102
- Update dag.ts JSDoc to use 'branch tips' instead of 'leaf nodes'
- Rename Mermaid DAG node variable to GRAPH in migration README
- Fix last 3 'DAGs' in ADR 039

Made-with: Cursor
The script served its purpose during the TML-2097 terminology cleanup
and is no longer needed as a permanent fixture.

Made-with: Cursor
…arget

Aligns the factory function name with the error code it produces
(MIGRATION.AMBIGUOUS_TARGET), matching the pattern used by all other
error factories in the file.

Made-with: Cursor
@saevarb saevarb force-pushed the chore/tml-2097-jargon-cleanup branch from d7bbdeb to c549b3c Compare March 30, 2026 10:05
saevarb added 2 commits March 30, 2026 12:14
Replace stale error codes (AMBIGUOUS_LEAF, NO_RESOLVABLE_LEAF) and
graph jargon (chain, leaf) with current domain terms.

Made-with: Cursor
Comment thread packages/1-framework/3-tooling/migration/src/dag.ts
Copy link
Copy Markdown
Contributor

@wmadden wmadden left a comment

Choose a reason for hiding this comment

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

One small correction - otherwise looks good 👍🏻

@saevarb saevarb enabled auto-merge (squash) March 31, 2026 07:39
@saevarb saevarb merged commit b0409e1 into main Mar 31, 2026
15 checks passed
@saevarb saevarb deleted the chore/tml-2097-jargon-cleanup branch March 31, 2026 07:45
jkomyno pushed a commit that referenced this pull request Apr 1, 2026
)

closes
[TML-2097](https://linear.app/prisma-company/issue/TML-2097/pn-rename-graph-theory-jargon-to-domain-language-across-codebase-and)

## Intent

Replace graph-theory vocabulary (`DAG`, `leaf`, `chain`, `self-loop`,
`root`) with domain language (`migration graph`, `target`, `history`,
`branch tip`) across all user-facing surfaces — error codes, CLI
messages, and documentation. Users and CI consumers should never
encounter CS-algorithm jargon when interacting with the migration
system. Internal implementation names (`findLeaf`,
`MigrationChainEntry`, `dag.ts`) are intentionally left unchanged; the
boundary is user-visible surface vs internal code.

## The story

1. **Rename five migration error codes** to use domain language instead
of graph-theory terms: `SELF_LOOP` → `SAME_SOURCE_AND_TARGET`,
`AMBIGUOUS_LEAF` → `AMBIGUOUS_TARGET`, `NO_ROOT` →
`NO_INITIAL_MIGRATION`, `NO_RESOLVABLE_LEAF` → `NO_TARGET`,
`MARKER_NOT_IN_GRAPH` → `MARKER_NOT_IN_HISTORY`. Update all call sites,
error factory functions, and detail field names (`leaves` →
`branchTips`, `reachableNodes` → `reachableHashes`).

2. **Update user-facing CLI text** — command descriptions, `--from` help
text, error `why`/`fix` messages, and diagnostic codes. "leaf" →
"target", "chain" → "history" in every string a user would see.

3. **Sweep documentation** — rename ADR 039 file and title, replace ~60
occurrences of "DAG" with "migration graph" across 14 ADRs and subsystem
docs, update stale error codes in ADR 027/169/Subsystem 7, fix stale
field names (`fromStorageHash` → `from`), and clean up residual plural
forms (`DAGs`, `chains`).

4. **Address review feedback** — rename internal variable
`toStorageHash` → `toHash` and `leafPkg` → `latestPkg` in
`migration-plan.ts`, fix remaining plural "DAGs"/"chains" in ADR 102,
update `dag.ts` JSDoc to say "branch tips" instead of "leaf nodes",
rename Mermaid diagram node variable, rename `errorDivergentBranches` →
`errorAmbiguousTarget` to match the error code naming pattern.

## Behavior changes & evidence

- **Error codes renamed (breaking for external tooling)**: Five stable
error codes under the `MIGRATION` namespace changed values. Any external
script or CI integration matching on these codes must update. The error
semantics, shape, and `details` structure are unchanged — only the
string code and detail field names changed.
  - **Implementation**:
-
[packages/1-framework/3-tooling/migration/src/errors.ts](packages/1-framework/3-tooling/migration/src/errors.ts)
— factory functions renamed and reworded
-
[packages/1-framework/3-tooling/migration/src/dag.ts](packages/1-framework/3-tooling/migration/src/dag.ts)
— call sites updated
-
[packages/1-framework/3-tooling/cli/src/commands/migration-status.ts](packages/1-framework/3-tooling/cli/src/commands/migration-status.ts)
— diagnostic codes updated
  - **Tests**:
-
[packages/1-framework/3-tooling/migration/test/dag.test.ts](packages/1-framework/3-tooling/migration/test/dag.test.ts)
— assertions on new codes and detail field names
-
[test/integration/test/cli-journeys/rollback-cycle.e2e.test.ts](test/integration/test/cli-journeys/rollback-cycle.e2e.test.ts)
— updated regex and code assertions
-
[test/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.ts](test/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.ts)
— updated describe block title

- **CLI user-facing text uses domain language**: All command
descriptions, option help text, and error guidance (`why`/`fix` fields)
now say "target" instead of "leaf" and "history" instead of "chain". No
behavior change — only string content.
  - **Implementation**:
-
[packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts](packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts)
— `--from` description, fix messages, variable renames
-
[packages/1-framework/3-tooling/cli/src/commands/migration-status.ts](packages/1-framework/3-tooling/cli/src/commands/migration-status.ts)
— command description, diagnostic messages
-
[packages/1-framework/3-tooling/cli/src/commands/migration-show.ts](packages/1-framework/3-tooling/cli/src/commands/migration-show.ts)
— error message
-
[packages/1-framework/3-tooling/cli/src/commands/migration-apply.ts](packages/1-framework/3-tooling/cli/src/commands/migration-apply.ts)
— long description
-
[packages/1-framework/3-tooling/cli/README.md](packages/1-framework/3-tooling/cli/README.md)
— user-facing docs
- **Tests**: Covered by existing e2e journey tests (updated assertions
match new text).

- **Documentation uses domain language (no behavior change)**: "DAG" →
"migration graph", stale error codes and field names updated, ADR 039
renamed. Purely prose — no code behavior affected.
- **Implementation**: 14 ADR files, Subsystem 7 doc, ADR-INDEX,
migration package README, destructive-scenarios.md

## Compatibility / migration / risk

- **Breaking**: The five renamed error codes are stable machine-readable
identifiers (ADR 027). External tooling parsing CLI JSON output for
`MIGRATION.AMBIGUOUS_LEAF` etc. must update to the new codes. No
deprecation period — this is a pre-1.0 prototype.
- **ADR 039 file rename**: Any external bookmarks or links to the old
filename will break. All in-repo cross-references are updated.

## ADR staleness observed during this work

Several ADRs contain content that does not reflect the current
implementation. This PR intentionally did not attempt to fix ADR content
beyond what was directly related to the terminology changes. Notable
examples:

- **ADR 039** documents integrity check error codes
(`ERR_MIG_GRAPH_INDEX_STALE`, `ERR_MIG_GRAPH_PARALLEL_EDGE`,
`WARN_MIG_GRAPH_CYCLE`, `WARN_MIG_ORPHAN_EDGE`,
`ERR_MIG_GRAPH_DANGLING_TARGET`) that do not exist in the codebase.
- **ADR 123** uses drift type keys with `dag/` prefixes
(`dag/orphan-database`, `dag/no-path`, `dag/cycle`) — unclear whether
these are stable machine-readable identifiers or stale naming.
- **Subsystem 7** had stale field names
(`fromStorageHash`/`toStorageHash`) that were corrected as part of this
PR, suggesting other content may also be out of date.

A broader ADR accuracy sweep should be a separate effort.

## Non-goals / intentionally out of scope

- **Internal API renames**: `findLeaf`, `findReachableLeaves`,
`MigrationChainEntry`, `forwardChain`/`reverseChain`, `dag.ts` filename
— these are implementation-internal and do not affect users.
- **File rename `dag.ts` → `graph.ts`**: Listed in the ticket but
deferred; would touch many import paths for no user-facing benefit.
- **`errorUnknownRef` extraction**: Listed in the ticket but unrelated
to the jargon rename.
- **ADR content accuracy**: Beyond terminology, ADR content was not
audited for correctness. See "ADR staleness" above.

Made with [Cursor](https://cursor.com)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
- Refined migration system architecture documentation with improved
terminology consistency across architectural decision records and
subsystem guides.

* **Refactor**
- Standardized migration error codes and diagnostic messages for better
consistency.
- Updated CLI command descriptions, help text, and error output to align
with documentation terminology.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants