Shared foundations for the Phase 176 sovereign neural-world-model stack.
Provides the abstractions every learned simulator in Phase 176 builds on:
WorldModel<S, A, O>— the uniform interface (encode/step/imagine/getUncertainty) implemented by DreamerV3's RSSM, MuZero's dynamics net, Genie's ST-transformer, and DIAMOND's diffusion dynamics.LatentState— a tagged union ofDeterministicLatent,StochasticLatent(diagonal Gaussian),CategoricalLatent(k×c one-hots, DreamerV3), andTokenLatent(VQ codebook grid, Genie), with real KL / entropy / balancing math and flat (de)serialisation.ActionSpace—ContinuousBox,DiscreteFinite,MultiDiscrete, andMultiModal(mouse + keyboard + text), plus aLatentActionCodebook(k-means-fit VQ quantiser) for Genie-style latent action tokens.ReplayBuffer— a prioritised (sum-tree) replay + trajectory dataset that ingests Phase 85 flywheel sessions and serves n-step returns and variable-horizon sequence slices that respect episode boundaries.ImaginationEngine— the DreamerV3 λ-return / GAE rollout engine reused across Dreamer, MuZero, and latent policy-gradient training.
Everything is pure TypeScript with no runtime dependencies; the numeric formulas (KL divergence, λ-returns, prioritised IS weights) are unit-tested against closed-form values.
text
npx vitest run --root libs/nous/world-model-core