ADL 0.6.0 reference · Review draft 1 · November 14, 2026.
Contents · Source map · Evidence
The 0.6 edition note
This chapter retains the detailed language contract and its source-specific observations. Its chapter number and numbered sections remain stable. The 0.6 additions do not by themselves change this subject’s defaults or supply fresh execution evidence for it.
Reverification should cover DDL generation, uniqueness failures, and adapter-specific index behavior. Use the original examples and evidence links below to recover the earlier test context. The new edition’s source map records this chapter as inherited detail; the current draft does not claim those historical tests were rerun.
Retained reference detail
The numbered sections below are carried from 15-indexes.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.
15.1 Scope and authority
An index declares an access structure over a resource’s stored columns. A non-unique index can change how a query is executed. A unique index additionally constrains which combinations of values may be stored. Neither creates a new ADL route or grants permission to use one.
The converted ADL 15 body (v0.5.0, retired) supplies the inherited declaration contract. Draft 05 §21.4 explicitly preserves the order of index field lists. This draft corrects three inherited claims against identified evidence: indexes are not all performance-only, descriptions are retained at some surfaces, and foreign-key indexes are not universally generated. It also separates migration preview, submitted changes, and physical storage results instead of repeating the old recommendation that renaming alone changes an index.
Source inspection uses 6a6666ed. Execution uses the existing Release artifacts
and compatible dcb5fa10 headers, not a freshly rebuilt production host at that
source revision. The evidence record identifies the
methods and limitations: 52 adapter cases, 82 checks, independent modeller
comparisons, and 30 passing focused tests. Known defects remain observations;
they do not amend the language contract.
ADL 10 owns fields, types, required values, and field-level uniqueness; ADL 12 owns keys and relationships; ADL 13 owns trait composition; ADL 14 owns storage mappings; and ADL 17 owns schema evolution. Database operations and recovery belong to the platform companion, especially KD 7 and KD 16. Indexes do not determine which filters or sorts are legal; those contracts belong to ADL 27.
15.2 Declare resource indexes
Place indexes inside a resource definition. The preferred full form is a
sequence of mappings:
indexes:
- name: by_status_created
fields:
- status
- createdAt
description: Find recent orders with a given status.
- fields:
- tenantId
- orderNo
unique: true
This fragment comes from the complete orders.yaml.
It declares a query index on status/createdAt and a unique tuple tenantId/orderNo.
The complete example includes the fields, permissions, and Customer relationship:
adl: "0.5.0"
domain:
name: sales
version: "1.0.0"
resources:
Customer:
object:
id:
type: integer
primaryKey: true
autoIncrement: true
email:
type: string
unique: true
permissions: &id001
create:
- '*'
read:
- '*'
update:
- '*'
delete:
- '*'
Order:
object:
id:
type: integer
primaryKey: true
autoIncrement: true
tenantId:
type: string
required: true
orderNo:
type: integer
required: true
status:
type: string
required: true
createdAt:
type: datetime
permissions: *id001
relationships:
customer:
type: belongsTo
target: Customer
indexes:
- name: by_status_created
fields:
- status
- createdAt
description: Find recent orders with a given status.
- fields:
- tenantId
- orderNo
unique: true
Ordinary indexes are inherited functionality, so these baseline files use
adl: "0.5.0", a language declaration accepted for this edition. The separate
trait example uses adl: "0.5.1". Domain version and language version have
different purposes; see ADL 6.
| Key | Value and default | Meaning |
|---|---|---|
fields | Nonempty ordered list of field-name strings | Columns of the index, in the declared order |
name | Optional string; generated when omitted | Requested physical index name |
unique | Optional Boolean, default false | Require uniqueness of the complete indexed tuple |
description | Optional string, default empty | Author explanation; does not change the SQL index definition |
The parser also accepts a string entry such as - status and a mapping
- {field: status} for a single field. When both fields and field are
provided, the checked array-valued fields takes precedence. Prefer the full
form when supplying metadata or multiple fields.
The production model retains a string description, a normal registry reload retains it, and the checked domain schema returns it. That supersedes the converted body’s blanket “accepted and discarded” statement. Retention is surface-specific: the inspected model exporter omits descriptions, as does the Python modeller’s index model. A YAML comment is not equivalent to modeled metadata. Parser, exporter, modeller
Use actual stored field names. ADL does not provide index expressions, partial
predicates, or per-column sort directions through this declaration. Writing
where, order, or a custom method does not establish those features; the
production parser’s acceptance gaps are detailed in §15.8.
15.3 Unique and composite indexes
fields: [tenantId, orderNo] with unique: true restricts the combination.
It does not require tenantId or orderNo to be individually unique. The checked
create sequence accepts (A, 1) and (B, 1), then rejects another (A, 1) with
409 DUPLICATE. The response does not identify every member of the conflicting
tuple. These are existing-artifact generated-action results, not a replacement
for the edition’s complete error contract.
This differs materially from a query-only index: adding uniqueness can reject writes that were previously accepted. It can also fail when applied to existing duplicate data. Declaring both fields required in the baseline example prevents missing values from bypassing its intended business key.
In a variant where orderNo is optional, the checked SQLite store accepts two rows with tenantId A and a null orderNo. Uniqueness does not imply requiredness. This records the tested store behavior; it does not establish identical null, collation, or concurrency behavior across every supported database. String case-folding and null-equality options are not index declaration keys here.
A field’s unique: true and a one-field unique index can both impose a storage
restriction, but they are not interchangeable metadata at every surface. The
former is a field constraint; the latter is an index definition. Their generated
names, migration handling, and error paths can differ. ADL 10 remains the owner
of field-level validation and required/null semantics.
15.4 Preserve column order and examine query plans
Index field order is semantic under Draft 05 §21.4. Preserve
[status, createdAt] as written; do not sort it into [createdAt, status]
when serializing, hashing, comparing, or deriving a model. The two checked
fixtures produce different resolved digests and different physical column order.
An equality on status followed by a range on createdAt gives a concrete reason to compare those two orders. Three temporary stores contain the same 2,000 seeded rows. They execute this SQL query to inspect the physical access path:
SELECT id, status, createdAt
FROM sales_orders
WHERE status = 'open' AND createdAt > '2026-09-10T00:00:00Z'
ORDER BY createdAt, id
LIMIT 5;
| Index layout | Recorded SQLite plan |
|---|---|
[status, createdAt] | Covering-index search on status=? AND createdAt>? |
[createdAt, status] | Covering-index search on createdAt>?; temporary sorting for part of the requested order |
| No declared indexes | Table scan and temporary sorting |
All three return the same five rows in the requested order. This is a query-plan comparison, not a timing benchmark. Data distribution, database statistics, and query shape affect the planner’s choices; the declaration does not guarantee that an index will be selected. The inherited claim that an index “does not serve” a non-leading-column query is too absolute. Use the plan for the actual query rather than treating a general prefix heuristic as a language prohibition.
An index does not specify result ordering. The query above requests ordering explicitly, including id to resolve ties. Likewise, the existence of an index does not itself permit a filter, authorize data access, or validate sort syntax.
The checked canonicalizer also changes the digest when the outer index list is reversed without changing any index. Draft 05’s exhaustive ordered set names index field lists, not index declaration lists. That wider order sensitivity requires reconciliation; it must not be inferred as a new language requirement. ADL 9 owns the complete canonicalization contract. Canonicalizer
15.5 Generated storage, names, and automatic constraints
The ordinary DDL generator emits CREATE INDEX IF NOT EXISTS or
CREATE UNIQUE INDEX IF NOT EXISTS. Its unnamed-index formula in the checked
build is idx_<physical-table>_<field1>_<field2>.... The tuple example becomes
idx_sales_orders_tenantId_orderNo. Physical resource naming remains subject to
the version and binding distinctions documented in ADL 12. DDL generator
The generator quotes column identifiers on PostgreSQL and emits bare column
identifiers on SQLite. Custom index and table names are interpolated separately;
a YAML-quoted name is not automatically a valid SQL identifier. The checked
bad-index-name is accepted by the parser and fails when SQLite applies its DDL.
Prefer portable, distinct identifiers and inspect emitted names.
IF NOT EXISTS checks an existing object’s name. It does not verify that an
existing index has the requested fields, uniqueness, or table. In the probes:
- Two different definitions with the same name produce only the first physical index, even though both declarations survive in the model.
- An unnamed non-unique status index followed by an unnamed unique status index collides because the generated name does not include the uniqueness flag.
- Two resources reusing
shared_nameproduce one physical index on Customer; the intended unique Order index is absent. - Two equivalent definitions with different names produce two physical indexes.
These are concrete reasons to treat names as more than documentation. The parser does not consistently reject duplicates, and generated DDL is not a reconciliation procedure for an existing object with the same name.
Some storage constraints arise without resource indexes. The complete example’s
Customer.email field generates a SQLite unique autoindex. Its integer primary
key uses the table’s primary-key mechanism without a separately listed index in
PRAGMA index_list. Do not require every primary key to appear as a distinct
index object in all database inspection results.
A belongsTo foreign key does not automatically receive a query index in the
checked example. Order.customer creates customerId and its foreign-key constraint,
but there is no index on customerId. The linter reports informational
MISSING_FK_INDEX; explicitly adding fields: [customerId] produces one and
removes that message. This corrects the inherited automatic-FK-index claim.
The linter counts every field mentioned by an index, so its silence is not a
proof of optimal leading-column order. Index linter
Feature-generated spatial/full-text and side-table indexes have their own
contracts and providers. They are not additional ordinary indexes keys;
ADL 42 owns spatial declarations.
15.6 Composition and mapping boundaries
Traits can contribute indexes. In trait-index.yaml,
Searchable supplies a status index with origin: trait:Searchable; the resource’s
two explicit indexes follow it. ADL 13 owns contribution order and precedence.
Domain derivation’s append.indexes and named add/replace forms belong to
ADL 14. None of these mechanisms removes the need to inspect physical names
and duplicate definitions.
Resource subtyping exposes two current DDL gaps. An inherited unnamed index on
a joined base field is also emitted against the subtype’s physical table, where
that column is absent; the checked application fails with no such column: name.
An explicitly declared unique index on a subtype’s own column produces a real
CREATE UNIQUE INDEX, whereas ADL 14’s Draft 05 §9.2 contract describes
application-level joined uniqueness. Do not silently equate this behavior with
the distinct unique: true field write-trigger implementation.
Foreign mapping skips creation of the externally owned resource table, but the
ordinary custom-index loop still emits against the domain-derived table name.
The checked foreign case fails with no such table: main.sales_legacies even
though its declared backing table is external_orders. Parser acceptance does
not establish correct index ownership or placement on a foreign mapping.
These are implementation limitations, not permission to create or migrate an
externally owned table. DDL generator
15.7 Index evolution and migration failures
A changed declaration, a generated plan, and an applied physical index are
separate facts. Follow the domain-version requirements in ADL 6 and the complete
migration contract in ADL 17; the examples use a patch-version increase. The
allow_destructive flag below belongs to a management request, not ADL YAML.
There are two relevant comparisons in the inspected host:
- The submission’s
diff_modelscomparison omits index changes. An index-only update can take the no-structural-change reapply path, update the stored model, and execute no SQL. SchemaDiffer, used by preview and migration generation, compares ordered field lists plus uniqueness. It does not use name or description as identity.
Submission path, model comparison, schema differ
The checked results are:
| Change and execution path | Observed result |
|---|---|
| Rename only | Preview has no structural change; submission returns 201 with zero DDL and leaves old_index |
| Change fields/order or uniqueness only | Preview can show index SQL; index-only submission still reapplies with zero DDL |
| Remove indexes only, then submit again with the flag | Stored declaration changes; the old physical indexes remain through both submissions |
| Add a unique index only over duplicate rows | Submission returns 201 with zero DDL; the required physical index remains absent |
| Add a resource during migration with its own unique index | Resource table is created; its declared index is omitted and duplicate create operations succeed |
The old instruction “rename the index to change it” is therefore insufficient. A successful response or new schema description does not prove an index exists. The new-resource gap has a separate cause: the migration generator calls the single-resource table generator and does not emit that resource’s custom indexes. Migration generator
The adapter also introduces a real field delta alongside an index change to
observe the migration path after the submission shortcut is bypassed. These are
diagnostic fixtures, not a recommendation to add dummy fields as a workaround.
With an unchanged index name and allow_destructive: true, the generated order
is create-if-absent followed by drop: creation does nothing, then the old index
is dropped, leaving no index. Changing both the definition and name in this
mixed change creates the new index and drops the old one successfully.
An index removal without the flag produces a warning and defers the drop. The
plan nevertheless reports destructive: false and zero deferred destructive
operations. Inspect the SQL and warnings; that flag is not reliable evidence
that an index change will be harmless or applied. Migration ordering and the
required decision to remove a physical index need explicit review.
For duplicate-data failure, the checked mixed change first adds a memo column,
then attempts a new unique tuple index over two existing (A, 1) rows. Preview
reports no data errors. Execution returns 500 MIGRATION_ERROR at index
creation. The SQLite transaction rolls back the memo column as well as the
failed index, and both original rows remain. The registry retains version 1.0.0
but changes the domain status to failed.
This supersedes the legacy error record (v0.3.1, retired) for the tested SQLite SQL rollback path. It does not claim that every store rolls back identically or that all runtime/lifecycle state is restored. Recovery of the failed domain belongs to the migration and operations documentation. Migration executor
15.8 Admission, tooling, and verification limits
Use declaration validation and physical inspection together. The production parser accepts several incomplete or unsupported inputs; the modeller rejects many of them before storage:
| Input | Existing production result | Python modeller result |
|---|---|---|
| Missing/empty fields, wrong-shaped outer indexes, numeric entry | Produces no index | INDEX_NO_FIELDS, INDEXES_NOT_LIST, or INDEX_NOT_OBJECT |
| Mixed string/numeric fields | Keeps string fields, drops numeric entry | INDEX_FIELD_NOT_STRING |
| Repeated field or explicit name | Accepts | INDEX_DUPLICATE_FIELD or INDEX_DUPLICATE_NAME |
| Unknown field | Parses; SQLite DDL fails | INDEX_UNKNOWN_FIELD |
where / order | Accepted source key, ignored by modeled index/DDL | INDEX_UNSUPPORTED_KEY |
| Other unknown index key | Accepted source key, ignored by modeled index/DDL | INDEX_UNKNOWN_KEY |
String unique: "true" | Generic JSON type exception | INDEX_UNIQUE_NOT_BOOL |
| Numeric name | Falls back to generated name | INDEX_NAME_NOT_STRING |
These are recorded diagnostics at specific layers, not newly ratified ADL error
codes. invalid-field.yaml is a
deliberately invalid index definition even though production CLI validation
returns success. Its SQLite DDL application fails and the modeller rejects it.
A CLI parse success does not demonstrate that a submitted domain will install.
The modeller’s accepted baseline has warnings for the production autoIncrement
field option. Its trait example also warns about unsupported trait keys and
retains only the two explicit indexes; that successful command exit is not trait
expansion evidence. It treats a synthesized customerId as unknown when it is
named in an index without an explicit field declaration. Model descriptions and
runtime column synthesis are distinct compatibility boundaries.
A schema view shows a declaration, which may have diverged from physical storage through the migration gaps above. The inspected storage verifier checks unique fields by collecting columns present in unique indexes; it is not a full comparison of every custom index name, tuple, order, or definition. Use the retained DDL and database index metadata to assess those facts. PostgreSQL SQL in this chapter was generated only; no PostgreSQL execution or benchmarking is claimed.
15.9 Evidence and author review
The evidence record and verification JSON retain all 52 inputs/results, 82 classified checks, three query-plan comparisons, generated SQL/OpenAPI, registry reload, modeller diagnostics, and 30 focused test results. The source register records 29 reviewed source files with Git revisions and hashes.
For an index change, review the intended tuple and nullability, field order for the actual query, physical name and ownership, current data, generated plan, and resulting database definition. Confirm uniqueness through an attempted conflicting write where that restriction matters. Preserve the difference between a declared constraint and its verified enforcement.
This is author guidance, not an additional deployment procedure. The chapter records both supported paths and current gaps so an author can identify which claims still need verification on the intended host and store.