Contextfulv0.23.0

Docs / Specification

contract read · 20-read.md · 21-memory.md · guide · card

The read face

Implementers use this page for SQL queries, ranked retrieval and read responses. Each connection registers relations with the caller’s access restrictions. Reads write no rows and hold no leases. Queries use existing index sidecars and build no indexes.

Query components and their connections to storage, access controls and memory:

Flowchart diagram Flowchart, top to bottom. 11 nodes, 13 edges. token caller → statement guard [statement] operator → view registry [raw SQL, templates] read: statement guard → view registry [admitted statement] read: view registry → operator [raw result]; → candidate generator [registered views] read: candidate generator → ranker [candidates] read: query embedder → ranker [query vector] read: ranker → token caller [ranked response] read: result cache → token caller [cache hit] read: memory recall → candidate generator [claims as candidates] store: parts and manifests → view registry [pinned snapshot]; → result cache [commit invalidates] authority: composed restriction → view registry [row restriction] read admitted statement registered views claims as candidates candidates query vector statement guard view registry candidate generator query embedder ranker result cache memory recall store parts and manifests authority composed restriction statement raw SQL, templates pinned snapshot row restriction raw result ranked response commit invalidates cache hit token caller operator

register

Registered relations, query tools, templates, the embedded SQL engine and HTTP transport.

HTTP transport

contextful serve --http admits each request, bounds its connections and drains on stop.

guard

SQL validation, allowed relations, operator statements and template arguments.

respond

Response fields, cell encoding, row and byte limits, truncation and diagnostic metadata.

query

The operator’s raw statement verb on the command line: its arguments, the relations it registers, its row bound and its output.

reference

Resolution of one stored citation through the caller’s registered relation, including the authenticated distinction between an erased source and an absent version.

lineage

The applied dataflow graph narrowed to the relations one caller’s session registers, whole or walked from one table.

Scenarios

retrieve

Candidate rows for ranked retrieval: query tokens, relevance thresholds, per-table queries, deduplication and snippets.

index sidecars

Vector and full-text sidecars add candidates that rejoin through the caller’s relation.

Scenarios

unsettled: Does the row id identity-columns injects serve as the row key of a table declaring no content-hash column? owner: read-path affects: read.retrieve

unsettled: Does restriction get the statistics treatment rank-statistics gives the horizon, so BM25 document frequency on fulltext-probe excludes restricted rows? owner: authority affects: read.retrieve

rank

Candidate ordering by vector and lexical scores, timeframe and reported confidence.

unsettled: Does a convex combination over min-max-normalized scores, its weight fitted per domain on settled judgments, replace fusion? owner: read-path affects: read.rank

unsettled: Does the read face admit a pointwise reranker, and does one whose every checkpoint postdates the horizon refuse to score under it? owner: read-path affects: read.rank

cache

Locality of the bytes a read touches, reuse of a resolved session and its connections, and reuse of a result across requests.

resolve-pin

Resolution of a named published-model build at read time, and the state each response echoes.

embed

Embedding implementations, stored model identifiers, query-model checks, build identity and missing-backend errors.

as-of-join

Point-in-time ASOF JOIN statements and templates that match rows by their availability timestamps.

Scenarios

unsettled: Does an as-of join’s max_age measure valid time or availability time? owner: read-path affects: read.as-of-join

horizon

Reads under horizon: default time bounds, rejected arguments, hidden metadata, network restrictions and selection of indexes, embedding models and builds.

Scenarios

unsettled: Where does the engine record the instant a column first landed in a table, for a schema that predates the record? owner: read-path affects: read.horizon

unsettled: Does a vintage table’s sidecar count only each key’s newest vintage available by the horizon, so its statistics and candidates match the bounded relation’s one vintage per key? owner: read-path affects: read.horizon

subscribe

Committed-run notifications, durable replay, resume positions, queue limits and the subscription CLI.

Scenarios

unsettled: Does a subscription under a credential horizon withhold runs committed after it and their stamps rather than refuse? owner: read-path affects: read.subscribe

unsettled: Does the networked transport carry context.subscribe as server notifications over a held stream? owner: read-path affects: read.subscribe

Shapes

The registered relation for one table:

CREATE OR REPLACE VIEW orders AS
SELECT * FROM (
  SELECT *, ROW_NUMBER() OVER (
    PARTITION BY order_id
    ORDER BY updated_at DESC, _ingested_at DESC, _run_id DESC, _row_seq DESC
  ) AS _rn
  FROM read_parquet(
    [ 'tables/orders/data/snapshots/snapshot-01773100800000000000/part-00000.parquet',
      'tables/orders/data/runs/run-0192/node-9f2c/part-00000.parquet' ],
    union_by_name = true
  )
) WHERE _rn = 1;

The response projection, with total_cents a BIGINT column:

{
  "columns": ["order_id", "total_cents", "placed_at"],
  "rows": [["A-8812", "1299", "2026-02-14T09:31:00Z"], ["A-8813", "9007199254740993", "2026-02-14T09:44:12Z"]],
  "truncated": true,
  "contextful.bounds": { "as_of": "2026-03-01T00:00:00Z", "inclusive": false },
  "contextful.resolved": {
    "daily_orders": {
      "build_id": "snapshot-01773100800000000000",
      "watermark": { "at": "2026-02-14T10:00:00Z", "inputs": { "orders": { "snapshot_id": null, "through": 7, "omitted": { "count": 1, "digest": "9f2c…" } } } }
    }
  },
  "contextful.policy.applied": { "rows_dropped": 12, "columns_masked": ["email"], "overfetch_rounds": 1 },
  "contextful.retrieval": {
    "window": 200, "candidates_prefloor": 200, "candidates": 61,
    "matched": 61, "returned": 20, "in_window": 14, "deduped": 3,
    "padded": 0, "floor": 2, "since": "2026-02-07"
  }
}

Per-row ranking fields: { "_score": 2, "_vscore": 0.71, "_in_window": true, "_date_basis": "published_at" }.

A template, and the tool it projects as:

[[query_templates]]
id         = "orders_by_region"
sql        = "SELECT region, sum(total_cents) FROM orders WHERE placed_at >= ? AND region = ? GROUP BY region"
parameters = ["since:timestamp", "region:string"]
max_rows   = 500
{ "name": "orders_by_region",
  "inputSchema": { "type": "object",
    "properties": { "since": { "type": "string", "format": "date-time" }, "region": { "type": "string" } },
    "required": ["since", "region"] },
  "limits": { "max_rows": 500 } }