DS 1.1.0

Desert Sage

An embeddable language for reacting to a changing world. Facts arrive — a sensor reading, a door opening, a reply from a service — and rules match patterns across them and fire typed effects.

use default
from units.si import celsius
from units.customary import fahrenheit

schema Thermometer scope logical:
    "A room's thermometer, which reports in Celsius."
    room: String key
    temperature: celsius mutable

schema TooHot scope ttl 1_h:
    "A room found too hot."
    room: String

rule too_hot:
    "A room over 85 °F is too hot, whatever unit its thermometer reports in."
    Thermometer t where t.temperature > 85_°F
->
    log warning "{t.room} is too hot"
    publish TooHot room: t.room

temperature is not a bare number — it is a value in Celsius, and the rule compares it with 85_°F. DS knows both are temperatures and converts between them, and rejects a comparison with non-temperature units at compile time.

Four guarantees

Determinism

Over a fixed sequence of inputs, DS produces the same output every time — bit for bit, across platforms. The live world is not deterministic, so DS records a live session and replays it exactly.

Testability

Every defined behaviour is observable and assertable: a deterministic clock advanced by hand, mockable service calls, a directly driven fact stream. Rule files are testable the way the engine itself is.

Debuggability

When a rule fires — or will not — the engine answers why. Which facts matched, the activation steps, time-travel over a recorded run, and the justification chain behind a derived fact.

Termination

Every cycle comes to rest. DS admits no unbounded computation: the compiler refuses a program whose rules could feed one another without end, so no fact can set off a loop.

Install in one line

The tools package is the compiler, the REPL, the test runner and the language server, in one npm package for Node 20 or later:

npm install @ds-lang/tools

Offline, download ds-tools-1.1.0.tgz from the latest release, then:

npm install --offline ./ds-tools-1.1.0.tgz

The Author's Reference has the details in Installing.

To embed the engine in a program:

Every release is at /releases/, permanently, with hashes and its signature.