Skip to content

docs(adr): ADR 245 — errors structured at origin; one ok discriminator on results - #29925

Merged
wmadden-electric merged 3 commits into
mainfrom
adr-244-close-out-cli-base-types
Aug 7, 2026
Merged

wmadden-electric merged 3 commits into
mainfrom
adr-244-close-out-cli-base-types

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Extracts the durable decisions from the consolidate-clis (TML-3172) Drive project into a repo ADR, so the project's working artifacts (decision-record branch, PR #29917) can be discarded rather than merged.

Records: errors structured at origin with no catch-all codes; envelope.code as the only machine-branching surface (explicit-code errorRuntime, no meta.code); the shared Result shape with the single ok discriminator; and the MigrationToolsError collapse into CliStructuredError. All already implemented on main via #29919 and #29911; composer's siblings are its ADR-0043/0044 (merged in prisma/composer#205).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added an architecture decision record documenting standardized structured errors and explicit, machine-readable error codes.
    • Clarified consistent operation result handling through a single success/failure indicator.
    • Documented unified error hierarchies, preserved error causes, direct error propagation, and guidance for maintaining error references.
    • Updated the architecture decision record index to include the new guidance.

…r on results

Records the durable rules from the consolidate-clis base-types work
(TML-3180/3181) as a repo ADR before the Drive project artifacts are
deleted: origin structuring with no catch-all codes, code as the only
branching surface, the shared Result shape with a single ok
discriminator, and the MigrationToolsError collapse into the one error
base class. Composer carries the same rules as ADR-0043/0044.

Refs: TML-3172

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden-electric
wmadden-electric requested a review from a team as a code owner August 7, 2026 15:32
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: f6338abe-6190-436e-b3ef-2dc0a9eb7ac2

📥 Commits

Reviewing files that changed from the base of the PR and between e4c0fb3 and 9ee6300.

📒 Files selected for processing (1)
  • docs/architecture docs/adrs/ADR 245 - Errors are structured at origin; results carry one ok discriminator.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/architecture docs/adrs/ADR 245 - Errors are structured at origin; results carry one ok discriminator.md

📝 Walkthrough

Walkthrough

This change adds ADR 245 and indexes it in the Migration System architecture documentation. The ADR defines structured-origin errors, explicit error codes, a shared ok result discriminator, unified error inheritance, direct propagation, and preserved causes.

Changes

Migration System error contracts

Layer / File(s) Summary
Document error and result contracts
docs/architecture docs/adrs/ADR 245 - Errors are structured at origin; results carry one ok discriminator.md, docs/architecture docs/ADR-INDEX.md
Adds ADR 245 with error and result-handling rules, rejected alternatives, and a corresponding index entry.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • prisma/prisma#29919: Documents related structured-error behavior, including explicit error codes, unified CliStructuredError handling, and preserved cause chains.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes ADR 245 and its primary decisions about structured errors and a single ok discriminator.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch adr-244-close-out-cli-base-types

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.

@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

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

Inline comments:
In `@docs/architecture` docs/adrs/ADR 245 - Errors are structured at origin;
results carry one ok discriminator.md:
- Around line 5-11: Resolve the ADR 239 cross-reference by ensuring
docs/architecture docs/ADR-INDEX.md:100 uses the error-envelope ADR’s matching
title and link, while preserving the authoring-helpers ADR as a distinct entry
if needed. Update the ADR 245 reference near “Decision” only as necessary so it
consistently points to the error-envelope content; no direct change is required
there if its existing link is already correct.
- Around line 11-17: Align ADR 245 with the documented behavior of
errorUnexpected and executeDbUpdateCommand: either explicitly permit
CLI.UNEXPECTED as a valid origin-created error, or update the generic catch path
to preserve the caught cause and replace/remove the generic code in accordance
with ADR 245’s no-fallback rule.
🪄 Autofix

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 Plus

Run ID: f39aae49-4c19-4055-8b8a-d0dfdc072d3d

📥 Commits

Reviewing files that changed from the base of the PR and between 71234cb and 8ca57d1.

📒 Files selected for processing (2)
  • docs/architecture docs/ADR-INDEX.md
  • docs/architecture docs/adrs/ADR 245 - Errors are structured at origin; results carry one ok discriminator.md

Grounding example first (a raise site and a consumer), rules stated as
the standing contract rather than as a narrative of the refactor that
produced them, subclass rules generalized beyond the one migration
class, and the historical failure modes compressed into Alternatives
considered. Index summary aligned.

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>

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

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

Inline comments:
In `@docs/architecture` docs/adrs/ADR 245 - Errors are structured at origin;
results carry one ok discriminator.md:
- Line 47: Update the `Result<T, F>` contract in the ADR so its failure type is
constrained to `CliStructuredError`: either replace usages with `Result<T,
CliStructuredError>` or declare the shared generic as `F extends
CliStructuredError`. Ensure the documented success and failure shapes
consistently enforce this constraint.
- Around line 24-37: Update the ADR’s propagation statements around the consumer
example and the `cause` serialization section to distinguish same-process
propagation from cross-process behavior: direct in-process consumers retain the
origin error value, while agents crossing a wire boundary receive only the
serialized error envelope, without the original object or cause chain.
- Around line 49-54: Update the ADR’s “Error subclasses extend the one base
class” section to align with the PR’s objective of collapsing
MigrationToolsError into CliStructuredError: remove the
MigrationToolsError-specific example and subclass guidance, or explicitly state
that domain-specific subclasses remain supported if that is the intended
contract. Ensure the surrounding subclass rules and predicates consistently
reflect the chosen design.
🪄 Autofix

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 Plus

Run ID: 7ab44ac6-c357-4c72-90ae-260e41b32aed

📥 Commits

Reviewing files that changed from the base of the PR and between 8ca57d1 and e4c0fb3.

📒 Files selected for processing (2)
  • docs/architecture docs/ADR-INDEX.md
  • docs/architecture docs/adrs/ADR 245 - Errors are structured at origin; results carry one ok discriminator.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/architecture docs/ADR-INDEX.md

…antiation, subclasses are the contract

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden-electric
wmadden-electric added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit d55cd02 Aug 7, 2026
16 checks passed
@wmadden-electric
wmadden-electric deleted the adr-244-close-out-cli-base-types branch August 7, 2026 16:14
SnowingFox pushed a commit to SnowingFox/prisma that referenced this pull request Aug 12, 2026
…or (prisma#29976)

## Linked issue

n/a — small docs change. Prompted by the engine-side telemetry work now
underway; see the note at the end about what this PR deliberately does
*not* pre-document.

## At a glance

`docs/Telemetry.md`, "Flipping your choice", before:

> To turn telemetry off (or back on), run `prisma-next telemetry
disable` / `prisma-next telemetry enable`, or edit the file in any text
editor and change the `enableTelemetry` value.

After:

> To turn telemetry off (or back on), run `prisma-next telemetry
disable` / `prisma-next telemetry enable`. The command writes the
`enableTelemetry` value for you and the change takes effect on the next
CLI invocation. `prisma-next telemetry status` reports what is in effect
and why.

## Decision

`prisma-next telemetry enable | disable | status` have been in the CLI
the whole time. They exist so nobody has to open a JSON file to change
their telemetry preference. The telemetry page was still teaching the
JSON file as an equal route in three places — one of them told readers
they could pre-create the file before ever running the CLI.

Hand-editing is now documented as what the file *is*, not as something
you should do. The distinction the page holds throughout: **describing
the file is useful reference material; recommending that users write to
it is not.** `telemetry status` prints the file's path, so a reader who
lands on it needs to know what the fields mean.

Nothing about where the file lives, what it contains, or how the fields
resolve is removed.

## How it fits together

1. **"The user-level config file"** opens with one new sentence saying
who writes it: the commands set the preference, `status` prints the
resolved path, and the section that follows describes the contents so
you can *read* them. The path bullets, the JSON samples, and the
`enableTelemetry` / `installationId` field definitions are all
untouched.
2. **Two field descriptions** dropped their "…or a hand edit"
parenthetical. They now say the CLI writes `enableTelemetry` when you
make an explicit choice with `enable` / `disable`.
3. **"Flipping your choice"** stops offering the text editor (shown
above).
4. **"Fully resetting"** no longer offers `keep "enableTelemetry": false
in it` as an alternative to running `disable`.
5. **"The `prisma-next telemetry` command"** now says plainly why it
exists, and notes that `enable` / `disable` write the preference
atomically and preserve every other field in the file — which is the
concrete reason to prefer them over an editor.
6. **"2. The stored preference"** keeps the JSON sample as *what
`disable` writes*, and the paragraph telling readers to drop a pre-made
`config.json` on disk is replaced. Provisioning a machine where the CLI
has never run is a real need, and the environment variables already
serve it — they work before any config file exists and suppress the
first-run notice too.

The `skills/prisma-8` quickstart carried the same hand-edit clause in
its telemetry callout; it goes the same way, keeping the per-user vs.
`prisma-next.config.ts` distinction it was making.

## Reviewer notes

- **Nothing shipped-behaviour-facing moved.** No filesystem path, no
environment-variable name, no wording inside the verbatim first-run
notice, and no `prisma-next` command prefix changed. Token counts for
each of those are identical before and after; the only increase is
`prisma-next telemetry`, which gains two mentions because the commands
are now the route.
- **The first-run notice still mentions setting `"enableTelemetry":
false` yourself.** That block is quoted verbatim from the shipped binary
and is left exactly as-is, so the page keeps matching what users
actually see on stderr. The notice's wording is one of the things
changing on the engine side.
- **Coming, and deliberately not written here:** when this CLI ports
onto the shared Prisma CLI engine, the config directory becomes `prisma`
rather than `prisma-next`, the opt-out variable becomes
`PRISMA_DISABLE_TELEMETRY`, and the first-run notice drops its hand-edit
clause. None of that has shipped in the `prisma-next` CLI this page
describes, so documenting it now would make the page wrong for the
binary people are running. It lands with the port.
- **Anchors.** One new intra-page link, pointing at
`#how-to-opt-out-or-back-in`. It first pointed at the commands section's
own slug, and `lint:legacy-name` was right to reject that: the rule
allows a bare `prisma-next` only when the character after it is neither
a word character nor a hyphen, and `#the-prisma-next-telemetry-command`
is followed by `-telemetry-command`. That is also why the two command
spellings in the same sentence pass. Every existing heading and anchor
is unchanged, so `prisma#2-the-stored-preference` and
`prisma#1-environment-variables-runtime-only` still resolve from their inbound
links.
- **Second file.** `skills/prisma-8/references/quickstart.md` is one
sentence, included so the ruling isn't applied in only half the places a
reader meets it. Easy to drop if you'd rather keep this to
`docs/Telemetry.md`.

## Testing performed

- Docs-only change; no suites apply.
- `pnpm lint:legacy-name` (`node scripts/lint-legacy-name.mjs`) —
passes, on the exact tree pushed.
- `pnpm lint:docs` (`scripts/validate-package-readmes.mjs`) — passes;
its warnings are pre-existing and concern mongo package READMEs
untouched here.
- Verified every intra-page anchor in `docs/Telemetry.md` resolves to a
heading that exists.
- Diffed the frozen surfaces (config paths,
`PRISMA_NEXT_DISABLE_TELEMETRY`, `DO_NOT_TRACK`, `%APPDATA%`,
`$XDG_CONFIG_HOME`, `prisma-next.config.ts`, the notice block) against
`main`: byte-identical.
- The repo has no markdown linter or link checker in CI to run against
`docs/`.

## Skill update

`skills/prisma-8/references/quickstart.md` — the telemetry callout's
opt-out routes now match the page. No CLI surface, flag, config field,
or error code changed, so no other skill content is affected.

## Checklist

- [x] All commits are signed off (`git commit -s`) per the DCO.
- [x] I read CONTRIBUTING.md and the change is scoped to one logical
concern.
- [x] Tests are updated — n/a, doc-only with no behavioural delta.
- [ ] The PR title is in `TML-NNNN: <sentence-case title>` form — no
Linear ticket; follows the `docs(<scope>):` form used by recent docs PRs
(prisma#29958, prisma#29957, prisma#29925).


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

## Summary by CodeRabbit

* **Documentation**
* Clarified that telemetry preferences are managed through CLI commands
rather than manual configuration edits.
* Documented telemetry status behavior, preservation of unrelated
settings, and default-on behavior.
* Added guidance for resetting telemetry and installation identity by
deleting the configuration.
* Updated opt-out instructions to use the telemetry disable command or
environment-variable settings for provisioning.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
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.

3 participants