Skip to main content
This is the Draft 0.1 language specification. Its conformance requirements include targets beyond the current implementation, such as complete static typing and resource bounds. The execution contracts describe the guarantees implemented today.

Environments

Expression evaluation receives five environments:
  • constants C;
  • immutable state snapshot S;
  • validated command input I;
  • capability-checked execution context X;
  • lexical collection locals L.
A reference MUST resolve within its declared namespace. Missing references are validation errors, except for context references declaring an explicit default.

Type judgment

Static typing is written: Γ⊢e:τ\Gamma \vdash e : \tau The type environment is the disjoint union: Γ=ΓC⊎ΓF⊎ΓI⊎ΓX⊎ΓL\Gamma = \Gamma_C \uplus \Gamma_F \uplus \Gamma_I \uplus \Gamma_X \uplus \Gamma_L where the components contain types for constants, fields, command inputs, context capabilities, and lexical locals. Context entries additionally carry a disclosure label: ΓX(x)=(τ,ℓ)\Gamma_X(x) = (\tau,\ell) The label ℓ\ell is checked by the information-flow rules in Section 5 and does not change the ordinary value type τ\tau. Representative rules: ΓF(f)=τΓ⊢field⁡(f):τ  StateType−Field\frac{ \Gamma_F(f) = \tau }{ \Gamma \vdash \operatorname{field}(f) : \tau } \;\mathrm{StateType-Field} Map lookup without a default returns an optional value: Γ⊢m:Map⁡[K,V]Γ⊢k:KΓ⊢get⁡(m,k):Optional⁡[V]  StateType−Get−Optional\frac{ \Gamma \vdash m : \operatorname{Map}[K,V] \qquad \Gamma \vdash k : K }{ \Gamma \vdash \operatorname{get}(m,k) : \operatorname{Optional}[V] } \;\mathrm{StateType-Get-Optional} Map lookup with a default of the map’s value type returns a non-optional value: Γ⊢m:Map⁡[K,V]Γ⊢k:KΓ⊢d:VΓ⊢get⁡(m,k,d):V  StateType−Get−Default\frac{ \Gamma \vdash m : \operatorname{Map}[K,V] \qquad \Gamma \vdash k : K \qquad \Gamma \vdash d : V }{ \Gamma \vdash \operatorname{get}(m,k,d) : V } \;\mathrm{StateType-Get-Default} Conditional branches are combined with the least defined type join: Γ⊢p:Boolean⁡Γ⊢e1:τ1Γ⊢e2:τ2τ1⊔τ2=τΓ⊢choose⁡(p,e1,e2):τ  StateType−Choose\frac{ \Gamma \vdash p : \operatorname{Boolean} \qquad \Gamma \vdash e_1 : \tau_1 \qquad \Gamma \vdash e_2 : \tau_2 \qquad \tau_1 \sqcup \tau_2 = \tau }{ \Gamma \vdash \operatorname{choose}(p,e_1,e_2) : \tau } \;\mathrm{StateType-Choose} The required joins are: τ⊔τ=τ\tau \sqcup \tau = \tau τ⊔Null⁡=Null⁡⊔τ=Optional⁡[τ]\tau \sqcup \operatorname{Null} = \operatorname{Null} \sqcup \tau = \operatorname{Optional}[\tau] Optional⁡[τ]⊔τ=τ⊔Optional⁡[τ]=Optional⁡[τ]\operatorname{Optional}[\tau] \sqcup \tau = \tau \sqcup \operatorname{Optional}[\tau] = \operatorname{Optional}[\tau] No implicit join exists for unrelated types. For example, Number⁡⊔Text⁡\operatorname{Number} \sqcup \operatorname{Text} is undefined unless a future DSL version introduces an explicitly declared union type. An undefined join is a creation-time type error; it does not silently widen to Any.

Worked example: constructing the poll’s type environment

While checking the vote command, the relevant environments include: ΓC(activities)=Sequence⁡[Activity⁡],ΓF(votes)=Map⁡[Text⁡,Activity⁡],ΓI(voter)=Text⁡,ΓI(activity)=Activity⁡,ΓX(current.agent.name)=(Text⁡,Participant⁡),ΓL=∅.\begin{aligned} \Gamma_C(\mathit{activities}) &= \operatorname{Sequence}[\operatorname{Activity}], \\ \Gamma_F(\mathit{votes}) &= \operatorname{Map}[\operatorname{Text},\operatorname{Activity}], \\ \Gamma_I(\mathit{voter}) &= \operatorname{Text}, \\ \Gamma_I(\mathit{activity}) &= \operatorname{Activity}, \\ \Gamma_X(\mathit{current.agent.name}) &= (\operatorname{Text},\operatorname{Participant}), \\ \Gamma_L &= \varnothing. \end{aligned} Here Activity is the finite choice type containing the four configured activities. There are no lexical locals because the command does not contain a map, filter, or similar binding expression. The expression:
is typed in three steps: Γ⊢field⁡(votes):Map⁡[Text⁡,Activity⁡]\Gamma \vdash \operatorname{field}(\mathit{votes}) : \operatorname{Map}[\operatorname{Text},\operatorname{Activity}] Γ⊢input⁡(voter):Text⁡\Gamma \vdash \operatorname{input}(\mathit{voter}) : \operatorname{Text} and therefore: Γ⊢get⁡(field⁡(votes),input⁡(voter)):Optional⁡[Activity⁡]\Gamma \vdash \operatorname{get}( \operatorname{field}(\mathit{votes}), \operatorname{input}(\mathit{voter}) ) : \operatorname{Optional}[\operatorname{Activity}] The optional result reflects that this voter may not have voted yet. By contrast:
has type Activity, because its default is also an Activity. A context-dependent expression illustrates the disclosure component:
has ordinary value type Text, while its label records that it identifies the current participant. Type checking answers “is this text?”; information-flow checking separately answers “may this view disclose it?” An implementation MUST recursively validate sequence element types, map key and value types, and record fields. Top-level container checking is insufficient.

Evaluation

Pure expressions MUST NOT modify state or perform I/O. Evaluation is deterministic for identical environments and semantic versions. Arithmetic MUST reject division by zero and non-finite results. Positional access MUST reject an invalid index unless guarded by a lazy expression.

Laziness

choose, Boolean and, and Boolean or are short-circuiting: M,S,I,X,L⊢p⇓trueM,S,I,X,L⊢e1⇓vM,S,I,X,L⊢choose⁡(p,e1,e2)⇓v  E−Choose−True\frac{ M,S,I,X,L \vdash p \Downarrow \mathrm{true} \qquad M,S,I,X,L \vdash e_1 \Downarrow v }{ M,S,I,X,L \vdash \operatorname{choose}(p,e_1,e_2) \Downarrow v } \;\mathrm{E-Choose-True} M,S,I,X,L⊢p⇓falseM,S,I,X,L⊢e2⇓vM,S,I,X,L⊢choose⁡(p,e1,e2)⇓v  E−Choose−False\frac{ M,S,I,X,L \vdash p \Downarrow \mathrm{false} \qquad M,S,I,X,L \vdash e_2 \Downarrow v }{ M,S,I,X,L \vdash \operatorname{choose}(p,e_1,e_2) \Downarrow v } \;\mathrm{E-Choose-False} The absent branch premise is intentional: the unselected expression is not evaluated. Short-circuit conjunction and disjunction are: M,S,I,X,L⊢p⇓falseM,S,I,X,L⊢p∧q⇓false  E−And−False\frac{M,S,I,X,L \vdash p \Downarrow \mathrm{false}} {M,S,I,X,L \vdash p \land q \Downarrow \mathrm{false}} \;\mathrm{E-And-False} M,S,I,X,L⊢p⇓trueM,S,I,X,L⊢q⇓vM,S,I,X,L⊢p∧q⇓v  E−And−True\frac{M,S,I,X,L \vdash p \Downarrow \mathrm{true} \qquad M,S,I,X,L \vdash q \Downarrow v} {M,S,I,X,L \vdash p \land q \Downarrow v} \;\mathrm{E-And-True} The rules for ∨\lor are dual. The unselected branch MUST NOT be evaluated. Similarly, the right operand of and is skipped after false and the right operand of or is skipped after true.

Collection operations

Map, filter, reduction, and sorting operate only on finite collections. Their lexical locals are visible only inside their own expression body. Stable sorting MUST preserve input order among records equal under all declared sort keys. Reducers MUST define empty-collection behavior explicitly. It is an error to invoke a reducer for which the runtime lacks the exact semantic version.

Expression safety

The language MUST NOT provide arbitrary callbacks, imports, evaluation of code, reflection, unrestricted object attributes, filesystem or network access, general recursion, or user-defined unbounded loops.

Implemented accumulator expressions

The current interpreter also provides lexical let, sequence fold, bounded iterate, take, exp, and stable logsumexp expressions. Their operands and bodies are serialized in the existing expression representation. See Primitive examples and validation for their operational contracts, scope rules, budget boundaries, and examples. The iteration cap does not establish the specification’s global resource-bound requirements or a complete static type system. Older interpreters that do not recognize these operators must reject the definitions.

Implemented record and scope checks

StateType.record(fields, allow_extra=False) declares required named members. Optional member types admit null, not omission; allow_extra=True permits additional finite JSON values. Initial values, inputs, and proposed state are checked recursively. Machine validation checks lexical scope in all expression contexts and rejects literal lookups of undeclared members on known closed records, including unselected branches. Failures include the machine and expression path. These checks are a conservative subset of the type judgment described above. The interpreter checks known operand compatibility, preserves compatible numeric and nested-container branch shapes, and uses explicitly declared accumulator_type/state_type invariants in loops. Seeds and each carried value are also validated at runtime. Undeclared accumulator types remain unknown. Unlike the full judgment above, unrelated branches currently widen to any; null safety, dynamic lookup proofs, and complete reducer inference are not implemented. These are implementation boundaries, not full conformance claims. See Records and early validation for the current contract.