Skip to main content

Module typecheck

Module typecheck 

Source
Expand description

The schema-derived path table and the type check.

PathTable is built once per process from the committed JSON Schema in evalhub_schema plus the currently applied ext_schemas from the registry. It maps each legal query path to where its value lives, what type it has, and which operators the storage can actually serve:

Path formTypeServed byOperators
{facet}.{key} with a columnfrom the schema leafgenerated columnall that suit the type
{facet}.{key} without onefrom the schema leafGIN index on bodyeq, exists
fingerprint.{facet}stringfingerprints tableeq, ne, in, exists
results, relations, attachmentsarray of objectown tablesany
results[{metric}].value (sort)numberresults tablesort only
ext.{ns}.{key} registeredfrom the ext_schemaexpression indexall that suit the type
ext.{ns}.{key} unregisteredunknownGIN index on bodyeq, exists
title, producer.name, …stringgenerated columnall that suit the type

The row that is easy to get wrong is the second one. Only sixteen facet keys have a generated column (the migration lists them, and GENERATED_COLUMNS mirrors that list with a test that fails if the two disagree). Every other key of the record is readable and equality- searchable through the GIN index over body, but ordering or ranging on it would be a sequential scan, so the check refuses with not_indexed and names the registry. That is the same answer an unregistered ext path gets, and for the same reason.

runs is deliberately absent: an Eval’s runs live in the body and have no side table, so there is nothing for any to range over. A query that needs them wants attachments or a registered ext path.

The check walks the parsed tree and, for each leaf, looks the path up, confirms the operator is legal for the type, confirms the literal is of that type, and confirms the operator is served by the path’s index. Failures are collected into 422 { errors[] } with codes unknown_path, type_mismatch, not_indexed, each carrying a JSON pointer into the submitted request.

The table is rebuilt when an ext_schema transitions to applied; the server holds it behind an ArcSwap-style handle so a query in flight sees a consistent table.

Structs§

ExtSchema
A registered extension schema, as the registry holds it.
PathTable
The set of legal query paths with their types and index status, projected from the record schema and the applied ext_schemas.

Enums§

Indexed
How much of the operator set a path’s storage can serve.
PathInfo
What a legal query path denotes.

Constants§

GENERATED_COLUMNS
The generated columns of versions, as JSON path and column name.

Functions§

check
Type-check a parsed filter against a path table.
compile
Parse, check and assemble a whole request into the IR the store runs.