ADL 27 · Part IV — Generated interfaces

0.5.1 baseline + 0.6 edition note

Query parameters

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 filter/sort/expand parsing, row authority, and pagination. 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 27-query-parameters.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.

27.1 Request grammar and operation coverage

Query parameters refine a generated read operation. They do not bypass resource permissions, and they are not applied uniformly to every endpoint. This chapter revises the inherited query reference (v0.5.0, retired) against the query builder, list/count/distinct handlers, and get handler at 31e59154.

For an HTTP request without a body, the REST adapter expands bracket notation into nested request data:

?filter[priority][gte]=2&sort=-priority&limit=10

The corresponding kernel request data is:

{"filter":{"priority":{"gte":"2"}},"sort":"-priority","limit":"10"}

The chapter’s executable queries supply this request data directly to generated actions. They verify the action semantics. The HTTP adapter’s bracket expansion is source-inspected, not exercised through a network listener. That adapter merges query parameters only when the HTTP body is empty; body-bearing requests must not assume the same query merge.

ParameterListCountDistinctGet
filter, searchAppliedAppliedAppliedNot the item selector
sortOrders resultsParsed; no ordering effectParsed; output ordered by selected fieldNo effect
limit, offset, page, cursorPaginationParsed; no result limitParsed; no result limitNo effect
scopeNamed/default filterNamed/default filterNamed/default filterOnly special soft-delete visibility handling
fieldsSparse selectNo effectUse singular field insteadResponse field handling; see §27.4
includeRelationship loadingNo effectNo effectRelationship loading

A cursor produces a WHERE predicate, so passing it to count/distinct can still narrow those operations even though their LIMIT clauses are not used. Supplying malformed pagination or an unknown sort to count/distinct can also fail strict query validation. Avoid irrelevant parameters.

27.2.1 Filter operators

Use the filter object, or its HTTP bracket notation. A scalar value means eq. An operator mapping permits multiple predicates on one field.

OperatorMeaningExample request data
eq, ne (neq, not)Equal, unequal{"filter":{"status":{"ne":"draft"}}}
gt, gteGreater than, at least{"filter":{"priority":{"gte":2}}}
lt, lteLess than, at most{"filter":{"priority":{"lt":3}}}
like, not_like (nlike)SQL LIKE / NOT LIKE pattern{"filter":{"title":{"like":"Alpha%"}}}
in, not_in (nin)Membership / non-membership{"filter":{"id":{"in":["e1","e3"]}}}
ieq, not_ieq (nieq)Case-insensitive equality / inequality{"filter":{"email":{"ieq":"A@B.com"}}}

in and not_in also accept a comma-delimited scalar such as e1,e3. Top-level predicates are joined with AND. The checked range priority >= 2 AND priority < 3 returns only e2. SQL values are bound separately from field identifiers.

Boolean combinators (or, and, not / exclude) and relationship paths (#1549).

  • filter[or][0][status]=draft&filter[or][1][status]=archived (or a JSON array in filter.or) joins branches with OR. Multi-field branches inside an indexed or[i] object are joined with AND.
  • filter[not][status]=archived, filter[exclude][title][like]=%spam%, or filter[title][not][like]=%spam% wraps the inner predicate in NOT (...).
  • Dotted belongsTo relationship paths (filter[question.pubDate][gte]=2026-01-01T00:00:00Z or filter[question][pubDate][gte]=..., up to 4 hops) compile to a parameterized EXISTS (SELECT 1 FROM ...) subquery that enforces the target resource’s own list permission, owner scope, default scope, readCondition, and field readability (403 FIELD_NOT_READABLE).

ieq was added in ADL plugin 0.80.0 (2026-09-21). It compares LOWER(CAST(field AS TEXT)) against LOWER(?), so the value is bound as a parameter and pattern characters are literal — it is case-insensitive equality, not a like (query_builder.cpp).

Two current edge cases need explicit treatment. An unknown operator such as gteTypo silently becomes equality, including in strict mode. An empty in array contributes no predicate and therefore does not mean “match nothing.”

Correction. Through 2026-09-22 the table above omitted ieq, which made the unknown-operator rule actively misleading: an author who read the table, concluded ieq was unknown and expected case-sensitive equality would get the opposite of what they intended. The live empty-array control returns all three records. These are implementation limitations; use recognized operators and handle an empty selection before issuing the request.

Unknown filter fields are rejected in strict mode with 400 INVALID_QUERY. Loose mode drops them. Known fields include the queryable primary keys and stored fields selected by the resource context. Virtual/computed-field read behavior is owned by ADL 19; a field appearing in a response does not alone prove it has a queryable SQL column.

Boolean filter values. A filter on a boolean field accepts true, false, 1 or 0, in any case: filter[sent]=false and filter[sent]=0 select the same rows. The value is bound in the store’s own form, 1/0 on SQLite (where a boolean column is INTEGER) and true/false on PostgreSQL. Any other spelling, such as yes, is refused with 400 INVALID_QUERY rather than silently matching nothing. Before 2026-09-24 false matched no row on SQLite (kalos#1005).

Spatial bbox, intersects, and within filters require geometry fields and PostgreSQL/PostGIS. simplify is likewise a spatial facility, with additional store/type checks. ADL 42 owns their grammar and evidence; this chapter’s SQLite cases do not establish spatial execution.

27.2.2 Sorting

sort=-priority,title sorts by descending priority and then ascending title. A leading + explicitly requests ascending order. Commas separate fields; whitespace around each sort segment is trimmed. The native builder whitelists field names before constructing SQL.

No sort parameter means no guaranteed SQL ordering. The examples use distinct keys and explicit sort where order matters. For pagination, select an ordering that distinguishes records; the current cursor algorithm does not add a stable secondary-key cursor automatically.

A resource answers search= in one of two ways, depending on whether it declares a full-text index.

Declared full-text search (ADL plugin 0.108.0, #1703). A resource-level search block names the indexed fields and one language for the resource:

resources:
  Chunk:
    object: {id: {type: uuid, primaryKey: true}, title: {type: string}, body: {type: text}}
    search:
      fields: [title, body]     # string, text, markdown, email, url or slug fields
      language: english         # optional; default english
  • Index. On SQLite the plugin keeps an external-content FTS5 table, <table>__fts, in step through insert, update and delete triggers. On PostgreSQL it keeps a GIN index over to_tsvector(language, fields). Both are checked at every activation and rebuilt when the search block changes, so existing rows are indexed without a migration.
  • Matching. The term is reduced to word tokens (letters, digits and any non-ASCII character). A row matches when it contains every token. With english, word forms match: search=indexing finds “indexed”. SQLite stems only english (porter tokenizer), while any other language matches whole words. On PostgreSQL the language is any text search configuration, such as simple or german, and its stop words are ignored.
  • Ranking. When search= is given and sort= is not, results come back in relevance order. Each item carries _rank, which is higher for a better match. Ranks compare within one store only: SQLite’s is the negated bm25, PostgreSQL’s is ts_rank. sort=-_rank names the same order and can be combined with other sort fields. A ranked search pages with page or offset, not a cursor.
  • Visibility. Read conditions and record sharing (§21.7.3) filter the matches before pagination, like any other predicate. A declared search field the caller may not read (§27.6) is left out of the match for that caller. If none is readable, the search matches nothing.
  • Limits. The block requires a resource with its own table and a single primary key, so it can’t be used on a subtype, a foreign table or a composite key.

Substring search (every other resource). search=Alpha builds a LIKE scan across the queryable field whitelist. SQLite uses LIKE, and PostgreSQL casts fields to text and uses ILIKE. Percent and underscore keep their LIKE wildcard meaning. The search feature flag doesn’t gate this scan: the same no-match term returns zero items with the flag true and false.

Structured search, either way. ADL plugin 0.80.0 added a structured form, {"value": "Alpha", "fields": ["title", "summary"]}, which searches only the fields the caller names, so a term doesn’t reach unrelated profile or secret fields. It is a substring match on those fields even when the resource declares search. It fails closed rather than falling back:

  • an object that is not exactly value plus a nonempty fields array is rejected with “Structured search requires a string value and nonempty fields array”;
  • a field that is not a string, not queryable, or repeated is rejected with “Invalid structured search field” (query_builder.cpp).

27.3 Pagination and response metadata

The default list pagination uses limit: 100 and offset: 0. The builder clamps limit to 1–1000, negative offset to zero, and page below one to one. A malformed number such as limit=abc produces a strict-mode query error. The current numeric parser nevertheless accepts a numeric prefix: limit=2tail becomes 2. Use complete decimal values; acceptance is not proof of strict lexical validation.

ModeExampleChecked metadata
Offsetoffset=1&limit=1&sort=iditems, count; no totalCount
Pagepage=2&limit=2&sort=iditems, count, totalCount
Cursorcursor=e1&limit=1&sort=iditems, count, plus cursor fields when available

Page mode computes (page - 1) * limit and overrides an offset input. A string cursor then selects cursor mode if also present. Count is the number of items returned in this response, whereas page-mode totalCount counts rows matching the same scope/filter conditions before pagination.

The checked three-row page example returns [e3], count: 1, and totalCount: 3. Its offset counterpart returns [e2] without a total.

A cursor is the last value of the primary sort field, or id if no sort was specified. It is not an encoded multi-column bookmark. Ascending order compares that field with >; descending order uses <. Equal sort values can therefore be skipped at a page boundary even if secondary sort fields were supplied.

For a nonempty page whose last response item retains the cursor field, the handler emits nextCursor and sets hasMore when the number of items reaches the limit. It does not fetch an extra row to prove another page exists. The checked empty terminal page omits both fields, rather than returning hasMore: false. Sparse fields or permissions that remove the cursor field can also prevent those metadata fields from being emitted.

27.4 Projection and includes

27.4.1 Field selection

fields=title on list performs a sparse SQL select and retains the primary key. The checked response items contain only id and title. The handler additionally selects the state field for a stateful resource and needed foreign keys when an include is requested, then applies its response processing. Unknown requested fields return 400 UNKNOWN_FIELD, independently of the filter-field diagnostic.

Get fetches the record before field-security processing; its fields handling is not the same sparse-select implementation. Hidden/requestable, internal, write-only, permission-controlled, and computed fields have their own processing stages. ADL 21 and ADL 19 specify those boundaries. Caching can bypass fresh projection/permission processing; see ADL 29 §29.6.

27.4.2 Local relationships and remote references

include=notes loads a declared local relationship through the relationship loader. The local example creates an Entry and its Note and observes the attached note in the list response. An include naming no relationship of the resource, such as missing, is refused with 400 INVALID_QUERY and the message Unknown relationship: missing, on list and on get, as an unknown filter or sort field is. A dotted name such as note.author is refused the same way: includes are not nested. features.validation: loose keeps the earlier behaviour and ignores the name. A relationship the loader cannot serve is returned as null, never left out, so an included key is always present in a 200. An include is not a promise of a join on an arbitrary response field. Each attached row passes the target resource’s own get permission and field security under the caller, or is null (to-one) or left out (to-many); see ADL 12.10 (#1407).

A field declared with type: reference and a suite-qualified references address is a different model construct. The cross-domain restriction is owned by ADL 12 and the signed rulings. Clients should fetch the referenced resource separately; include does not authorize automatic remote traversal. The checked source and target domains are submitted in one local store. After creating both records, include=person returns the same canonical address string in person; it does not attach the target record. No network or foreign-site access is exercised. The independent modeller rejects this field with UNKNOWN_TYPE for reference, despite successful native submission and writes.

27.5 Scopes, count, and distinct

scope=high chooses a declared scope filter; the resource’s default scope applies when no scope is requested. Explicit scope selection replaces the default and combines the selected predicate with request filters. It does not replace the operation’s permission check or owner restriction.

An unknown named scope returns 422 VALIDATION_ERROR, including in loose mode. The mine example binds :currentUserId and returns the caller’s two records. ADL 16 owns the authored scope language, quoting, and default soft-delete scopes.

Count uses the list permission and returns {"total":2} for the checked high scope. Distinct requires the singular field parameter and returns {"values":["open"],"count":1} for distinct status in that scope. Its values come back as stored strings; do not infer list-style JSON typing.

The three list-family handlers share scope resolution, but their authorization paths are not identical. List and count have an owner-scoping fallback; the current distinct handler requires its record-less list-permission check to succeed. Get recognizes scope=deleted and scope=all to include tombstones; it does not run the general named-scope filter used by list/count/distinct.

Export has a separate handler. It applies its default scope and soft-delete condition, but ignores the checked per-request filter, scope, and format selection. ADL 29 §29.5 explains that operation.

27.6 Diagnostic and visibility boundaries

InputChecked current result
Unknown filter or sort field, strict resource400 INVALID_QUERY
Malformed pagination, strict resource400 INVALID_QUERY
Unknown projected field400 UNKNOWN_FIELD
Unknown named scope422 VALIDATION_ERROR
Distinct without field400 MALFORMED_REQUEST
Distinct on unknown field400 INVALID_FIELD
Distinct on a field the caller may not read403 FIELD_NOT_READABLE
Filter, sort or search on a field the caller may not read403 FIELD_NOT_READABLE
Plain priority=2 or misspelled filtterIgnored; full result set
Unknown filter operatorEquality fallback
Unknown include400 INVALID_QUERY; ignored under validation: loose
Empty in arrayNo predicate

Strict resource query validation is not a closed-key validator for the entire request. These distinctions matter because an ignored narrowing parameter can produce a broader result than the client intended.

A query may not ask about a value the caller could not read in a response. “Could not read” means four kinds of field:

  • one that the resource’s field permissions hide from the caller, masked ones included, because *** is not the value;
  • a write-only field (writeOnly, or type: password), even for an administrator;
  • an internal field (#1400);
  • for distinct only, a hidden field that is not requestable.

List, count and distinct refuse a filter, sort or search on such a field with 403 FIELD_NOT_READABLE (#1372). The refusal applies in loose validation mode too, because a warning header would still have answered the question. Distinct on such a field is refused the same way (#1400), since its response is the field’s values. In the checked field-permissions case, a viewer’s filter on the admin-only secret and the viewer’s distinct on it both return 403, while an administrator’s succeed.

One exception: a server-side caller with no client behind it may still match a write-only field. authd, for example, finds a session by its refresh-token hash. A relationship list that forwards a client’s filter is not such a caller.

The evidence records the deterministic inputs, responses, builder clauses, and explicitly asserted defects. It separates native action execution, independent modeller checks, and source inspection; it does not claim full HTTP or PostgreSQL conformance. Error-envelope ownership remains with ADL 31.