Craticula

Semantics overview

The rules every compiler follows, one page for each topic.

Normative per AR-1 (the maintainers' private TRD, §7): this document, not any single compiler, is where these behaviors are decided (SEM-1..SEM-7 from the TRD, SEM-8 added in #2455). A backend compiler that disagrees with a rule below has a bug, not an alternative opinion. Every rule here is the target of conformance fixtures (spec/fixtures/, TRD T-1) authored in a later work item (#1630) — this document states the rule and gives illustrative examples; it does not itself constitute the enforceable test suite.

Each section follows the same shape: the rule, why it exists (the naive alternative it rules out — see TRD §1's problem statement for the catalogue of ways this translation is usually done badly), one worked example per backend family showing the same logical outcome reached through different backend-native mechanisms, an explicit "must NOT" list, and cross-links to the IR shapes in ir.schema.json that the rule constrains.

All SQL/Mongo/OpenSearch examples in the SEM-1..SEM-7 sections below are illustrative snippets to convey intent, not the literal compiler output for any one dialect. The literal rendering — identifier quoting, parenthesisation, which operator carries a negation, how a set is parameterized — is pinned separately in three addenda at the end of this document, all of which are normative and are byte-for-byte what the spec/fixtures/ artifacts contain: "Addendum — canonical SQL rendering" (SQL-0..SQL-8) for the Postgres reference arm and its four sibling dialects, "Addendum — canonical MongoDB rendering" (MDB-1..MDB-12) for the mongo.artifact.json arm, and "Addendum — canonical OpenSearch/Elasticsearch rendering" (OSE-0..OSE-14) for the search.artifact.json arm. A Mongo or OpenSearch snippet below is illustrative in exactly the way a SQL one is; where the two disagree — SEM-1's implicit {name: "Smith"} against MDB-1's explicit $eq, or its bare {"term": {"name.keyword": …}} shorthand against OSE-1's — the addendum is what a compiler follows.