Skip to content
language.blue
repo.blue ↗Run this example

02 · Deterministic execution

BEX Rules & Processing Gas

Compare a direct update with a conditional workflow. See which document and request values BEX reads, which changes and events it returns, and how much deterministic processing gas the resulting revision consumes.

Executable Playground exampleBEX operatorsChanges and eventsProcessing gas

The execution boundary

Logic is Blue-compatible data, not hidden application code.

BEX evaluates a bounded expression object against the current document and delivered event. It cannot mutate the Root directly. Instead it returns explicit patch operations and emitted events, which the processor commits together.

Gas is deterministic work, not wall-clock time.

The same program and input consume the same processing gas during replay. Network latency and server speed are separate measurements.

current Root + delivered request
             │
             ▼
       BEX expression object
       ├─ read $document
       ├─ read $event
       ├─ evaluate $if / arithmetic
       ├─ $appendChange
       └─ $appendEvent
             │
             ▼
changes + events + result + gas

Run it

Compare cost with meaning.

Gas becomes educational when each number stays next to the exact workflow, request, and resulting revision that produced it.

01
Run the simple update.Inspect the request values, direct arithmetic, returned patch, emitted event, and revision gas.
02
Run the conditional workflow.Follow the predicate and selected branch before inspecting its returned effects.
03
Compare the revisions.Relate processing gas to deterministic expression work—not to API response time.
04
Replay the workspace.Confirm that the same entries reconstruct the same state, events, and gas evidence.

What to inspect

Four different kinds of evidence.

Keeping these measures separate prevents a fast server from being confused with a cheap program—or Coordination routing work from being mistaken for BEX gas.

InputsThe exact document revision and delivered request.
EffectsReturned changes, events, and workflow result.
GasDeterministic BEX processing work recorded on the revision.
ElapsedObserved API and machine time, useful but not replay evidence.
Next: connect one child to more than one Root.

One Counter, Two Hosts applies the same processing loop inside an embedded document graph.