Entity / Expressions

How three interpreters share one expression

Every Expr value is interpreted by three engines depending on where it runs:

  1. SQL compiler (foldkit-remote-drizzle): Translates the expression into parameterized SQLite, Postgres, or D1 queries.
  2. In-memory evaluator (evaluate): Runs the expression over a complete table of rows in memory.
  3. Partial holder judge (Judge): Evaluates the expression over whatever rows and fields the browser currently holds, returning Known(true | false | unknown) when decidable or Unknown(reason) when a required row or field is missing.

Two rules guarantee that SQL and memory produce identical results:

  • Three-valued SQL logic: Comparing with null yields unknown, and rows match only when the predicate evaluates to true.
  • Explicit backend parity: Text ordering declares its collation, contains specifies ASCII case folding, and inputs that databases handle inconsistently (strings containing NUL bytes, or NaN) fail explicitly.