Repository navigation
docs(adr): ADR 239 amendment — findings as diagnostics in completed envelopes, typed nextActions (S4) - #29957
Conversation
…ions A command settles one of two ways: it completes (with a result that may be good news or bad) or it errors (it could not do its job). ADR 239 only had the second path, so a command asked to look for problems had to throw in order to report what it found, landing on exit 2 alongside "you passed an unknown flag". The amendment gives findings their own path. `migration check` finding integrity violations, `db verify` finding drift: these complete, exit a documented per-command code in the 4-99 band, and carry the individual problems as Diagnostic values in the completed envelope. Diagnostics are pure data, never thrown, no stack. A severity-error diagnostic must come with a non-zero exit code so a shell pipeline never reads a clean 0 over a reported error. The shipped `migration check` already behaves this way (exit 4 = INTEGRITY_FAILED); the ADR now describes it. The second change replaces the freeform `fix?: string` prose field with a typed `nextActions: readonly NextAction[]`, always present and empty when there is nothing to suggest. A fix sentence fuses two actions, a command, and an argument placeholder into English only a human can take apart; a NextAction states the kind, label, and executable command directly. This keeps Diagnostic field-for-field identical to the settled engine envelope. The target shape freezes now and the several hundred call sites convert under a ratchet, the same way the bare-throw ban converts. Severity stays at three values on evidence: errorInitUserAborted() ships with severity `info`, and the migration-status diagnostics publish "warn" | "info" in their JSON schema. CLI Style Guide gains a "Completed with findings" section and its error JSON schema, human layout, and exit-code table are brought into line. ADR-INDEX gains the errors ADR; both entries numbered 239 now say so. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
|
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe documentation defines typed ChangesError envelope and diagnostic conventions
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 8
🤖 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/ADR-INDEX.md:
- Line 100: Amend ADR 245 and its corresponding ADR index entry to present it as
a companion to ADR 239 rather than a separate compatibility layer. Replace the
why/fix contract with why plus typed nextActions, and clarify that
CliStructuredError subclasses are construction details while boundary
recognition remains structural.
In `@docs/architecture` docs/adrs/ADR 239 - Errors are structural envelopes with
dotted namespace codes.md:
- Around line 19-22: Align the Diagnostic model and its documented examples with
the StructuredError envelope described in the ADR. Update the Diagnostic
definition to use the same fields as StructuredError— including message and
cause while removing the divergent summary field—or explicitly document the
field mapping and rationale for excluding provenance. Apply the same correction
to the related sections referenced in the comment.
- Around line 104-107: Update the nextActions commands in the ADR so every
command marked executable can run as written: replace the <valid-hash>
placeholder in the ref-setting action with a command or preceding action that
obtains or computes the valid hash, or explicitly document the required
substitution contract and remove executable treatment until then.
- Line 170: Update isStructuredError to recognize structured error envelopes by
validating their serialized shape and required fields, without using e
instanceof Error, so JSON-parsed envelopes remain recognized across network
boundaries; keep the predicate’s type-narrowing behavior intact.
- Around line 40-46: Update NextAction into a discriminated union so run-command
requires command, user-choice requires commands, edit-file carries its required
payload, and done has no command payload; keep shared fields such as label and
reason on each variant as appropriate. Update the consumer guidance around
nextActions[0] to branch on kind before accessing variant-specific fields,
including the related sections at the other referenced locations.
- Around line 93-109: Update the completed-envelope section around the
migration-check example to explicitly define the required discriminator, the
canonical findings collection name, and that exitCode is part of the serialized
result. Reconcile the contract with migration-check.ts and
cross-consumer-integrity.test.ts by documenting how consumers using ok,
failures, summary, or an external exitCode must migrate to the chosen envelope
shape.
- Line 32: Align the ADR contract with the actual migration state: either
migrate StructuredError, CliStructuredError, CliErrorEnvelope,
errorInitMissingFlags, their producers, serializer, and tests from fix to
nextActions, or explicitly label nextActions as target state and document the
fix transition. Keep the ADR and docs/CLI Style Guide JSON schema consistent.
In `@docs/CLI` Style Guide.md:
- Line 96: Update errorInitMissingFlags so meta.missingFlags stores each missing
flag with its long-form “--” prefix, while preserving the existing prefixed
values used for flagList and fixList.
🪄 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: a6a39bfa-0f41-49a1-a69a-b6868f3475c7
📒 Files selected for processing (3)
docs/CLI Style Guide.mddocs/architecture docs/ADR-INDEX.mddocs/architecture docs/adrs/ADR 239 - Errors are structural envelopes with dotted namespace codes.md
Restructure to grounding-example-first, remove transient refactor framing (pre-amendment states, site counts, internal system numbers), fold the amendment note into a one-line status, and state adoption facts in the present tense. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 239 - Errors are structural envelopes with
dotted namespace codes.md:
- Line 306: Update the crosswalk table around the duplicate PN-CLI-4012 mappings
to identify the legacy producer or distinguishing context for each row, and
document that migration requires contextual disambiguation because the retired
code alone cannot select a replacement. Keep the mappings to
CLI.CONFIG_ARG_MISSING_PATH and CLI.INVALID_VERIFY_MODE explicit.
🪄 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: 2f816e7f-1002-41ed-aae3-126f31a7034d
📒 Files selected for processing (1)
docs/architecture docs/adrs/ADR 239 - Errors are structural envelopes with dotted namespace codes.md
Make the example predicate fully structural to match the shipped one, state the exact Diagnostic-to-envelope field mapping, document the flat NextAction shape and placeholder convention, disambiguate the duplicate PN-CLI-4012 crosswalk rows, and label the fix-to-nextActions transition in the style guide. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/architecture docs/adrs/ADR 239 - Errors are structural envelopes with dotted namespace codes.md (1)
318-318: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winMark the second schema mapping as a merge.
The crosswalk defines
↦ mergesat Line 237.PN-RUN-3004at Line 286 andPN-SCHEMA-0001at Line 318 both map toCONTRACT.SCHEMA_VERIFICATION_FAILED. Add the merge annotation to thePN-SCHEMA-0001row or explain why this many-to-one mapping is excluded.Proposed clarification
-| PN-SCHEMA-0001 | SQL schema-verify failure (the `SCHEMA` domain's only producer; the domain is dropped with it) | `CONTRACT.SCHEMA_VERIFICATION_FAILED` | +| PN-SCHEMA-0001 | SQL schema-verify failure (the `SCHEMA` domain's only producer; the domain is dropped with it) | `CONTRACT.SCHEMA_VERIFICATION_FAILED` ↦ merges with `PN-RUN-3004` |🤖 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 `@docs/architecture` docs/adrs/ADR 239 - Errors are structural envelopes with dotted namespace codes.md at line 318, Update the PN-SCHEMA-0001 row to annotate its mapping to CONTRACT.SCHEMA_VERIFICATION_FAILED as a merge, consistent with the crosswalk notation and the PN-RUN-3004 mapping. If this mapping is intentionally excluded, document the explicit rationale in the row instead.
🤖 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 239 - Errors are structural envelopes with
dotted namespace codes.md:
- Line 359: Clarify the ADR’s handling of the run-command action’s commands
field: define whether commands is a sequence or an alternative list, then update
the remediation consumer rule to execute it accordingly alongside command;
otherwise restrict commands to user-choice actions and state that constraint
explicitly.
- Line 118: Update the ADR’s StructuredError/Diagnostic comparison to explicitly
address their severity mismatch: either define and document the default applied
when StructuredError.severity is omitted, or make both declarations use the same
optionality. Revise the nearby “two deliberate differences” and identical
field-for-field mapping statements so they accurately include the chosen
severity behavior.
- Around line 48-52: Update isStructuredError to require a valid nextActions
collection and validate each NextAction before returning true, preventing
consumers from receiving incomplete envelopes. Align the StructuredError
foundation interface and structuredError factory so nextActions is required and
consistently populated with the expected type.
---
Outside diff comments:
In `@docs/architecture` docs/adrs/ADR 239 - Errors are structural envelopes with
dotted namespace codes.md:
- Line 318: Update the PN-SCHEMA-0001 row to annotate its mapping to
CONTRACT.SCHEMA_VERIFICATION_FAILED as a merge, consistent with the crosswalk
notation and the PN-RUN-3004 mapping. If this mapping is intentionally excluded,
document the explicit rationale in the row instead.
🪄 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: 9c66c85b-b7ae-48c4-8b95-ca676ae697f1
📒 Files selected for processing (2)
docs/CLI Style Guide.mddocs/architecture docs/adrs/ADR 239 - Errors are structural envelopes with dotted namespace codes.md
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/CLI Style Guide.md
Two ADRs carried the number 239. The errors ADR keeps it (referenced by number from code comments, the style guide, and ADR 245); the option-arguments ADR becomes ADR 246, the next free number. Index rows and the two code comments that cited it follow. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
size-limit report 📦
|
prisma-next
@prisma/orm-extension-arktype-json
@prisma/orm-extension-middleware-cache
@prisma/orm-extension-paradedb
@prisma/orm-extension-pgvector
@prisma/orm-extension-postgis
@prisma/orm-extension-supabase
@prisma/orm-family-mongo
@prisma/orm-family-sql
@prisma/orm-framework
@prisma/orm-mongo
@prisma/orm-postgres
@prisma/orm-sqlite
@prisma/orm-target-mongo
@prisma/orm-target-postgres
@prisma/orm-target-sqlite
@prisma/orm-toolchain
commit: |
Add the open-url action kind and url field to match the shipped engine protocol, define command vs commands semantics, document the envelope contract both settlement paths share, state the third Diagnostic difference (required severity), and scope the predicate to identification rather than schema validation. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> # Conflicts: # docs/architecture docs/ADR-INDEX.md
) Trails prisma#29957, which amended ADR 239 to replace the freeform `fix?: string` prose field with a typed `nextActions: readonly NextAction[]`. ADR 245 governs how ADR 239's envelopes are **built and carried**, so it spells the envelope fields out in its examples and prose — and five of those spellings still said `fix`. This brings it into line. Merge after prisma#29957. ## The grounding example, before and after ADR 245 opens with a raise site: the only place that knows enough to fill in an envelope. **Before** ```ts errorRuntime('MIGRATION.SNAPSHOT_MISSING', `Ref "${refName}" is not resolvable`, { why: `Ref "${refName}" has no pointer file and its fallback hash is not a graph node.`, fix: `Create the ref with \`prisma-next ref set ${refName} <hash>\`, or pass a graph-node hash.`, meta: { identifier: refName, viaRef: true }, }) ``` **After** ```ts errorRuntime('MIGRATION.SNAPSHOT_MISSING', `Ref "${refName}" is not resolvable`, { why: `Ref "${refName}" has no pointer file and its fallback hash is not a graph node.`, nextActions: [ { kind: 'run-command', label: 'Create the ref', command: `prisma-next ref set ${refName} <hash>` }, { kind: 'user-choice', label: 'Or pass a graph-node hash instead of a ref name' }, ], meta: { identifier: refName, viaRef: true }, }) ``` The `fix` string was two alternatives fused into one sentence, with a backtick-quoted command and a placeholder inside it. A consumer wanting to offer "create the ref" as a one-click action had to parse English to find the command. Now it reads `nextActions[0].command`. ## The decision No new rules. ADR 245 says the same things in the vocabulary ADR 239 settled. Five sites: 1. **The raise-site example** above. 2. **The serialized `toEnvelope()` field list** — `code`/`summary`/`why`/`nextActions`/`where`/`meta`, without `cause`. 3. **Rule 1** — a failure carries "its own dotted code, its own `why`, and its own `nextActions`". 4. **The `MigrationToolsError` subclass example** — its constructor requires `why` and a non-empty `nextActions`. (The shipped class currently requires `why`/`fix`; like every other call site, it converts under the ratchet ADR 239 describes. No code is changed here.) 5. **The "Why" paragraph** on structuring at origin. This one gets *sharper* under the rename rather than merely renamed, so it gained a sentence: a next action names an executable command with real arguments in it, and the raise site is the only place that holds those arguments. The argument for structuring at origin was always about where the knowledge lives; typed actions make the claim concrete. The `Related:` line now points at ADR 239 for the field definition itself, so a reader who lands on 245 first knows where the shape is specified. `ADR-INDEX.md`'s description of ADR 245 is updated to match. ## What is not here - **No code changes.** The several hundred `fix:` call sites — `MigrationToolsError` included — convert under the ratchet, per ADR 239. - **`docs/Error Handling.md` untouched.** It says user-facing surfaces should "emphasize `why/fix/docs`", which is loose prose about what to foreground, not a field list. Nothing there is now wrong. Say the word if you want it tightened anyway. ## Verification `node scripts/list-error-codes.mjs --verify docs/reference/error-reference.md` → *error-reference lists all 275 known codes.* No codes change. Docs-only, so no test suites. ## Note for whoever merges Both this PR and prisma#29957 touch `ADR-INDEX.md`, and their edits land on adjacent lines — prisma#29957 inserts a new ADR 239 row immediately above the ADR 245 row that this PR edits. Expect a possible textual conflict on the second merge; the resolution is to keep both changes. Slice S4 of prisma-cli-v8, follow-up. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated architecture documentation to describe typed `nextActions` alongside structured error codes and explanations. * Revised ADR 245 examples and guidance to use structured follow-up actions instead of string-based fixes. * Clarified requirements for error subclasses and serialization of recommended next steps. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
…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]>
Number collision resolved: the authoring-helpers ADR is now ADR 246
Two files were numbered ADR 239. Per operator ruling, this PR renumbers
Option arguments and select templates for authoring helpersto ADR 246 (the next free number); the errors ADR keeps 239 because it is referenced by number from source comments, the CLI Style Guide, and ADR 245. The index rows and the two code comments that cited the authoring ADR by number follow the rename.What this looks like in practice
Run
migration checkagainst a migrations tree with a dangling ref.Before
Exit
2means "your invocation was wrong". It was not — the command did exactly what it was asked to do and found something. A shell pipeline cannot tell this apart from a typo'd flag, and an agent has to parse an English sentence to discover there is a command it could run.After
{ "ok": true, // the command completed "commandId": "migration.check", "exitCode": 4, // INTEGRITY_FAILED, documented by this command "result": { "failures": 1 }, "diagnostics": [ { "code": "MIGRATION.CHECK_DANGLING_REF", "severity": "error", "summary": "Ref \"prod\" points at a hash no migration produces", "where": { "path": "migrations/refs/prod" }, "nextActions": [ { "kind": "run-command", "label": "Repoint the ref", "command": "prisma-next ref set prod <valid-hash>" }, { "kind": "run-command", "label": "Or delete it", "command": "prisma-next ref delete prod" } ] } ], "nextActions": [] }ok: truebecause the command completed. Exit4because it found something, and4is what this command documents. The finding is a diagnostic, not a thrown error. Remediation is two executable commands, not a sentence.The shipped
migration checkalready returns exit 4 (migration-check/exit-codes.ts) — the ADR simply did not describe the model that behavior belongs to, and classified findings as structured failures exiting2.The decision
Two amendments to ADR 239, folded into the body with an amendment note at the top (following the ADR 211 / ADR 234 precedent rather than a trailing section).
1. Completed-with-findings. A command settles one of two ways. It completes — it ran to its end and has a result, good news or bad — or it errors, meaning it could not do its job. Findings belong to the first path: they are
Diagnosticvalues in a completed envelope with a documented per-command exit code in the4–99band. Findings are data. They are never thrown.The test is one question: was finding these problems the job?
migration checkreporting integrity violations did its job. It exits2only when it cannot run the check at all — an unresolvable migration reference, an unknown--space.One runtime check keeps this honest: a
severity: 'error'diagnostic requires a non-zero exit code, so a pipeline never reads a clean0over a reported error.The exit-code table now reads:
0completed cleanly /1bug only /2errored (expected, structured) /3user abort /4–99documented per command /130,143signals.2.
fix→ typednextActions. The freeformfix?: stringis replaced bynextActions: readonly NextAction[], always present, empty when there is nothing to suggest.NextActionis{ kind: 'run-command' | 'user-choice' | 'edit-file' | 'done', label, command?, commands?, reason? }. An errored envelope copies the primary error'snextActionsso consumers readenvelope.nextActionson both settlement paths.This keeps
Diagnosticfield-for-field identical to the settled engine envelope minusok. That identity is the point — a consumer that can read a finding can read an error.The code sweep trails. The ADR freezes the target shape; the several hundred
fix:call sites convert cluster by cluster under a ratchet, exactly as the bare-throw ban in the same ADR converts. Converting first and settling the shape afterwards would letDiagnosticand the error envelope drift while half the tree used each spelling. No code is renamed in this PR.Severity: the three-value scale stays, on evidence
The amendment was contingent on whether any shipped error uses
severity: 'info'. I grepped production code (excluding tests). It does:packages/1-framework/3-tooling/cli/src/commands/init/errors.ts:119—errorInitUserAborted()constructs aCliStructuredErrorforCLI.INIT_USER_ABORTEDwithseverity: 'info'. It is the right value: nothing went wrong, the user changed their mind, and rendering it as a red error would misreport it.packages/1-framework/3-tooling/cli/src/utils/migration-types.ts:9—StatusDiagnostic.severityis typed'warn' | 'info'.packages/1-framework/3-tooling/cli/src/commands/json/schemas.ts:80,87— theCONTRACT.UNREADABLEandMIGRATION.MARKER_NOT_IN_HISTORYdiagnostics publish"warn" | "info"in their JSON schema, so'info'is already part of the machine-readable surface consumers match on.So both scales stay at
'error' | 'warn' | 'info', and they stay identical to each other. Trimming would be a breaking change to a published surface with a live producer behind it. The evidence is recorded in the ADR under The severity scale, and the trim is written up as a rejected alternative.Files
docs/architecture docs/adrs/ADR 239 - Errors are structural envelopes with dotted namespace codes.md— amendment note, the two-settlement-paths decision,Diagnostic/NextActionin the grounding example, a rewritten exit-codes section with the full table, new Remediation is typed, not prose and The severity scale sections, and three new rejected alternatives.docs/CLI Style Guide.md— § Errors (JSON schema, human layout, exit-code sentence, missing-flags rule, destructive-op rule) and § Exit Codes (a new Completed with findings subsection;0and2reworded). The4–99band and itsmigration checkexample were already there and already agreed; this makes the semantics explicit.docs/architecture docs/ADR-INDEX.md— adds the errors ADR; the authoring-helpers row is renumbered to 246.Alternatives considered
Findings as structured failures exiting
2(the status quo ante). Makes a command throw to report what it was asked to find, and puts "eleven violations" in the same exit-code bucket as "unknown flag".A separate
Findingshape unrelated to the error envelope. Two renderers, two JSON schemas, two things to learn — for a distinction that is about carrier, not content.Keep
fixalongsidenextActions. Guarantees they disagree; every factory would hand-sync a sentence against a list.Trim severity to
'error' | 'warn'. Rejected on the evidence above.Verification
node scripts/list-error-codes.mjs --verify docs/reference/error-reference.md→ error-reference lists all 275 known codes. (No codes change, but the change touches the code-space docs.)node scripts/validate-package-readmes.mjs→ passes; its warnings are pre-existing and unrelated.pnpm lintis biome over source and has nothing to say about these three files.Left undone (deliberate)
fix→nextActionscode sweep. Out of scope; the ratchet is the plan.ADR 245still says "why/fix" in its body and in its index description. It governs how ADR 239's envelopes are built, so it will want the same rename — separate PR, since editing it means re-reading its own argument.docs/Error Handling.mduses "why/fix/docs" as loose prose about what to emphasize, not as a field list. Left alone; flag it if you want it tightened.4–99band in the Style Guide already documentedmigration check's4 = INTEGRITY_FAILED, so no exit-code numbers changed anywhere — only what they mean.Slice S4 of prisma-cli-v8.
🤖 Generated with Claude Code
Summary by CodeRabbit