ADL 31 · Part IV — Generated interfaces

0.6.0 reconciled + 0.5.1 detail

Error contract

ADL 0.6.0 reference · Review draft 1 · November 14, 2026.

Contents · Source map · Evidence

The 0.6 edition note

An error has both a meaning and a presentation surface. Preserve the diagnostic actually emitted by that surface. A parser token embedded in a message, a CLI diagnostic code, an HTTP status, and a field-validation code are not interchangeable.

The fresh old-version policy fixture is a concrete example. The CLI exits nonzero and reports success: false, with an error object whose code is E000. Its message begins with ADL_POLICY_VERSION. Reporting only one of those values loses information; pretending that the CLI emitted ADL_POLICY_VERSION as its structured code misstates the output.

Journey compilation uses a different JSON report: ok, error counts, journeys, and structured diagnostics such as E-JRN-ACTOR-OWNER, E-JRN-CALL-FORM, and E-JRN-EXPR-UNKNOWN-INPUT. Those codes are observed by the new fixtures. They are not ordinary HTTP response envelopes.

Runtime and recovery

The retained response contract uses numeric code for response status and error_code for the machine-readable family. A field’s nested validation code has its own meaning. Clients should identify the operation and error family before interpreting data, and retain a fallback for unknown codes or absent structured locations.

A guard refusal, a resource-policy refusal, and missing policy supervision can all prevent an approval. They need different remedies: a different eligible actor or state, satisfied obligations, or a corrected deployment. Retrying the same request indiscriminately is not a recovery policy. An error after a side effect also requires attention to transaction boundaries; compensation is not automatic rollback.

The diagnostic register is generated from the new evidence. It retains expected rejection cases and labels the observed export deviation separately. The older large diagnostic catalog remains useful but describes its original lexical inventory and classification baseline. This edition does not relabel it as a newly executed catalog of every installed plugin.

Human-readable messages explain the failure. Use structured codes and locations when supplied; do not manufacture a path or HTTP status from wording. The raw fixture output is kept precisely so adapters and future clients can be assessed against what was emitted.

Retained reference detail

The numbered sections below are carried from 31-error-contract.md. Their original baseline and evidence remain attached to the source. Statements about “current” or “checked” behavior in this retained text refer to those original observations unless the edition note explicitly updates them. This is a consolidated draft, not a claim of complete re-verification.

31.1 Purpose and scope

An error contract lets an author locate a rejected declaration and lets a client handle a failed operation without parsing prose. This chapter owns the ADL response envelope, diagnostic distinctions, and the versioned code catalog. ADL 20 owns validation rules; ADL 26 owns generated route identity; ADL 33 locates operations. Authentication providers and platform administration retain their own operation-specific error contracts.

The governing material is error-contract.yaml — which test_phase_19_v051 enforces as a post-condition, failing the build on any emitted code the contract does not classify — together with delta §17 and §18 and signed rulings. The v0.3.1 error chapter (retired) is the provenance of the envelope shape, not a current authority over it. A classification of addition is not a ratified new requirement. A pending vector is not a demonstrated runtime rejection.

Behavior checks in this draft use revision 3a1655dc, including the Phase-19 structured-diagnostic implementation. Earlier release plans placing error completion in cut -c are historical planning evidence; the inspected source and executed cases establish this draft’s implementation observations.

31.2 Envelope and the three meanings of code

An ordinary error response has this shape:

{
  "status": "error",
  "code": 422,
  "error_code": "VALIDATION_ERROR",
  "error_message": "Validation failed",
  "data": {
    "title": {"code": "required", "message": "Field is required"}
  }
}
MemberContract
status"error" for a failed response
codeInteger response status, normally the HTTP status at the REST boundary
error_codeMachine diagnostic name such as VALIDATION_ERROR
error_messageHuman-readable explanation; wording is not a stable parsing interface
dataContext owned by the error family (object, array, or null)

Do not confuse an HTTP-like response status with the numeric kalos::ErrorCode returned by a C++ parser API. The latter is an internal error category, not an HTTP status. Likewise, a lowercase data.title.code identifies a validation rule; it is distinct from the uppercase response-level error_code. When a parameterized constraint or named validation rule fails, the field detail also includes params (for example {"min": 10}, {"max": 200}, {"pattern": "..."}, {"enum": [...]}, or {"rule": "titleNotBlank"}; #1551) so clients can format localized messages without parsing prose.

The inherited rule says only VALIDATION_ERROR carries structured data. Delta §17 already requires data.path and data.use for renamed values. Current Phase-19 submission errors also carry diagnostic data, so the older universal null rule no longer describes the whole edition. A client must branch on the error family before interpreting data.

Response::to_json() always emits status, code, and data. It emits the error-name/message members when nonempty. The executed normal failures have both; the serializer alone does not force every arbitrary hand-built response to contain all five keys. The examples record this actual serializer output. They do not substitute a manually assembled envelope for native evidence.

31.3 Failure phase and location

PhaseTypical causeExpected next action
YAML/JSON ingestionInvalid syntax or mapping keyRepair the source representation
Version and vocabulary admissionMissing/unsupported adl, retired key/type/valueSelect an admitted version or current spelling
Resolution and compositionMissing import/target, bad address, cycle, protected overrideRepair dependencies, locator, or composition
Semantic validationInvalid references, capability declaration, model invariantCorrect the declaration or deployment grant
Activation/migrationIdentity/version conflict, destructive change, DDL failureReview version and migration evidence
Generated operationPermissions, field validation, state transition, storage failureApply the operation’s owning contract
Transport/site routingUnroutable site, malformed request, authentication failureCorrect transport context rather than the ADL model

The C++ parser can return a leading machine token within Error.message. AdlDiagnostic separates code, explanatory text, and optional address and path suffixes. It recognizes coded diagnostics even behind a suite-member prefix. The domain-submission adapter converts that result into an envelope. For a coded parse error it emits data.code, plus data.address and data.path when present. An uncoded parser failure becomes 422 PARSE_ERROR.

Location is not guaranteed for every diagnostic. The structured helper only extracts its defined suffix forms; a path embedded in ordinary prose is not automatically a data.path. The renamed-key/value examples record this gap, including the absence of the promised replacement member for the checked renamed-value failure. PUT_INCOMPLETE also carries an array of missing names in the checked replacement failure. A frontend should display prose as explanation while using structured locations only when actually supplied.

31.4 Status rules and implementation exceptions

Delta §17 requires syntax, resolution, and semantic-validation failures to use 422 unless a listed exception applies. Routing and digest/lock conflicts use 409. Fetch, authentication, and transport failures retain their ordinary statuses and must not be recast as validation errors.

StatusADL-facing example or boundary
400Malformed operation input or unusable query field
401Missing authentication when the action requires it
403Forbidden action, failed guard, or denied write authority
404Missing record/domain or unknown action
409Duplicate key, record version conflict, site or digest conflict
421Unknown site in the site resolver’s contract
422Rejected document, field validation, invalid transition
429Rate limit; retry metadata is transport-specific
500Storage, registry, or execution fault
501Unsupported operation, including a host’s unavailable capability
503Unavailable dependency or exhausted store capacity

This table groups failure classes; it does not promise that every handler uses the same code for superficially similar failures. For example, duplicate-key mapping belongs to the store adapter, and domain version conflicts can travel through different submission paths. Use the code catalog and the owning chapter’s recorded operation for a precise claim.

The classification file carries status_note for deliberate deviations from §17, including statuses determined by signed rulings. Preserve that explanation when consuming the catalog. Passing the classification reconciliation does not prove every call site emits the classified status under every input.

31.5 Validation detail

VALIDATION_ERROR commonly carries an object keyed by field name or rule name. Each value has a lowercase code and a message. Nested content can use paths such as profile.caption or cards[0].label; these strings are diagnostic locations, not a separate JSON Pointer guarantee.

The vocabulary includes presence (required), type (invalid_type), bounds (too_long, too_small, too_many_items), format (invalid_email, invalid_uuid), and domain-specific content failures such as unknown_media. The legacy fixed list is incomplete for the current source. The generated catalogs identify how each inventory was collected and distinguish response codes from field-detail tokens.

Cross-field errors use a rule name when there is no single input field. Multiple failures sharing a key can overwrite one another in the final detail object. ADL 20 records that behavior and custom-message selection. Error rendering should have a form-level fallback when a diagnostic key has no corresponding input control.

UNKNOWN_FIELDS, IMMUTABLE_FIELD, and REQUIRED_FIELD are separate response families on some write paths. Do not interpret their data as field-validation objects merely because the user was editing a form. PATCH, PUT, bulk, and import also have different validation and atomicity boundaries.

31.6 The versioned catalog

The code catalog is generated from the checked source and the production classification file. It retains exact identifiers, classification, status, specification reference, vector state, and source paths. The corresponding JSON catalog is suitable for inspection by tools.

The source walker scans C++ .cpp and .h files under plugins/adl/src and plugins/transport/rest/src, skipping test directories. It recognizes leading code-token literals, literal Response::error names, embedded JSON error-code literals, and a supported local err helper spelling. Its categories mean:

ClassMeaning
contractCode listed by the governing contract
additionProposed additional language diagnostic
internalRuntime/management/transport diagnostic outside the language table
unimplementedContract entry without a current emitter
retiredWithdrawn entry retained for provenance
not-a-codeA token the lexical source walk matched that is not a diagnostic

This is a lexical inventory, not control-flow reachability analysis. Comments can match, dynamically constructed identifiers can escape the patterns, and other plugins or kernel sources lie outside its roots. The chapter does not call it the total set of errors from an installed Kalos server. File-level provenance and the classification reconciliation make the scope reviewable.

The Phase-19 test compares the JSON catalog linked by this chapter, the current source walk, the classification file, and existing vector declarations. The published catalog is a versioned snapshot; newly emitted runtime codes must still be classified in adl/v0.5/error-contract.yaml. Its status and missing-vector checks are useful catalog gates. They do not execute every vector, nor do pending/unimplemented entries become implemented because that test passes. The new examples separately execute representative parser, submission, validation, permission, not-found, duplicate, unknown-action, and database failures.

31.7 Recovery and verification boundaries

Branch first on the numeric response status, then on error_code, then interpret that family’s data. Keep a fallback for unknown codes. Display error_message as text and retain it for diagnosis; do not extract policy decisions from its wording. Retry only when the operation’s semantics support it. In particular, a failed bulk/import request may have performed earlier writes, and an expired refresh token is not a reason to loop through refresh again.

This batch uses the production parser, the kernel action router, native response serialization, and disposable SQLite. It deliberately drops only its own test table to demonstrate a database error. No production data is changed. It records independent modeller diagnostics separately because a modeller’s code/path representation is not the server response envelope.

The evidence identifies sources, commands, results, assertions, catalog checks, and remaining discrepancies. Network HTTP serialization, token refresh, remote dependency failure, rate-limit timing, and every error emitter are outside the executed scope. Their behavior must be established by the platform or owning feature evidence before being promised.