Expand description
loom_epoch - the deterministic between-session Epoch world-tick (Rust core).
v3.0 Phase 3 (Living Persistent World). The native sibling of the TS
src/runtime/world-epoch.ts. While a player is offline the world must keep
moving - factions act, regions shift - WITHOUT the session/combat PRNG and
WITHOUT any non-determinism, so the browser client and the authoritative
server arrive at the BYTE-IDENTICAL world-state hash for the same epoch.
THE THREE GUARANTEES (all cross-language byte-parity, pinned by test_vectors/v3_3_epoch_tick.json):
-
PRNG ISOLATION. The Epoch PRNG is seeded from SHA-256(UTF8(world_id) || LE64(epoch_number)) - a fresh, PUBLIC derivation that never touches the session PRNG. digest[0..8] LE -> state, digest[8..16] LE |1 -> inc, built straight into
Pcg32::from_rawwith NO seeding steps. -
DETERMINISTIC ORDER + FAIL-CLOSED RESOLUTION. Offline actors are the entities carrying an actor tag; they resolve in
compare_idsorder. A proposal naming an unknown action, or failing AST validation, or erroring mid-eval is REJECTED and consumes ZERO prng + ZERO state change (prng snapshot/restore + the AST’s clone-not-mutate contract). Reason codes are assigned HERE at fixed decision points - never parsed from error text - so they are identical on every surface. -
BOUNDED COST.
tick_epochcaps SUCCESSFUL resolutions atmax_actions;catch_up_epochscaps replayed epochs atmax_catchup. Both are PARAMETERS, never hardcoded.
Structs§
Constants§
- DEFAULT_
ACTOR_ TAG - The default tag marking an entity that acts while the owner is offline.
- MAX_
SAFE_ INT - The JS-safe integer bound (2^53 - 1). Epoch / catch-up / cap inputs beyond this are rejected at the JSON boundary, matching the TS/Python guards (and keeping the emitted event JSON hashable). Codex P1.
- RESOURCE_
WORLD_ EPOCH - Resource key for the world’s resource registry (matches the TS constant).
Functions§
- catch_
up_ epochs - Deterministically replay offline epochs from
state.epochup tocurrent_epoch, capped atmax_catchup. Result depends only on (state, capped, proposals) - never on the wall clock directly. Errs (never panics) on a non-NFC world_id (round-6 audit HIGH). - catch_
up_ epochs_ from_ json - JSON-in / JSON-out catch_up_epochs WITH full input validation. Input: {worldId, state, currentEpoch, maxCatchup, ruleset, proposalsByEpoch?, actorTags?, maxActions?}. Returns {state, events, epochsResolved, epochsVoided}.
- derive_
epoch_ prng - Derive the Epoch PRNG for
(world_id, epoch_number). PUBLIC + deterministic: any surface computes the same PRNG from these two inputs. - is_
safe_ epoch - True iff
nis a JS-safe integer epoch (|n| <= 2^53 - 1). - tick_
epoch - Resolve one offline epoch. Pure: does not mutate
input.state. Returns the new state (epoch advanced) + the canonical EpochResolved event. Errs (never panics) on a non-NFC world_id - the same inputs TS/Python throw on (round-6 audit HIGH). - tick_
epoch_ from_ json - JSON-in / JSON-out tick_epoch WITH full input validation - the boundary the WASM