ADL 0.6.0 reference · Review draft 1 · November 14, 2026.
Contents · Source map · Evidence
The 0.6 edition note
Named enumeration definitions may carry descriptions as well as values. A field referencing that enumeration still has its own metadata. The inspected parser regression tests near KeyCoverage in plugins/adl/tests/test_adl_parser.cpp cover preserving the enum’s description without leaking it into a referencing field’s description.
The complete calibration example uses $ref: "#/enums/CalibrationStatus"; both validators accept it without warnings in this edition’s run. This is acceptance evidence, not a new execution of every metadata regression or projection test. The handbook records a separate lint limitation: an enum bound through $ref may still attract unused-enum advice. A lint finding must not be substituted for a parser or resolver failure.
Retained reference detail
The numbered sections below are carried from 11-enumerations.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.
11.1 Scope and authority
An enumeration constrains a string field to a fixed set of member names. The
name is the value a client sends, receives, filters, and indexes. A label is
display metadata for that value. There is no type: enum: declare
type: string and bind the enum as a constraint.
The inherited body is reduced v0.3.1 Chapter 9 (retired). Draft 05 §18 item 25 replaces its two named-enum forms with mapping form only. Item 29 and §§21.1/21.4 make member declaration order significant and preserve it through canonical encoding. These amendments supersede the older list-form allowance and any claim that alphabetical member sorting is harmless.
ADL 10 owns field types, defaults, and nullability;
ADL 13 owns composition and $ref;
ADL 20 owns validation ordering;
ADL 22 owns state machines;
ADL 31 owns error envelopes; and
ADL 32 owns complete OpenAPI generation.
ADL 9
owns canonical bytes and digest rules. This chapter explains what enum order
means without defining a second encoding profile.
11.2 Declare a named enum
Named enums belong in domain.enums. Each enum has a values mapping whose
keys are member names and whose values are metadata mappings. Use {} for a
member with no metadata. This is a fragment from the complete ticket model:
enums:
TicketStatus:
values:
pending:
label: "Pending"
description: "Awaiting review"
color: "#FFA500"
icon: "lucide:clock"
review: {}
delivered:
label: "Delivered"
description: "Work completed"
color: "#008000"
icon: "lucide:check"
final: true
The member names are pending, review, and delivered, in that order.
Pending is a label, not an alternate accepted value. An empty metadata body
does not remove the member or create a special “simple enum” form. The checked
model marks every accepted mapping declaration as rich, including bare members.
Declare at least one member. Named values: [pending, review, delivered],
lists of member objects, and scalar member bodies such as pending: Pending
are rejection cases. Empty values: {} also rejects in the checked parser.
Use pending: { label: "Pending" } when the scalar was intended as a label.
A bare member written pending: (a null body) is also refused; write
pending: {} (ruling R21, kalos#924).
Admission limits. The checked parser accepts missing, null, and scalar
values declarations as empty enum definitions, although they do not meet the
mapping-form contract. Those empty definitions provide no useful allowed-value
set. Do not use successful parsing to justify these forms. Mapping keys are
member strings after ingestion; a YAML key 7 was retained as the member name
"7". Quoting numeric-looking or boolean-looking names makes their intended
string identity clear to other YAML tools.
Enums and their members are parse-time constructs. They do not acquire runtime
ADL resource addresses; see ADL 7. A domain enum name in a
field binding and a local pointer such as #/enums/TicketStatus are different
notations for the mechanisms described below.
11.3 Member identity and metadata
The five inherited metadata keys are optional. Their meanings do not depend on the type of editor or client displaying them.
| Key | Value shape | Inherited default | Meaning |
|---|---|---|---|
label | String, or per-locale mapping | Member name | Display text |
description | String | Empty string | Extended explanation |
color | String | Empty string | #RRGGBB display color |
icon | String | Empty string | Icon identifier |
final | Boolean | False | Descriptive terminal marker |
Changing a label does not rename a stored member. Changing pending to
waiting changes the allowed value and requires considering existing rows and
clients. Color, icon, and description do not add accepted aliases either.
Observed metadata behavior. The production model retains all five keys
for the authored members, and the two named field-binding forms retain copies
of the member metadata. For the bare review: {} member, the bound label is
empty and introspection returns {}; the inherited member-name label default
is not materialized at those surfaces. A client can display the member name
as a fallback, but that is a consumer decision, not proof that the host filled
the default.
A checked locale map { en: "Pending", fr: "En attente" } survives in the
model, whose convenience label is Pending; the schema helper emits that
English label. This does not test HTTP locale negotiation or every fallback
rule. ADL 46 owns localization.
An unknown metadata key survives in the resolved source but is not modeled as
one of the five member attributes, and produced no warning in the checked case.
A numeric label was accepted without a useful label; a string final: "yes"
raised a generic JSON type exception at the parser boundary. Those observations
do not make arbitrary metadata or the wrong value shapes part of the contract.
11.4 Bind a string field
The inherited four forms remain distinct. The retirement of named enum
values lists does not retire a field’s inline enum list.
| Form | Field declaration fragment | Bound name | Member metadata on the checked field |
|---|---|---|---|
| Inline | { type: string, enum: [pending, review, delivered] } | None | None |
Named enum | { type: string, enum: TicketStatus } | TicketStatus | Retained |
Named enumRef | { type: string, enumRef: TicketStatus } | TicketStatus | Retained |
| Directive | { $ref: "#/enums/TicketStatus" } | None after expansion | Lost |
The two named forms resolve the declared enum and populate its allowed names
on the field. $ref runs earlier, during directive resolution; it expands the
declaration into type: string and an inline list of names. The original
domain enum still exists, but the expanded field no longer names it or carries
its rich metadata. The checked expansion emits no metadata-loss warning.
All four correctly bound forms accept pending, reject alien and Pending,
and have the same string storage representation. They are equivalent for this
membership check; they are not interchangeable when a client needs labels or
the identity of the reusable declaration. Prefer a named binding when those
are needed. Inline lists are useful for a field-local set without member
metadata; an independent inline list does not change when a named enum changes.
Use one binding form per field. This is authoring guidance rather than a newly
specified conflict-resolution rule: the reviewed sources do not establish a
portable meaning for contradictory forms. In the checked production parser,
enum: [alien] together with enumRef: TicketStatus produces the union
alien, pending, review, delivered, while its schema references only
TicketStatus. When both keys contain names, enumRef overwrites enum’s
name. The independent modeller handles these combinations differently.
Unresolved-name gap. enum: Missing and enumRef: Missing parse without
warnings and bind an empty allowed-value list in the checked production path.
The validator then accepts alien; a generated create also stores it. A missing
$ref target instead rejects before model construction. The modeller reports
UNKNOWN_ENUM_REF for the missing named declaration. A misspelled enum name
must not be treated as an intentional unrestricted string field.
11.5 Declaration order and canonical identity
Member order is declaration order. A producer must preserve it during
ingestion, even though ordinary mappings are sorted at the canonicalization
stage. Under Draft 05 §21.4, named enum values mappings encode as ordered
arrays of [name, body] pairs. The encoding mechanism and its limits are
specified in ADL 9.
The baseline declares pending → review → delivered.
reordered.yaml keeps every member body
and field binding unchanged but declares delivered → review → pending.
The checked production model and named enum schema preserve each order, and
both source and resolved digests differ. Equivalent baseline YAML and JSON
have equal digests. An older enum-form test comment saying the parser sorts
members alphabetically is stale at these checked surfaces.
Order significance does not convert string values into numeric ordinals. Draft 05 notes that ordinal positions may be persisted, which explains why order cannot be discarded; it does not amend the inherited string API or prove that the checked adapters store ordinals. Both generated DDL variants use text columns for this example, and the SQLite actions return member strings.
An introspection limit remains: the checked schema action returns a values
mapping serialized alphabetically as delivered, pending, review. Its resolved
field lists and the named OpenAPI enum array preserve declaration order, but
the mapping alone does not communicate the original ordering reliably. Clients
must distinguish those output surfaces; this draft does not invent an order
key to compensate.
11.6 Defaults, omission, null, and updates
Choose a default from the allowed member names. Defaults and required are
field constraints, not additional enum members. The first member is not an
implicit default: write default: pending when that is the intended create
value.
| Input or operation | Contract and checked boundary |
|---|---|
| Explicit valid string | Membership check succeeds for all four binding forms |
| Explicit invalid or differently cased string | Membership check fails with enum_violation |
| Omitted optional field without default | Membership check is skipped; accepted in direct checks |
| Omitted field with valid default | Checked create supplies pending |
| Optional null | Not an enum member; membership check is skipped in direct checks |
| Required field omitted without default | Rejected with required in direct validation |
| Partial update omits enum field | Existing value remains; checked label/title-only updates do not revalidate it |
Explicit null still has to satisfy the field’s presence/nullability contract.
The inherited enum chapter’s statement that every non-required field accepts
null is too broad when nullable: false is declared. Use
ADL 10 §10.6
for that distinction. The direct helper also accepts null on a required enum
field with a default; this chapter does not infer full-write behavior from
that helper result.
Invalid-default gap. A document declaring default alien against
TicketStatus is accepted by the checked parser and submission handler. A
create omitting status returns 201 and stores alien; the following get
returns the same value. Membership validation on explicit input therefore does
not prove validation of generated defaults. The fixture records this as a
defect, not an accepted modeling pattern.
The inherited chapter describes PUT as replacement validation. This adapter invokes generated actions directly and does not exercise PUT or its transport mapping. Only its tested partial-update behavior is claimed here.
11.7 Validation scope and error consequences
Membership comparison is exact and case-sensitive. For a correctly bound
string field, an invalid generated update returns response code 422 with
error_code: VALIDATION_ERROR. Its field-keyed payload includes:
{
"status": {
"code": "enum_violation",
"message": "Must be one of: pending, review, delivered"
}
}
This is the observed data payload, not a complete HTTP response. The message
uses member names in declaration order, not labels, descriptions, or localized
display text. Retaining metadata on the field does not mean every diagnostic
uses it. ADL 31 owns the full error contract.
The enum constraint belongs on string. The checked parser also accepts a
named enum on integer and text; their type-specific validators then bypass
string membership checking, even though the schema references a string enum.
Those declarations do not establish additional supported enum base types.
Nested fields and array items need separate checks. In the direct cases,
component.object.status.enum: TicketStatus and an array item’s inline enum
both accept an out-of-set value. The nested/item parser does not preserve and
resolve the complete enum constraint there. This is the same incomplete nested
field model identified in ADL 10 §10.5.
An empty inline enum: [] becomes an unconstrained string in this validator.
Non-string entries in an inline list are silently discarded by the production
parser. Neither behavior proves a valid empty enumeration or a portable
coercion rule. Declare a nonempty set of explicit string names and verify that
the bound field contains the intended list.
11.8 Storage and out-of-band writes
The inherited implementation boundary is application-level enforcement.
An enum field is an ordinary string column; the checked SQLite and PostgreSQL
DDL generators emit no enum membership CHECK, enum type, or member lookup
foreign key for this example. PostgreSQL evidence stops at generated SQL.
The disposable SQLite sequence deliberately changes the stored value to
out_of_band through direct SQL. The write succeeds, and the generated get
returns that value unchanged. A read does not detect or repair the invalid
member at this surface. This corrects the older chapter’s implication that an
invalid out-of-band value would be detected when read.
Application membership validation consequently does not protect writes made through another storage path. Migration, seeding, repair, and integration procedures need their own guarantees. This chapter does not assume that every seed path bypasses validation or prescribe a new database constraint syntax.
11.9 Final markers and state machines
Enum member final: true is descriptive metadata. It does not forbid a later
write, add transition permissions, execute side effects, or close a lifecycle.
The checked sequence moves pending → delivered → pending with successful
updates even though delivered is final.
Use ADL 22 when only declared transitions may occur, or when
entry/exit behavior must run. An enum can supply the allowed state names; the
state machine adds movement and transition rules. An enum’s final marker and a
state machine’s terminal-state rules are different declarations with different
consequences. Merely naming a field status supplies neither transition rules
nor authorization.
11.10 Schema output and a complete example
The complete tickets.yaml uses baseline
constructs and adl: "0.5.0". Its resource demonstrates all four bindings:
adl: "0.5.0"
domain:
name: enumdemo
version: "1.0.0"
enums:
TicketStatus:
values:
pending:
label: "Pending"
description: "Awaiting review"
color: "#FFA500"
icon: "lucide:clock"
review: {}
delivered:
label: "Delivered"
description: "Work completed"
color: "#008000"
icon: "lucide:check"
final: true
resources:
Ticket:
permissions:
create: [admin]
read: [admin]
update: [admin]
delete: [admin]
object:
id: { type: uuid, primaryKey: true }
title: { type: string, required: true }
status: { type: string, enum: TicketStatus, default: pending }
named: { type: string, enumRef: TicketStatus }
inline: { type: string, enum: [pending, review, delivered] }
expanded: { $ref: "#/enums/TicketStatus" }
The example includes its root, domain name, and domain version and is directly
runnable. The strict adapter and CLI accept it without warnings.
adl-ref accepts it but warns that enumRef is an unknown field key, despite
binding that field correctly. An additional adapter case accepts the same
declarations with adl: "0.5.1".
Observed output for this model is preserved in the generated enum catalog:
| Surface | Checked output |
|---|---|
| Named enum schema | String enum array in declaration order |
| Named field schema | $ref to #/components/schemas/EnumdemoTicketStatus |
| Inline/directive field schema | Inline string enum array; no rich metadata link |
| Labels and descriptions in OpenAPI | x-enum-descriptions; label wins when both are authored |
| Colors and icons in OpenAPI | x-enum-colors and x-enum-icons keyed by member name |
final in enum schema | No emitted final-member extension in this helper |
| Domain introspection | Authored member metadata retained, including icon and final |
| Ordinary row responses | Stored strings or nulls; no automatic replacement with labels |
The helper emits no x-enum-labels in this example. The bare review member
has no synthesized label extension. Named optional fields also expose a schema
gap: their bare $ref points to a non-null string enum although direct
validation accepts null; inline fields explicitly include null in their type.
These are observed outputs and parity limits, not an independent specification
of all OpenAPI extensions or nullable-reference encoding.
Introspection retains domain-level metadata from resolved source and the authored named bindings. It need not copy rich metadata beside each field in the response. An older model-projection code path is not sufficient evidence of what the active schema action returns; the adapter invokes that action.
The independent modeller now retains color, icon, and final as well as label
and description. The legacy error record saying it models only two keys is
historical. Its continuing enumRef warning and acceptance of retired named
list forms remain distinct current limitations.
11.11 Evolution and retired forms
An enum change can affect clients and existing data even when no SQL column changes. Review the kind of change before choosing a domain version and migration; ADL 6 owns version identity, and ADL 17 owns schema evolution.
| Change | Consequence to review |
|---|---|
| Change label, description, color, icon, or final metadata | Stored names stay the same; clients and document digests can change |
| Reorder members | Semantic order and both checked digests change |
| Add a member | Accepted set expands; older clients may not recognize it |
| Remove a member | Existing rows and defaults may become invalid; independent inline lists remain separate |
| Rename a member key | Existing strings are not automatically renamed; data and consumers need a transition |
| Rename a named enum | Update bindings and schema consumers; member strings need not change |
The checked removal sequence creates a row with delivered, submits domain
version 1.1.0 without that member, and receives 201 with zero DDL statements.
A get still returns delivered. A title-only update succeeds and preserves it;
an update explicitly resending delivered returns 422 enum_violation against
the new set. Successful declaration upgrade is therefore not evidence of a
complete data migration or whole-row revalidation.
For old named list forms, replace the list with an ordered mapping and retain
each member body. The complete list rejection
produces ENUM_FORM_RETIRED with a suggested bare mapping in the parser
message. Lists of metadata objects also reject, but their suggestion contains
{ ... } placeholders; it is not a metadata-preserving automatic conversion.
reject-body.yaml demonstrates the
separate non-mapping member-body rejection.
Both negative files cause production CLI exit 1 with diagnostic wrapper E000
and the enum-specific message. adl-ref exits 0 for both, with its enumRef
warning. Modeller success is therefore insufficient evidence of v0.5.0/v0.5.1
enum-form admission. The stale type: enum example in Draft 05 §9 likewise
does not override the closed type inventory and field-binding grammar.
11.12 Verification and publication boundary
The evidence record contains 61 production adapter cases, including four disposable SQLite action sequences; eight CLI/modeller commands; eight independent modeller model observations; and 13 passing focused existing Release tests. The example instructions describe reproduction.
Source inspection uses 120debea; the existing library requires the older
2cae30f6 parser/model headers. Their identities and the library, CLI, and test
hashes are recorded separately. No fresh production HEAD build is asserted.
The source register records
25 reviewed files while the shared checkout continues to evolve.
Unknown enum names, invalid defaults, incomplete nested constraints, contradictory bindings, malformed declarations, and schema/order differences remain explicit findings. No runtime fix is included in this documentation. These checks do not establish full PUT behavior, locale negotiation, client rendering, PostgreSQL execution, or every migration path. Draft 1 supplies the chapter and its evidence; publication still requires review of those boundaries.