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 default/named scopes and interaction with row authority. 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 16-scopes.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.
16.1 Scope and authority
A scope gives a resource filter a name. A caller selects that name with
?scope=published rather than repeating the filter on each collection query.
The filter selects rows; it does not create an index, grant access, or change
the fields returned.
The converted ADL 16 body (v0.5.0, retired)
supplies the inherited declaration and permission boundary. This draft retains
its six original section subjects, then adds composition, diagnostics, and
complete evidence. It corrects inherited implementation reports: the checked
host binds :currentUserId, checks SQL fragment structure, and applies scopes
to count and distinct. These observations do not ratify new language rules
or turn a reproduced defect into a supported authoring pattern.
Source inspection is pinned to c8cd9d7c. Execution uses the existing Linux
Release artifacts and compatible dcb5fa10 headers, independently identified
in the evidence record. Only the documentation adapter
was compiled. The results are not a production rebuild of that source revision
or a declaration of complete release-cut conformance.
ADL 21 owns permissions, ADL 27 owns ad-hoc query parameters, and ADL 29 owns feature switches. ADL 18 owns AEL, a different expression language. Store-specific SQL and deployment belong to the platform companion’s KD 7. ADL 15 explains indexes that may support these queries.
16.2 Declare a named filter
Place scopes inside the resource. Its full form is a mapping from scope names
to definitions. This fragment comes from articles.yaml:
scopes:
published:
filter: "(status = 'published' AND deletedAt IS NULL)"
default: true
description: Published articles that have not been deleted.
mine:
filter: "(ownerId = :currentUserId AND deletedAt IS NULL)"
all:
filter: ''
| Key | Form and default | Meaning |
|---|---|---|
filter | SQL predicate string; use "" for an explicitly unfiltered scope | Predicate used when this scope is selected |
default | Boolean; omitted means false | Select this scope when the request does not name one |
description | Optional explanatory text | Authored metadata; retention differs by surface (§16.7) |
Declare at most one default. This inherited requirement remains in force even though the checked production parser admits multiple defaults. With none, there is no custom default filter. With a default whose filter is empty, the default itself contributes no restriction. Selecting another scope replaces the default; it does not conjoin every scope declared on the resource.
The production parser also accepts a shorthand string such as
published: "status = 'published'" and treats filter: null as empty.
The full form with an explicit string avoids ambiguity and the modeller’s
shorthand rejection. Missing or wrongly typed filters are admission gaps,
not alternative ways to spell a valid predicate (§16.8).
The filter is SQL, not AEL. Write SQL equality, AND, OR, and IS NULL;
do not infer AEL null or function semantics from a trait example elsewhere.
SQL functions remain store-specific: SQLite date('now', '-30 days') does
not establish a PostgreSQL contract.
For the checked host, “inserted verbatim and never validated” is incomplete:
- Before model construction, a structural scan rejects oversized fragments,
statement separators, SQL comments, unbalanced single/double quotes or
parentheses, a leading
AND/OR/WHERE, and selected SQL keywords. - On
list,count, anddistinct, recognized ADL field identifiers are qualified for the store, and:currentUserIdis bound as a value. - Remaining SQL syntax, identifier existence, database functions, and query
meaning are not fully validated at admission.
status =and a nonexistent column both pass parsing and fail when queried.
The scanner’s limit is 512 bytes, despite a diagnostic saying “characters.”
A 512-byte ASCII predicate passes; a shorter Unicode string exceeding 512
UTF-8 bytes fails. Quoted literal text such as 'pending; DELETE -- review'
is data and passes the scan. SELECT in a correlated EXISTS expression is
permitted; this does not certify its database semantics.
These filters are trusted document SQL. Do not construct them by interpolating request values. The structural scan is not a SQL sanitizer or an authorization mechanism. Parser, fragment checker, query handling
16.3 Scopes supplied for soft deletion
For features.softDelete: true, the runtime supplies these names individually:
| Name | Predicate supplied when that name is absent |
|---|---|
active | deletedAt IS NULL |
deleted | deletedAt IS NOT NULL |
all | Empty predicate |
A declaration using one of these names replaces that name’s supplied filter;
the other names remain available. In the checked override example,
active: {filter: "status = 'draft'"} returns drafts, while deleted still
returns the tombstoned row. Do not infer a built-in meaning after overriding
a name. On a resource without soft deletion, declare any such name you need.
Availability of a name and selection of a default are separate. With no
declared scopes, the parser supplies active as the default. With any custom
scope present, the action generator adds the missing built-in names but does
not mark the added active scope as default. Consequently:
| Checked declaration | Unscoped list result |
|---|---|
| Soft deletion, no declared scopes | Active rows |
Soft deletion plus published, no default | All rows, including deleted rows |
Explicit default published containing deletedAt IS NULL | Active published rows |
The second row is a visibility limitation, not suppression of the three
runtime names. A custom scope also receives no automatic soft-delete
conjunction on the list family. status = 'published' alone includes deleted
published rows. If that is not intended, put deletedAt IS NULL inside the
scope’s own predicate and choose the intended default explicitly.
Parser,
action context construction
16.4 Select a scope and bind the caller
Select one declared or runtime-supplied name, for example ?scope=published.
There is no scope-parameter declaration mechanism here, and a comma-separated
list is not a request to combine scopes. Use the exact name.
For an otherwise authorized, well-formed collection request, an unknown
nonempty name returns 422 VALIDATION_ERROR on list, count, and
distinct. It must not silently widen the query or fall back to the default.
The checked mnie typo takes that rejection path.
Two checked input gaps limit that guarantee. An unknown empty name (scope="")
returns all rows instead of rejecting. A non-string scope in an internal
action request is ignored and the default applies. These are diagnostic
examples, not valid selectors. HTTP query decoding was not exercised in this
verification, so the non-string case makes no claim about an HTTP encoder.
On the list family, :currentUserId binds the request’s canonical user ID.
It is not a declared field, an AEL call, or a value substituted by the client.
Repeated occurrences receive repeated bindings; text inside a SQL string
literal is left literal. Alice’s mine query selects Alice’s rows, and Bob’s
selects Bob’s. A caller ID containing SQL quote/comment text selects no rows
in the checked fixture; it does not become SQL structure.
An anonymous request binds the empty string. This is not guaranteed to match
nothing: the checked row with ownerId: "" matches it. If authentication
or ownership is required, impose that through permissions and data rules.
Other placeholder names have no general binding contract. In the checked
SQLite case, ownerId = :otherUser is admitted and returns an empty result;
it does not necessarily fail with a database error.
The old ${STORE:…} notation is not store branching. It can be consumed by
the ordinary environment-substitution stage owned by
ADL 4.
With STORE explicitly absent from the probe environment,
${STORE:sqlite} = 'sqlite' becomes sqlite = 'sqlite' and later fails
as a query. Do not rely on the inherited claim that the original placeholder
text always reaches the database unchanged.
Substitution,
selection and binding
16.5 Which operations apply a scope
These are the checked action-level results. Each operation still has its permission and feature requirements.
| Operation | Scope behavior at this execution boundary |
|---|---|
list | Named scope, otherwise default; combines with ordinary filters |
count | Same scope selection and filter combination as list |
distinct | Same scope selection; separate permission limitation in §16.6 |
get | No custom/default scope; soft-delete guard unless selector is deleted or all |
export | Default scope plus soft-delete guard; ignores named scope and request filters; does not use list-family binding |
update | No default/custom scope restriction on the target row |
delete | No default/custom scope restriction on the target row |
The fixture’s default published lists rows 1 and 4. get still fetches draft
row 2, including with scope=published or an unknown name. Without a visibility
override, get hides deleted row 3 with 404 NOT_FOUND. scope=all admits it.
On get, scope=deleted merely disables that guard: it also fetches an active
row and does not mean “deleted rows only.”
A scope is therefore a convenience for the rows a caller asks for, not a
security boundary: a caller may name another scope, and get ignores scopes.
To keep rows from a caller, declare permissions.readCondition
(ADL 21 §21.7.2, #1527).
It applies to get, list, count and distinct under every scope, and get
answers 404 for a row it excludes.
An ordinary update changes draft row 2 even though the default scope excludes
it; delete reaches that row too. Passing scope as an update body field
instead returns 422 UNKNOWN_FIELDS in the checked strict action request.
That rejection is field validation, not enforcement of a scope predicate.
Export has two further limits. A default containing :currentUserId returns
200 with zero CSV rows in the SQLite fixture, because export never binds it.
A default with an unknown column or invalid SQL also returns 200 with zero rows,
even though the recorded store reports a failed read. The corresponding
list/count/distinct requests return 500 DB_ERROR. Do not interpret an
empty export as proof that a scoped query succeeded.
This table corrects the inherited “no custom scope on count/distinct” row. It does not promise identical scope behavior for every operation. List family, get, export, update, delete
16.6 A scope is not a permission
A scope shapes a query the caller is allowed to make. Permissions impose
access conditions independently. An unauthorized reader selecting all
still receives 403 FORBIDDEN on list, count, distinct, get, and export
in the role-denial fixture. An allowed administrator can use those scopes.
A scope cannot make a row unreachable through an operation that does not
apply its filter.
Two reproduced runtime defects require more precise guidance than that conceptual distinction alone.
Group compound predicates. The checked list-family merger does not wrap
the scope in parentheses before adding other predicates. With the scope
status = 'published' OR status = 'draft' and an additional ownerId=bob
filter, the result includes Alice’s published rows. SQL applies the additional
filter to only the latter branch. Parenthesizing the entire scope produces the
intended Bob-only rows in list, count, and distinct.
The same omission affects permission-imposed ownership on list/count: an owner-only caller using that ungrouped scope sees other owners’ draft rows. The grouped control preserves ownership. This is an enforcement defect, not authorization granted by a scope. Use explicit outer parentheses around compound scope predicates; permission tests must still cover the resulting queries.
Keep identity-dependent scopes out of the checked list cache.
With features.caching: true and a role permitted to read generally, Alice’s
mine list is cached under the request data alone. Bob’s identical request
receives Alice’s cached row; Bob’s count independently returns the correct two
rows. Disabling this cache avoids that reproduced path. The owner-permission
fallback bypasses list caching and the checked Alice/Bob control stays separate;
that does not establish safety for every permission/cache combination.
There is also a coverage difference: an owner-only permission can constrain list and count, but distinct lacks that ownership fallback and returns 403. This is narrower behavior, not permission parity across the three operations. Permission and filter handling, cache construction
16.7 Composition, metadata, and identity
Scopes can be supplied by traits. The checked
trait-scopes.yaml retains
review from OwnedView, while the resource’s explicit mine definition
replaces the same-named trait scope as a whole. Later-trait precedence and
explicit overrides belong to
ADL 13.
Do not assume that a default flag omitted by a replacement survives from
the earlier definition. Domain derivation and protected override rules remain
in ADL 14.
The native scope model retains name, filter, default, and origin. Both checked
registry reloads preserve those values, including trait:OwnedView.
That is an in-process model reload, not a complete host restart test.
Metadata has multiple representations:
| Surface checked | Scope information |
|---|---|
| Resolved document and submitted domain schema | Custom names, authored description, filter, explicit default |
Native ScopeDefinition and native-model export/snapshot | Name, filter and default; description is absent |
| Native registry reload | Same modeled scope values and persisted origin |
| Python modeller | Description retained; production traits and supplied runtime scopes are not expanded |
| Offline OpenAPI from the adapter | No scope parameter in the emitted paths |
The inspected live endpoint-schema populator separately emits an
active/deleted/all enum and active default for soft-delete resources.
That source-only projection omits custom names and can contradict the custom
default behavior in §16.3. It was not an executed HTTP schema assertion.
The submitted domain schema, offline OpenAPI, and endpoint parameter schema
are distinct outputs; the inherited blanket “not stored, not exposed” claim
cannot describe all of them.
Reordering a valid scope mapping leaves the checked resolved digest unchanged. Changing a filter, default, or description changes it—even though native scope objects omit descriptions. Multiple defaults remain invalid; their preserved input order is not a legitimate priority system. The implementation selects the first modeled default, and reversed invalid mappings can share a digest while changing model order.
A checked scope-only domain update from 1.0.0 to 1.0.1 changes the
active default query from published rows to drafts without replacing stored
rows. Follow ADL 6 for
version/reapplication rules and ADL 17
for evolution. This observation does not guarantee cache eviction or full
restart behavior on every update.
Trait resolver,
registry,
model exporter,
endpoint schema
16.8 Admission and modeller diagnostics
Use full string-valued predicates and Boolean defaults. The following deliberate cases explain why parser acceptance alone is insufficient:
| Input or operation | Checked production consequence |
|---|---|
| Statement separator, comment, unbalanced delimiter, denied keyword, oversized predicate | Parse rejection with a resource/scope path and reason |
default: "false" | Generic JSON Boolean-type exception, not a structured scope diagnostic |
| Missing filter, numeric filter, numeric definition | Accepted as an empty predicate |
Non-mapping scopes | Ignored; soft-delete generation can then apply |
Multiple default: true definitions | Admitted; first modeled default selected |
| Empty scope name | Admitted |
Unsupported parameters in a definition | Omitted from the native model |
| Unknown column or incomplete SQL | Admitted, then list-family 500 DB_ERROR |
| Nonempty unknown selector | List-family 422 VALIDATION_ERROR |
| Empty unknown selector | No scope restriction; documented defect |
The structural parser failure is a message returned by the adapter and a nonzero CLI validation result; this chapter does not invent a stable scope error code for that path. ADL 31 owns diagnostic envelopes.
The independent Python modeller is useful but differs from production:
SCOPE_MULTIPLE_DEFAULTSandSCOPE_NO_FILTERreject the corresponding definitions; the latter also rejects production’s shorthand form.SCOPE_UNKNOWN_IDENTIFIERis a heuristic warning, not SQL validation.SCOPE_UNIMPLEMENTED_PLACEHOLDERstill warns about working:currentUserIdlist-family binding, even when the text is a quoted literal.SCOPE_SUPPRESSES_SOFT_DELETEhas stale wording about suppressing supplied scopes. Its warning can highlight the missing-default problem, but the runtime still supplies the three names individually.- The deliberately invalid statement-separator file exits 0 in the modeller with warnings, while the production CLI rejects it.
- A numeric filter raises a modeller exception. A string
default: "false"is coerced totrueinstead of matching production’s type exception.
These comparisons cover declarations, not a modeller execution of SQL. Modeller construction, scope model, complete observations
16.9 Complete example and verification
The complete baseline below uses adl: "0.5.0" for inherited scope grammar,
a language declaration accepted for this edition. Domain version is a separate
string. The trait fixture uses adl: "0.5.1". Broad permissions in this
illustrative baseline make scope behavior visible; §16.6 supplies the separate
authorization tests.
adl: "0.5.0"
domain:
name: publishing
version: "1.0.0"
resources:
Article:
object:
id:
type: integer
primaryKey: true
title:
type: string
status:
type: string
ownerId:
type: string
createdAt:
type: datetime
permissions:
create:
- '*'
read:
- '*'
update:
- '*'
delete:
- '*'
features:
softDelete: true
export: true
scopes:
published:
filter: (status = 'published' AND deletedAt IS NULL)
default: true
description: Published articles that have not been deleted.
mine:
filter: (ownerId = :currentUserId AND deletedAt IS NULL)
all:
filter: ''
The disposable seed includes active published rows 1 and 4, draft rows 2 and 5, and deleted published row 3. Alice owns rows 1 and 3, Bob owns 2 and 4, and row 5 has an empty owner ID.
| Baseline request, Alice | List IDs | Count | Distinct status |
|---|---|---|---|
| No scope | 1, 4 | 2 | published |
scope=mine | 1 | 1 | published |
scope=all | 1, 2, 3, 4, 5 | 5 | draft, published |
scope=mnie | 422 | 422 | 422 |
Examples and commands reproduce 60 adapter cases and 159 assertions, including 21 disposable-store sequences, 39 production/modeller declaration comparisons, two registry reloads, six complete YAML inputs, and twelve CLI/modeller commands. 21 focused Release tests pass. Assertions that reproduce a defect are labeled as such; passing them is not a claim that the host conforms.
The evidence record and verification JSON identify reviewed sources, binary hashes, inputs, outputs, and limitations. No HTTP transport, PostgreSQL server, timing benchmark, or production rebuild was exercised. The baseline manual audit records 51 pre-existing broken links after archival/tool moves; ADL 16’s new links are checked separately from that debt.