04. FACET Type System (FTS)

This page summarizes normative FTS behavior from FACET v2.1.3.

Primitive types

Constraint violations:

Composite types

Optional fields are expressed as T | null.

Multimodal types

Assignability rules

T1 assignable to T2 iff one of:

  1. T2 == any
  2. same primitive + constraints satisfied
  3. union target contains assignable member
  4. list/map element assignability
  5. struct target required fields exist and are assignable

@var_types and @vars

@var_types is an ordered singleton map from variable name to FTS expression.

@var_types
  username: "string"
  age: "int"
  score: "float"
  status: "string | null"

@vars
  username: "alice"
  age: 30
  score: 97.5
  status: null

If a declared type exists, computed value must satisfy it.

Input typing with @input

@vars
  query: @input(type="string") |> trim()
  n: @input(type="int", default=3)

Pipeline typing

Each pipeline step must accept previous step output type.

@vars
  raw: "  HELLO  "
  clean: $raw |> trim() |> lowercase()

Invalid:

@vars
  bad: 42 |> trim()

This must fail with F451 (wrong input type for lens).

JSON Schema mapping

@interface signatures must map to JSON Schema (Appendix D):

Unmappable type usage must raise F452.