refactor(migration): rename graph-theory jargon to domain language#265
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (29)
✅ Files skipped from review due to trivial changes (18)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 WalkthroughWalkthroughThis 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
@prisma-next/runtime-executor
@prisma-next/sql-runtime
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/contract-authoring
@prisma-next/contract-ts
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/emitter
@prisma-next/eslint-plugin
@prisma-next/migration-tools
@prisma-next/vite-plugin-contract-emit
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/family-sql
@prisma-next/sql-kysely-lane
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder-new
@prisma-next/sql-lane
@prisma-next/target-postgres
@prisma-next/adapter-postgres
@prisma-next/driver-postgres
@prisma-next/core-control-plane
@prisma-next/core-execution-plane
@prisma-next/config
@prisma-next/contract
@prisma-next/operations
@prisma-next/plan
@prisma-next/utils
commit: |
There was a problem hiding this comment.
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:postgresin 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 --fullBootstrap (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.mdat 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 embeddingpostgres:postgresdirectly; 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
⛔ Files ignored due to path filters (1)
projects/cli-migration-cleanup/plan.mdis excluded by!projects/**
📒 Files selected for processing (28)
docs/architecture docs/ADR-INDEX.mddocs/architecture docs/adrs/ADR 001 - Migrations as Edges.mddocs/architecture docs/adrs/ADR 027 - Error Envelope Stable Codes.mddocs/architecture docs/adrs/ADR 028 - Migration Structure & Operations.mddocs/architecture docs/adrs/ADR 038 - Operation idempotency classification & enforcement.mddocs/architecture docs/adrs/ADR 039 - Migration graph path resolution & integrity.mddocs/architecture docs/adrs/ADR 041 - Custom operation loading via local packages + preflight bundles.mddocs/architecture docs/adrs/ADR 051 - PPg preflight-as-a-service contract.mddocs/architecture docs/adrs/ADR 097 - Tooling runs on canonical JSON only.mddocs/architecture docs/adrs/ADR 101 - Advisors Framework.mddocs/architecture docs/adrs/ADR 102 - Squash-first policy & squash advisor.mddocs/architecture docs/adrs/ADR 122 - Database Initialization & Adoption.mddocs/architecture docs/adrs/ADR 123 - Drift Detection, Recovery & Reconciliation.mddocs/architecture docs/adrs/ADR 169 - On-disk migration persistence.mddocs/architecture docs/subsystems/7. Migration System.mdexamples/prisma-next-demo/destructive-scenarios.mdpackages/1-framework/3-tooling/cli/README.mdpackages/1-framework/3-tooling/cli/src/commands/migration-apply.tspackages/1-framework/3-tooling/cli/src/commands/migration-plan.tspackages/1-framework/3-tooling/cli/src/commands/migration-show.tspackages/1-framework/3-tooling/cli/src/commands/migration-status.tspackages/1-framework/3-tooling/cli/src/utils/command-helpers.tspackages/1-framework/3-tooling/migration/README.mdpackages/1-framework/3-tooling/migration/src/dag.tspackages/1-framework/3-tooling/migration/src/errors.tspackages/1-framework/3-tooling/migration/test/dag.test.tstest/integration/test/cli-journeys/migration-status-diagnostics.e2e.test.tstest/integration/test/cli-journeys/rollback-cycle.e2e.test.ts
5ce7c9a to
d7bbdeb
Compare
…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
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
d7bbdeb to
c549b3c
Compare
Replace stale error codes (AMBIGUOUS_LEAF, NO_RESOLVABLE_LEAF) and graph jargon (chain, leaf) with current domain terms. Made-with: Cursor
wmadden
left a comment
There was a problem hiding this comment.
One small correction - otherwise looks good 👍🏻
) 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 -->
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
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).Update user-facing CLI text — command descriptions,
--fromhelp text, errorwhy/fixmessages, and diagnostic codes. "leaf" → "target", "chain" → "history" in every string a user would see.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).Address review feedback — rename internal variable
toStorageHash→toHashandleafPkg→latestPkginmigration-plan.ts, fix remaining plural "DAGs"/"chains" in ADR 102, updatedag.tsJSDoc to say "branch tips" instead of "leaf nodes", rename Mermaid diagram node variable, renameerrorDivergentBranches→errorAmbiguousTargetto match the error code naming pattern.Behavior changes & evidence
Error codes renamed (breaking for external tooling): Five stable error codes under the
MIGRATIONnamespace changed values. Any external script or CI integration matching on these codes must update. The error semantics, shape, anddetailsstructure are unchanged — only the string code and detail field names changed.CLI user-facing text uses domain language: All command descriptions, option help text, and error guidance (
why/fixfields) now say "target" instead of "leaf" and "history" instead of "chain". No behavior change — only string content.--fromdescription, fix messages, variable renamesDocumentation 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.
Compatibility / migration / risk
MIGRATION.AMBIGUOUS_LEAFetc. must update to the new codes. No deprecation period — this is a pre-1.0 prototype.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:
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.dag/prefixes (dag/orphan-database,dag/no-path,dag/cycle) — unclear whether these are stable machine-readable identifiers or stale naming.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
findLeaf,findReachableLeaves,MigrationChainEntry,forwardChain/reverseChain,dag.tsfilename — these are implementation-internal and do not affect users.dag.ts→graph.ts: Listed in the ticket but deferred; would touch many import paths for no user-facing benefit.errorUnknownRefextraction: Listed in the ticket but unrelated to the jargon rename.Made with Cursor
Summary by CodeRabbit
Documentation
Refactor