Class: WorldModel
Defined in: apps/paracosm/src/runtime/world-model/index.ts:206
A compiled, runnable world. Wraps a ScenarioPackage with convenience methods for simulating single leaders or running a batch.
Construct via WorldModel.fromJson (compile from raw JSON) or
WorldModel.fromScenario (wrap an already-compiled scenario,
e.g. marsScenario).
The underlying scenario is exposed via WorldModel.scenario as an escape hatch for callers that want the raw ScenarioPackage.
Examples
import { WorldModel } from 'paracosm';
import worldJson from './my-world.json' with { type: 'json' };
const wm = await WorldModel.fromJson(worldJson, { provider: 'anthropic' });
const artifact = await wm.simulate({ actor: leader, maxTurns: 6, seed: 42 });
const wm = await WorldModel.fromJson(worldJson);
const trunk = await wm.simulate({
actor: visionary,
maxTurns: 6, seed: 42, captureSnapshots: true,
});
const branch = await (await wm.forkFromArtifact(trunk, 3)).simulate({
actor: pragmatist,
maxTurns: 6,
seed: 42,
});
// branch.metadata.forkedFrom === { parentRunId: trunk.metadata.runId, atTurn: 3 }
import { marsScenario } from 'paracosm';
import { WorldModel } from 'paracosm';
const wm = WorldModel.fromScenario(marsScenario);
const artifact = await wm.simulate({ actor: leader, maxTurns: 8 });
Properties
scenario
readonlyscenario:ScenarioPackage
Defined in: apps/paracosm/src/runtime/world-model/index.ts:211
The underlying compiled scenario. Exposed so callers can reuse the same compiled package across custom integrations.
Methods
batch()
batch(
options):Promise<BatchManifest>
Defined in: apps/paracosm/src/runtime/world-model/index.ts:459
Run N leaders through this world in parallel via runBatch.
scenarios is fixed to [this.scenario]; supply leaders, turns,
seed, and any other BatchConfig fields.
For N-scenarios-×-M-leaders sweeps that span multiple worlds, call
runBatch directly with an explicit scenarios array.
Parameters
options
WorldModelBatchOptions
Returns
Promise<BatchManifest>
fork()
fork(
snapshot,opts?):Promise<WorldModel>
Defined in: apps/paracosm/src/runtime/world-model/index.ts:556
Construct a new WorldModel positioned at the snapshot's turn. The
new WorldModel has no prior run of its own; calling .simulate()
on it resumes from the snapshot's kernel state, optionally with a
different leader, seed, or custom events.
metadata.forkedFrom on the subsequent .simulate() call's
returned RunArtifact is set to
{ parentRunId: snapshot.parentRunId, atTurn: snapshot.kernel.turn }.
The opts argument is accepted for API symmetry but not consumed
at fork time; the caller passes opts.leader / opts.seed /
opts.customEvents through to the subsequent .simulate() call
directly. A future spec may fold this into a single-call API.
Parameters
snapshot
opts?
ForkOptions = {}
Returns
Promise<WorldModel>
Throws
Error when snapshot.kernel.scenarioId !== this.scenario.id.
forkFromArtifact()
forkFromArtifact(
artifact,atTurn,opts?):Promise<WorldModel>
Defined in: apps/paracosm/src/runtime/world-model/index.ts:590
Convenience: pulls the kernel snapshot at atTurn from
artifact.scenarioExtensions.kernelSnapshotsPerTurn (populated
when the parent run was created with captureSnapshots: true)
and calls WorldModel.fork with it.
Parameters
artifact
aborted?
boolean = ...
assumptions?
string[] = ...
Assumptions held true during the simulation.
citations?
object[] = ...
cost?
{ breakdown?: Record<string, number>; cachedReadTokens?: number; cacheSavingsUSD?: number; inputTokens?: number; llmCalls?: number; outputTokens?: number; totalUSD: number; } = ...
cost.breakdown?
Record<string, number> = ...
Per-site / per-model breakdown: { director: 0.12, departments: 0.34 }.
cost.cachedReadTokens?
number = ...
cost.cacheSavingsUSD?
number = ...
cost.inputTokens?
number = ...
cost.llmCalls?
number = ...
cost.outputTokens?
number = ...
cost.totalUSD
number = ...
decisions?
object[] = ...
Every decision made during the run — one per commander choice in turn-loop.
disclaimer?
string = ...
Scenario-supplied disclaimer (digital-twin simulations use this for medical / professional caveats).
finalState?
{ capacities?: Record<string, number>; environment?: Record<string, string | number | boolean>; metrics: Record<string, number>; politics?: Record<string, string | number | boolean>; scenarioExtensions?: Record<string, unknown>; statuses?: Record<string, string | boolean>; } = ...
finalState.capacities?
Record<string, number> = ...
Capacity constraints: life support, housing, budget.
finalState.environment?
Record<string, string | number | boolean> = ...
Environmental conditions: weather, radiation, depth, altitude.
finalState.metrics
Record<string, number> = ...
Numeric gauges: food, power, population, morale, VO2max, whatever.
finalState.politics?
Record<string, string | number | boolean> = ...
Political/social pressures. Values may be numeric or categorical.
finalState.scenarioExtensions?
Record<string, unknown> = ScenarioExtensionsSchema
finalState.statuses?
Record<string, string | boolean> = ...
Categorical state: governance status, alignment, phase.
finalSwarm?
{ agents: object[]; births?: number; deaths?: number; morale?: number; population: number; scenarioExtensions?: Record<string, unknown>; time: number; turn: number; } = ...
Final agent-swarm roster at end-of-run. Pairs with finalState: the
world snapshot is the macro view (metrics, statuses), the swarm
snapshot is the micro view (every agent's role, mood, family edges,
memory). Populated in turn-loop runs that exercised the swarm.
Use WorldModel.swarm() for the live equivalent during a run.
finalSwarm.agents
object[] = ...
Every agent in the swarm at snapshot time, alive or dead.
finalSwarm.births?
number = ...
Number of births this turn.
finalSwarm.deaths?
number = ...
Number of deaths this turn.
finalSwarm.morale?
number = ...
Aggregate morale 0..1 (population-weighted).
finalSwarm.population
number = ...
Aggregate counts derived from agents.
finalSwarm.scenarioExtensions?
Record<string, unknown> = ScenarioExtensionsSchema
finalSwarm.time
number = ...
Scenario time at snapshot (years/quarters/ticks per scenario).
finalSwarm.turn
number = ...
Turn number this snapshot was taken at (0-indexed).
fingerprint?
Record<string, string | number> = ...
Loose classification scores. Paracosm heritage; scenarios may extend.
forgedTools?
object[] = ...
intervention?
{ adherenceProfile?: { expected: number; risks?: string[]; }; category?: string; description: string; duration?: { unit: string; value: number; }; id: string; mechanism?: string; name: string; scenarioExtensions?: Record<string, unknown>; targetBehaviors?: string[]; } = ...
Intervention being tested on the subject.
intervention.adherenceProfile?
{ expected: number; risks?: string[]; } = ...
intervention.adherenceProfile.expected
number = ...
intervention.adherenceProfile.risks?
string[] = ...
intervention.category?
string = ...
intervention.description
string = ...
intervention.duration?
{ unit: string; value: number; } = ...
intervention.duration.unit
string = ...
intervention.duration.value
number = ...
intervention.id
string = ...
intervention.mechanism?
string = ...
intervention.name
string = ...
intervention.scenarioExtensions?
Record<string, unknown> = ScenarioExtensionsSchema
intervention.targetBehaviors?
string[] = ...
leveragePoints?
string[] = ...
Actionable leverage points for consumers of the artifact.