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.

Command definition

A command contains:
Inputs MUST match the declaration exactly and recursively satisfy their types. Formally, cc is a command identifier and D(c)D(c) is its definition in machine MM‘s command map. II is the map of actual values supplied to this particular invocation. Command lookup therefore precedes input validation: d=D(c)dom⁡(I)=dom⁡(inputs⁡(d))d = D(c) \qquad \operatorname{dom}(I)=\operatorname{dom}(\operatorname{inputs}(d))

Normative execution algorithm

All effect expressions MUST evaluate against snapshot. Effects are applied in declaration order to proposed.

Transition judgments

Let evalEffects⁡(E,S,I,X)\operatorname{evalEffects}(E,S,I,X) evaluate all expressions in effect sequence EE against immutable snapshot SS. Let applyEffects⁡(S,E^)\operatorname{applyEffects}(S,\widehat{E}) apply the resulting concrete effects in order. A successful changing command is: validInputs⁡(M,c,I)M,S,I,X,∅⊢require⁡(c)⇓trueE^=evalEffects⁡(effects⁡(c),S,I,X)S′=applyEffects⁡(S,E^)validState⁡(M,S′)S′≠SM⊢⟨S,c,I,X⟩⟶⟨S′,changed⁡⟩  C−Commit\frac{ \operatorname{validInputs}(M,c,I) \qquad M,S,I,X,\varnothing \vdash \operatorname{require}(c) \Downarrow \mathrm{true} \qquad \widehat{E} = \operatorname{evalEffects}(\operatorname{effects}(c),S,I,X) \qquad S' = \operatorname{applyEffects}(S,\widehat{E}) \qquad \operatorname{validState}(M,S') \qquad S' \neq S }{ M \vdash \langle S,c,I,X \rangle \longrightarrow \langle S',\operatorname{changed}\rangle } \;\mathrm{C-Commit} An unmet requirement leaves state unchanged: validInputs⁡(M,c,I)M,S,I,X,∅⊢require⁡(c)⇓falseM⊢⟨S,c,I,X⟩⟶⟨S,requirement_not_met⁡⟩  C−Require−False\frac{ \operatorname{validInputs}(M,c,I) \qquad M,S,I,X,\varnothing \vdash \operatorname{require}(c) \Downarrow \mathrm{false} }{ M \vdash \langle S,c,I,X \rangle \longrightarrow \langle S,\operatorname{requirement\_not\_met}\rangle } \;\mathrm{C-Require-False} A valid command whose concrete effects make no change commits no new state contents, though it still receives a command-event ID: validInputs⁡(M,c,I)require⁡(c)⇓trueapplyEffects⁡(S,E^)=SM⊢⟨S,c,I,X⟩⟶⟨S,unchanged⁡⟩  C−No−Change\frac{ \operatorname{validInputs}(M,c,I) \qquad \operatorname{require}(c) \Downarrow \mathrm{true} \qquad \operatorname{applyEffects}(S,\widehat{E}) = S }{ M \vdash \langle S,c,I,X \rangle \longrightarrow \langle S,\operatorname{unchanged}\rangle } \;\mathrm{C-No-Change} If the proposed state is invalid, the transition fails and commits nothing: S′=applyEffects⁡(S,E^)¬validState⁡(M,S′)M⊢⟨S,c,I,X⟩⟶⟨S,validation_error⁡⟩  C−Invalid−State\frac{ S' = \operatorname{applyEffects}(S,\widehat{E}) \qquad \neg\operatorname{validState}(M,S') }{ M \vdash \langle S,c,I,X \rangle \longrightarrow \langle S,\operatorname{validation\_error}\rangle } \;\mathrm{C-Invalid-State}

Effects

assign(f,v) replaces field f with v. apply⁡(set⁡(f,v),P)=P[f↦v]\operatorname{apply}(\operatorname{set}(f,v),P) = P[f \mapsto v] set_once(f,v) sets f only when its current proposed value is null; otherwise it is a no-op. apply⁡(setOnce⁡(f,v),P)={P[f↦v],P(f)=nullP,otherwise\operatorname{apply}(\operatorname{setOnce}(f,v),P) = \begin{cases} P[f \mapsto v], & P(f)=\mathrm{null} \\ P, & \text{otherwise} \end{cases} put(f,k,v) assigns f[k] = v. put(f,k,v,once=true) assigns only when k is absent from the current proposed map; otherwise it is a no-op. apply⁡(putOnce⁡(f,k,v),P)={P[f↦P(f)[k↦v]],k∉dom⁡(P(f))P,otherwise\operatorname{apply}(\operatorname{putOnce}(f,k,v),P) = \begin{cases} P[f \mapsto P(f)[k \mapsto v]], & k \notin \operatorname{dom}(P(f)) \\ P, & \text{otherwise} \end{cases} append(f,v) appends v to sequence field f. apply⁡(append⁡(f,v),P)=P[f↦P(f)+ ⁣+[v]]\operatorname{apply}(\operatorname{append}(f,v),P) = P[f \mapsto P(f) \mathbin{+\!+} [v]] when(p,e) applies effect e only when predicate p, evaluated against the immutable input snapshot, is true. apply⁡(when⁡(p,e),P)={apply⁡(e,P),S,I,X⊢p⇓trueP,S,I,X⊢p⇓false\operatorname{apply}(\operatorname{when}(p,e),P) = \begin{cases} \operatorname{apply}(e,P), & S,I,X \vdash p \Downarrow \mathrm{true} \\ P, & S,I,X \vdash p \Downarrow \mathrm{false} \end{cases} A no-op set_once or put-once does not cancel sibling effects. If sibling effects must occur only when insertion is possible, the shared condition MUST be stated in the command requirement or on every dependent effect.

Worked example: executing vote

Let the current state be empty: S0={votes↦{}}S_0 = \{\mathit{votes}\mapsto\{\}\} The command identifier and invocation inputs are: c=voteI1={voter↦Amina,activity↦hike}c=\mathit{vote} \qquad I_1=\{\mathit{voter}\mapsto\text{Amina}, \mathit{activity}\mapsto\text{hike}\} The command definition D(c)D(c) says to evaluate the key and value expressions against S0S_0 and I1I_1, producing the concrete effect: putOnce⁡(votes,Amina,hike)\operatorname{putOnce}(\mathit{votes},\text{Amina},\text{hike}) Because Amina is absent, the transition is: M⊢⟨S0,c,I1,X⟩⟶⟨{votes↦{Amina↦hike}},changed⁡⟩M \vdash \langle S_0,c,I_1,X\rangle \longrightarrow \left\langle \{\mathit{votes}\mapsto \{\text{Amina}\mapsto\text{hike}\}\}, \operatorname{changed} \right\rangle Now invoke the same command with different inputs: I2={voter↦Amina,activity↦sailing}I_2=\{\mathit{voter}\mapsto\text{Amina}, \mathit{activity}\mapsto\text{sailing}\} The putOnce key already exists, so: M⊢⟨S1,c,I2,X⟩⟶⟨S1,unchanged⁡⟩M \vdash \langle S_1,c,I_2,X\rangle \longrightarrow \langle S_1,\operatorname{unchanged}\rangle This example also shows why cc and II are separate: vote selects one command definition, while each invocation supplies a different input map.

Outcomes

Outcome data is advisory. It MAY report processed, changed, no-op, validation, and conflict information. It MUST NOT be represented as proof that the caller holds the latest state. Durable truth is the committed event and snapshot history.

Registered effects

A registered effect invokes an allowlisted algorithm capability. It receives only evaluated plain data and a copy of proposed state. Its complete output MUST pass the same type and resource validation before commit. Failure commits nothing.

Implemented explicit rejection extension

The current interpreter additionally supports ordered require(condition, code=...) and reject(code) effects. An assertion must evaluate to a Boolean. An explicit rejection discards all proposed effects, stops evaluation, and returns a fixed public reason code. It is distinct from the legacy unmet-requirement no-op and from an execution exception. SQLite durably records applied, no-op, and rejected decisions; execution failures leave no completed event. Guards keep the same pre-command snapshot semantics as ordinary effects. This extension is advertised through effect:assert@1 and effect:reject@1, without changing older command serialization. See Explicit rejection and outcomes for current close, acknowledgement, disclosure, and idempotency contracts.