Skip to content

Determinism

open1s edited this page Sep 25, 2026 · 1 revision

Determinism

Determinism in PWE is not a slogan; it is a compile-and-run gate.

The rule

Interpreter ≡ semantic baseline
JIT/AOT     ≡ optimized implementations

The EIR interpreter is the semantic reference. Compiler optimization MUST NOT change semantics. Production execution must preserve WIR → Domain IR → EIR → execution — no undocumented bypasses.

What is enforced

Interpreter ≡ JIT, every step

step_cross runs both backends on identical state and requires:

  • byte-identical writes, and
  • identical event / queue streams,

on every step — not a summary comparison at the end.

let mut rt = pwe_reference::lang::LangRuntime::compile(SOURCE)?;
rt.step_cross()?;     // interpreter == JIT, asserted
rt.step_cross_n(30)?;

Analytic law conformance

Every simulation is asserted against its closed form: Newton cooling, radioactive decay, logistic growth, Kepler orbits, harmonic energy, action–reaction, reversible kinetics, wall reflection, and more.

Snapshot / replay

State hashes reproduce bit-for-bit across runs and snapshots. A successful commit increments WorldVersion.

Frozen contract

The RFC set in rfc/ defines canonical bytes, schemas, and protocols; the conformance runner (RFC-0029) runs with zero skips.

cargo run -p pwe-conformance
cargo test --workspace

Why it holds structurally

  • Authoritative mutation goes through WorldTransaction only — never opportunistic writes during Compute.
  • Time is explicit and domain-based; the step grid is the clock events land on.
  • Structural changes are deferred to commit.
  • Randomness (random(), noise(), emit()) is seeded and replay-stable.
  • Grid fields are ordinary deterministic world state — snapshot and replay included.
  • Presentation fields are excluded from the state hash by design.
  • A mutable entity has exactly one authoritative owner; epochs reject stale commands, so split-brain authority is never silently allowed.

The frame pipeline

Observe → Compute → Prepare → Commit → Publish

Turning it off

You cannot. Determinism is an execution mode that is first-class and always available; the differential gate runs in tests and cross-backend execution paths. A runtime that cannot meet a MUST requirement fails closed: a defined error, no authoritative mutation.

See also: The Frozen Contract · Architecture

PWE Wiki


Repository


The world is the single source of truth. Program it. Prove it. Watch it move.

Clone this wiki locally