Metakit / @doeixd/metakit/abstract

Abstract

namespace · packages/metakit/src/abstract/check.ts:19

export * as Abstract from './abstract/check.js'

Tier 3 synchronous static checker over intervals and a Zone (difference bounds), with case splits on bool.or, If and Match.

It decides the value evaluation gives, under evaluation's own rule: an operator over a null operand is null, an absent key reads as null, and arithmetic past the safe range is refused. A verdict of True says the goal evaluates to true in every environment the Schemas and hypotheses allow, False that it evaluates to false in every one, and Unknown anything else: a goal that may be null is never True, and its negation is not either.

That False is the one meaning every reader's has (verdict.ts: there is an environment where the goal does not hold), made by a reader exact only on false: a goal null or refused everywhere is Unknown here, where Expr.judge would answer False. The Kleene connectives in support.ts rely on it.

In the guides

Members

Abstract.checkGoal

function · packages/metakit/src/abstract/check.ts:67

function checkGoal<S extends Schema.Top, I, Emit, Sup>(
  stateSchema: S,
  transition: Transition<S['Type'], I, Emit, Sup>,
  options: Expr.ReaderOptions & {
    readonly assume?: ReadonlyArray<
      Expr.Expr<TransitionEnv<S['Type'], I, Sup>, boolean | null>
    >
    readonly goal: Expr.Expr<GoalEnv<S['Type'], I, Sup>, boolean | null>
  },
): Verdict.Verdict<never>

Tier 3 synchronous check of one goal about one step of transition: in every step from a state stateSchema admits, with the input and supplied values their Schemas admit, where the guard and each of assume hold, does goal hold? goal reads the state before as state and the state the writes leave as next.

Abstract.checkInvariant

function · packages/metakit/src/abstract/check.ts:42

function checkInvariant<S extends Schema.Top>(
  schema: S,
  goal: Expr.Expr<S['Type'], boolean | null>,
  options?: Expr.ReaderOptions,
): Verdict.Verdict<never>

Tier 3 synchronous check: does schema entail goal?

Abstract.checkTransition

function · packages/metakit/src/abstract/check.ts:105

function checkTransition<S extends Schema.Top, I, Emit, Sup>(
  stateSchema: S,
  transition: Transition<S['Type'], I, Emit, Sup>,
  options?: Expr.ReaderOptions,
): Verdict.Verdict<never>

Tier 3 synchronous check: does transition leave a state stateSchema admits? Every rule on the Schema must hold of the state after the writes, and every written value must be one its field's Schema takes: its type, its bounds, whether it is an integer or finite, a literal of its enumeration, or null. A check it cannot read on what a write changes, a union member it cannot match, and a finite field written from a number that may not be finite each leave it Unknown, naming the check or the source.

Abstract.FieldInfo

interface · packages/metakit/src/abstract/fields.ts:11

interface FieldInfo {
  readonly segments: ReadonlyArray<string>
  readonly ast: SchemaAST.AST
  readonly kind: FieldKind
  readonly isInt: boolean
  readonly finite: boolean
  readonly nulFree: boolean
  readonly nullable: boolean
  readonly optional: boolean
  readonly absent: Absent
  readonly interval: Interval.Interval
  readonly literals: Option.Option<ReadonlyArray<string | number | boolean>>
}

What a Schema says of the value at a path.

Abstract.FieldKind

type · packages/metakit/src/abstract/fields.ts:8

type FieldKind = 'number' | 'boolean' | 'text' | 'literal' | 'struct' | 'other'

Abstract.fieldsOf

function · packages/metakit/src/abstract/fields.ts:207

function fieldsOf(slices: ReadonlyArray<Slice>): ReadonlyMap<string, FieldInfo>

What each Schema says of every path under its slice's prefix, keyed by path: fieldsOf([[['v'], schema]]) reads schema as the value at v.

Abstract.GoalEnv

interface · packages/metakit/src/abstract/check.ts:56

interface GoalEnv<State, Input, Supplied> extends TransitionEnv<
  State,
  Input,
  Supplied
> {
  readonly next: State
}

The environment a goal of checkGoal reads: a step's, and the state it leaves as next.

Abstract.Slice

type · packages/metakit/src/abstract/unordered.ts:8

type Slice = readonly [under: ReadonlyArray<string>, schema: Schema.Top]

A schema of the environment, and the path it sits under: [] for the whole of it.