ADL 43 · Part V — Execution, presentation, and integration

0.5.1 baseline + 0.6 edition note

Vector search and RAG

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 vector/search integration assumptions and external-service 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 43-vector-search-and-rag.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.

43.1 Scope and edition boundary

ADL can describe documents, chunks, indexing status, answers, and citations as ordinary records. A separate service can produce embeddings, own a similarity index, retrieve authorized source material, and pass that material to a model. This chapter describes that application pattern. Since adl 0.112.0 (#1096) a store on PostgreSQL with pgvector can also index an array of floats flagged vector: and answer nearest-neighbour queries on the ordinary list path (§43.7). ADL still introduces no type: vector, retrieval endpoint, embedding provider, or generation operation.

The governing delta §22 defers type: vector and embedding indexes. The inherited chapter (v0.5.0, retired) also treats vector search as an external integration. The checked native parser rejects the complete deferred-vector.yaml example. An ordinary json or array field containing numbers does not acquire similarity-search semantics; only the vector: flag of §43.7 does.

ADL 10 owns field types, ADL 12 owns relationship declarations, ADL 21 owns resource authority, and ADL 44 owns the implemented integration grammar. Choosing a model, index engine, access policy, or consistency protocol remains an application and platform decision.

43.2 Divide ownership explicitly

A useful division is:

ArtifactOwner and responsibility
Document recordADL resource: stable ID, title, source revision, digest, and indexing status
Chunk recordADL resource: stable chunk ID, document ID/revision, text or locator, digest, and embedding-generation metadata
EmbeddingService: model-specific numeric output, dimension, preprocessing/version identity, and validation
Similarity indexService/store: vectors, distance function, index generation, search parameters, and deletion
Retrieval resultService: scored candidates checked against current records and caller authority
Answer and citation recordsADL resources where declared; application supplies answer text and verifiable source identities
Generation requestApplication/model provider: prompt, context limits, generation settings, and output checks

The complete metadata.yaml declares Document, Chunk, and Citation. It intentionally uses ordinary fields. Its documentId and chunkId strings are identifiers, not implicit foreign keys. Applications that require generated relationship validation must declare relationships according to ADL 12. Similarly, an indexStatus string records a reported state; ADL does not run an indexer because that field exists.

A chunk carries documentRevision, contentHash, embeddingModel, and embeddingDimensions so a retrieval service can identify the indexed generation. There is no universal dimension default. The example uses three dimensions and fixed vectors solely to make arithmetic inspectable; it does not recommend a model or represent model output.

43.3 Indexing and change propagation

An application indexing procedure can follow these steps:

  1. Read an identified source revision and derive deterministic chunk identities.
  2. Record the chunk text or locator and its digest as ADL metadata.
  3. Compute embeddings using an explicitly selected model and preprocessing version.
  4. Write vectors under the same chunk IDs in a service-owned index generation.
  5. Publish that generation only after its metadata and vector writes are verified.
  6. Mark the source revision indexed, recording the generation that was published.

Retries need idempotent keys, such as document ID, revision, chunk ID, and model identity. Otherwise a repeated job can create duplicate candidates. A failed embedding request must remain distinguishable from an empty document, an unauthorized read, and a successful index containing no matching vectors.

Putting metadata and vector tables in one database does not itself make ADL resource actions and service writes one transaction. Establish and verify a transaction boundary or use a recoverable job/outbox protocol with reconciliation. ADL history or integration callbacks can be inputs to that protocol, but their existence does not establish exactly-once delivery. ADL 24 and ADL 44 describe their actual event and failure behavior.

Updates require a new generation or replacement protocol. Deletion requires both record removal and index cleanup. A service should reject a candidate whose current chunk has disappeared even if index cleanup has not yet completed. Retaining a stale vector while its source becomes inaccessible must not permit that source text to reappear in a response.

43.4 Retrieval and authorization

Similarity search produces candidate IDs and scores. It does not decide whether the caller may read those records. Before returning text or passing it to a model, the application must apply its authority policy and reread the current source through an appropriate authorized interface.

The service example consumes records actually created by the native ADL fixture. It owns a small in-memory vector index and uses an explicit application permission callback. It checks candidate model and dimensions, current document/chunk existence, document revision, and the digest of the text it is about to return. This demonstrates where checks belong; the callback is an illustrative policy fixture, not a substitute for production ADL RBAC or evidence that native vector retrieval exists.

For production retrieval, decide how scopes, field restrictions, tenant/site identity, deleted records, and cross-domain authority affect both indexing and querying. An administrative indexing account can read more than an end user. Its ability to index a document must not become that user’s permission to see it. Prefiltering at the index may reduce candidate volume; final source checks still need a defined consistency boundary.

The example ranks with cosine similarity and stable chunk-ID tie breaking. It rejects mismatched dimensions/models, zero-length query vectors, and non-finite components. These are service choices. Scores are relative ranking values; they are not probabilities that an answer is correct.

43.5 RAG context and citation provenance

A retrieval-augmented generation application supplies retrieved passages as context for a model. Retrieval and generation remain distinct operations: retrieving a passage does not prove it supports a generated claim, and producing an answer does not prove that its citations identify the context actually used.

Keep source IDs, revisions, content digests, and the retrieval generation alongside the context. The illustrative result contains documentId, chunkId, documentRevision, contentHash, embeddingModel, score, and the checked text. The ADL Citation fixture stores the subset needed to reconnect an answer to its chunk and source generation. Additional fields can record retrieval time, model/version, query-policy version, and a bounded context manifest.

Treat retrieved source text as data. Instructions found inside a document should not acquire application authority merely because similarity search selected it. The application owns prompt construction, tool authority, output validation, and the handling of unsupported or conflicting passages. No ADL declaration in this pattern guarantees grounded answers, prompt-injection resistance, or faithful citation generation.

43.6 Evidence and limits

The native fixture submits the metadata domain and creates a document, a chunk, and a citation in SQLite. It checks native parser/export/registry behavior and independently checks the modeller. The rejected-vector input remains explicitly labelled invalid; it is included to demonstrate the closed type boundary.

The service exercise uses the native metadata record to demonstrate an authorized result and rejection after permission denial, revision changes, content changes, chunk deletion, model mismatch, and dimension mismatch. It performs no remote embedding call, persistent vector-index build, or language-model generation. Those operations need separate provider and workload evidence before an application claims them.

The evidence record identifies source revisions and hashes. Neither accepted metadata syntax nor a passing service exercise establishes more than §43.7 states. A type: vector field and embedding generation by the runtime remain deferred until a governing language change and corresponding runtime contract exist.

43.7 Vector fields on PostgreSQL (vector:)

A field that is type: array with items: {type: float} may carry a vector: mapping:

embedding:
  type: array
  items: {type: float}
  vector: {dimensions: 768, metric: cosine, index: hnsw}
KeyValuesDefault
dimensionsrequired integer, 1–16000; at most 2000 unless index: none—
metriccosine, l2, ip (negative inner product)cosine
indexhnsw, ivfflat, nonehnsw

The parser refuses vector: on any other field shape, an unknown key, and minItems/maxItems that disagree with dimensions; both bounds are set to dimensions, so a write of the wrong length is 422 VALIDATION_ERROR naming the field, and OpenAPI shows minItems = maxItems = dimensions.

Storage. The JSON array stays the source of truth. On PostgreSQL with the vector extension installed, activation maintains a generated column "<field>__vec" vector(N) and, unless index: none, an index using vector_cosine_ops, vector_l2_ops or vector_ip_ops. Adding or changing the flag on an existing field rebuilds the column and index at the next activation. Without the extension the field stays a plain array and a warning is logged. __vec columns never appear in responses.

Query. near[<field>]=[x1,…,xN] on the list endpoint orders results by distance, nearest first, and adds a numeric _distance to each item. Rows without a vector are left out. It composes with filter[...], scopes, read conditions and limit, and is answered under the resource’s list permission: no row the caller could not list is returned. sort=_distance (or another sort key) overrides the default order. Refusals:

CaseResponse
SQLite or another store without pgvector support400 VECTOR_UNSUPPORTED
Field without vector:, or one the caller may not read400, near[<field>]: not a searchable vector field
Wrong length, non-numeric or non-finite components400
near with a cursor400 (use limit/offset)
near[<field>]=@<id>400, not supported yet

_distance is the pgvector operator’s value (<=>, <-> or <#>). It ranks; it is not a probability. HNSW and IVFFlat are approximate: under a selective filter or read condition they may return fewer than limit rows. Use index: none where exact results matter more than speed.

Evidence: tools/repro/adl/58_vector_near.py (PostgreSQL and SQLite) and the QueryBuilderVector tests in plugins/adl/tests/test_adl_query_engine.cpp.