paracosm 0.9.1096 → 0.9.1097

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -84,11 +84,11 @@ console.log(trunk.fingerprint, branch.fingerprint);
84
84
 
85
85
  ```typescript
86
86
  const replay = await wm.replay(storedArtifact);
87
- console.log(replay.matches); // true when the kernel reproduces the artifact byte for byte
87
+ console.log(replay.matches); // true when the between-turn step reproduces each saved snapshot
88
88
  console.log(replay.divergence); // first-mismatch JSON pointer when matches=false
89
89
  ```
90
90
 
91
- The kernel's between-turn progression hook reruns deterministically from each recorded snapshot. LLM stages are not invoked, so replay is fast and free. Use it for golden-artifact regression tests in CI, or to find the first kernel-state divergence between two paracosm versions.
91
+ Replay restores the kernel from each saved snapshot, re-runs the between-turn step (ageing, dose, deaths, births, food and morale) to the next turn, and compares the result with the next snapshot. It calls no model, so it is fast and free. It does not re-apply a turn's decisions, and the turn loop saves each snapshot after them, so a run of two or more turns that the turn loop saved reports a mismatch at its second snapshot ([#235](https://github.com/framerslab/paracosm/issues/235)), and a one-turn run, with one snapshot, matches with no transition checked. What replay checks, what the seed fixes and what the model decides: [FAQ](docs/FAQ.md#what-does-replay-do).
92
92
 
93
93
  ---
94
94
 
@@ -430,12 +430,12 @@ Running a simulation calls real LLM APIs against the user's key. Paracosm assign
430
430
 
431
431
  | Preset | Departments | Commander · Director · Judge | Reactions | OpenAI / run | Anthropic / run |
432
432
  |-----------------------|--------------------------------------|-----------------------------------------------------|----------------------------------------------------|--------------|-----------------|
433
- | `quality` (default) | gpt-5.4 · claude-sonnet-4-6 | gpt-5.4-mini · claude-haiku-4-5-20251001 | gpt-5.4-nano · claude-haiku-4-5-20251001 | ~$1 to $3 | ~$3 to $7 |
433
+ | `quality` (default) | gpt-5.4 · claude-sonnet-4-6 | gpt-4o (commander), gpt-5.4-mini (director, judge) · claude-haiku-4-5-20251001 | gpt-5.4-nano · claude-haiku-4-5-20251001 | ~$1 to $3 | ~$3 to $7 |
434
434
  | `economy` | gpt-4o · claude-sonnet-4-6 | gpt-5.4-nano · claude-haiku-4-5-20251001 | gpt-5.4-nano · claude-haiku-4-5-20251001 | ~$0.20 to $0.60 | ~$3 to $5 |
435
435
 
436
436
  Numbers assume 6 turns, 5 departments, 100 agents, up to 3 events per turn. Forge approval rate drops 10 to 20 points on `economy` because the mid-tier department model occasionally violates structured-output schemas the judge rejects. Use `economy` for iteration and CI; use `quality` for publishable runs. Explicit `models` entries always win over the preset, so per-role overrides combine cleanly with global defaults.
437
437
 
438
- `WorldModel.simulate` returns a `cost` field with token counts, LLM call counts, and USD spend. Stable system prefixes (the director's instructions, the department prompts) route through a `cacheBreakpoint: true` block, so on Anthropic the shared prefix serves from prompt cache at one-tenth input cost from turn 2 onward once it reaches the model's minimum (4,096 tokens on Claude Haiku 4.5, [prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching)); OpenAI caches a prefix on its own once it reaches the model's minimum (1,024 tokens on GPT-5.6 and later, set by the request on earlier models, [prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching)). The `cost.caches` field reports tokens read, tokens created, and USD saved per run.
438
+ `WorldModel.simulate` returns a `cost` field with the run's USD spend and its LLM call count; it leaves the token counts empty. Stable system prefixes (the director's instructions, the department prompts) route through a `cacheBreakpoint: true` block, so on Anthropic the shared prefix serves from prompt cache at one-tenth input cost from turn 2 onward once it reaches the model's minimum (4,096 tokens on Claude Haiku 4.5, [prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching)); OpenAI caches a prefix on its own once it reaches the model's minimum (1,024 tokens on GPT-5.6 and later, set by the request on earlier models, [prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching)). The cost payload on each streamed event (`_cost`) carries the tokens, the prompt-cache reads and writes, and the USD the cache saved, per stage.
439
439
 
440
440
  ---
441
441
 
@@ -550,6 +550,7 @@ Commercial, partnership and sponsorship inquiries go to [team@frame.dev](mailto:
550
550
  | API docs | [paracosm.agentos.sh/docs](https://paracosm.agentos.sh/docs) |
551
551
  | HTTP API | [docs/HTTP_API.md](https://github.com/framerslab/paracosm/blob/master/docs/HTTP_API.md) |
552
552
  | Cookbook | [docs/COOKBOOK.md](https://github.com/framerslab/paracosm/blob/master/docs/COOKBOOK.md) |
553
+ | FAQ | [docs/FAQ.md](https://github.com/framerslab/paracosm/blob/master/docs/FAQ.md): dice, models, seeds, replay and forks |
553
554
  | npm | [npmjs.com/package/paracosm](https://www.npmjs.com/package/paracosm) |
554
555
  | AgentOS | [agentos.sh](https://agentos.sh/en) |
555
556
  | Discord | [wilds.ai/discord](https://wilds.ai/discord) |
@@ -45,9 +45,9 @@ Full per-turn record appends to the RunArtifact.
45
45
 
46
46
  ## Determinism + replay
47
47
 
48
- The kernel is fully deterministic, seeded by Mulberry32 (32-bit PRNG). Given the same seed, scenario, and actor profile, agent rosters, lifecycle schedules, promotion sequences, and resource starting values are identical. Divergence between parallel worlds comes entirely from the AI commander's decisions.
48
+ The kernel is deterministic, seeded by Mulberry32 (a 32-bit pseudo-random number generator). Given the same seed, scenario, population and key personnel, a run starts with the same roster, and each person rolls the same dice for each cause each year whoever leads. What differs between two leaders' worlds comes from each leader's traits, which scale an event's outcome and pull the department heads' personalities, from what the model writes for each (events, department reports, choices), and from the states those leave. A rerun of the same seed makes new model calls and can go differently. The FAQ covers what the dice, the formulas, the scenario's tables and the model each decide: https://github.com/framerslab/paracosm/blob/master/docs/FAQ.md
49
49
 
50
- - `wm.replay(artifact)` re-executes the deterministic between-turn progression hook from each recorded snapshot. Returns `{ matches: true | false, divergencePath?: string }`. `matches: true` proves byte-equal-determinism.
50
+ - `wm.replay(artifact)` re-runs the between-turn step from each recorded snapshot without calling a model and compares the result with the next snapshot. Returns `{ artifact, matches, divergence }`; `divergence` names the first path that differs. The turn loop records each snapshot after the turn's decisions, which replay does not re-apply, so a run it saved reports a mismatch at its second snapshot (https://github.com/framerslab/paracosm/issues/235). A run with one snapshot matches with no transition checked, since replay copies its only snapshot.
51
51
  - `wm.forkFromArtifact(trunk, atTurn).simulate(altLeader)` branches a counterfactual from any captured turn — the CWSM (Counterfactual World State Model) pattern (Kirfel et al, 2025).
52
52
 
53
53
  ## Runtime tool forging (sandboxed)
@@ -167,7 +167,7 @@ Every method has real input/output JSON captured in `docs/COOKBOOK.md`. `scripts
167
167
  | **LLM-driven?** | Yes (events + decisions) | Yes (per-agent) | Yes (per-agent) | No (rule-based) | Mostly no |
168
168
  | **Personality model** | HEXACO + pluggable | Heterogeneous prompt | Persona prompts | n/a | n/a |
169
169
  | **Determinism** | Seeded kernel | Stochastic | Stochastic | Stochastic | Mixed |
170
- | **Replay verified?** | Yes (`wm.replay` byte-equal) | No | No | Save/load only | Save/load only |
170
+ | **Replay verified?** | The between-turn step (`wm.replay`; a turn-loop run mismatches at its second snapshot, #235) | No | No | Save/load only | Save/load only |
171
171
  | **Counterfactual fork** | Yes (`wm.forkFromArtifact`) | Manual | Manual | Manual | Manual |
172
172
  | **Tool forging** | Sandboxed runtime forge | No | No | No | No |
173
173
  | **Output** | Universal forkable RunArtifact | Aggregate forecast | Aggregate forecast | Custom logs | Custom logs |
@@ -196,8 +196,9 @@ All three produce the same canonical ScenarioPackage.
196
196
 
197
197
  ## LLM provider support
198
198
 
199
- - **OpenAI** — GPT-5.4 family
200
- - **Anthropic** — Claude Sonnet 4.6, Claude Haiku 4.5
199
+ - **OpenAI** (the default for a dashboard run, `runSimulation` and `WorldModel.simulate`; `WorldModel.quickstart` and `paracosm compile` default to Anthropic): for `runSimulation` and `WorldModel.simulate`, GPT-5.4 for the departments, GPT-4o for the commander, GPT-5.4 mini for the Event Director and the tool judge, GPT-5.4 nano for agent reactions; the dashboard's model picker keeps those but sets the commander to GPT-5.4 mini
200
+ - **Anthropic**: Claude Sonnet 4.6 for the departments, Claude Haiku 4.5 for every other role
201
+ - **Hosted demo** (on the host's keys): GPT-5.4 mini for the departments, the tool judge and the verdict; GPT-5.4 nano for the commander, the Event Director and agent reactions
201
202
 
202
203
  Each role (commander, departments, director, judge, agent reactions) configurable independently. Cost presets `quality` and `economy` bundle sensible defaults; per-role overrides win. Auto-detects which API key is present, falls back between providers.
203
204
 
@@ -209,7 +210,7 @@ A 6-turn run on a small scenario:
209
210
 
210
211
  Compile-from-seed adds ~$0.10 (cached to disk by seed signature).
211
212
 
212
- Largest cost lever: tool reuse after turn 3. Anthropic prompt cache hits the shared system prefix from turn 2 onward (10× input-cost reduction); OpenAI auto-caches any prompt over 1024 tokens. The artifact's `cost` field reports tokens read, tokens created, and USD saved per run.
213
+ Largest cost lever: tool reuse after turn 3. Anthropic prompt cache hits the shared system prefix from turn 2 onward (10× input-cost reduction); OpenAI auto-caches any prompt over 1024 tokens. The artifact's `cost` field reports the run's spend in US dollars and its number of model calls; the cost payload on each streamed event (`_cost`) carries the tokens, the prompt-cache reads and writes, and the USD the cache saved, per stage.
213
214
 
214
215
  ## Network behavior
215
216
 
@@ -58,7 +58,8 @@
58
58
  {"@type":"Question","name":"What are the two kinds of world model and which one is Paracosm?","acceptedAnswer":{"@type":"Answer","text":"The phrase 'world model' is overloaded. Older lineages do most of the work: Hafner's Dreamer line and DeepMind's MuZero learn dynamics in latent space; MuJoCo, Brax, and Isaac Sim simulate physics deterministically. Both have been the substrate for robotics research for years. LeCun's JEPA family is explicitly anti-pixel — the architectural argument is that pixel reconstruction is wasteful. Newer pixel-generation entrants (Sora, Genie 3, World Labs Marble) get the headlines, but their 'world simulator' framing is contested by the older lineage. Structured / LLM-based world models emit typed JSON state, decisions, and citations agents can reason inside. Paracosm is in the structured / LLM lineage. The split is surveyed in the Tsinghua FIB Lab ACM CSUR 2025 survey and the World Model for Robot Learning survey (arXiv 2605.00080); critique in Xing 2025 (arXiv 2507.05169); counterfactual semantics in Kirfel et al, AI & Ethics 2025."}},
59
59
  {"@type":"Question","name":"How does Paracosm differ from MiroFish, OASIS, and other agent-based modeling stacks?","acceptedAnswer":{"@type":"Answer","text":"MiroFish and OASIS (CAMEL-AI) run open-ended bottom-up social simulations with thousands to one million LLM-driven agents and emit aggregate prediction reports. Paracosm runs a top-down agent swarm: one HEXACO-typed leader, ~5 specialist departments, ~100 personality-typed cells, deterministic per seed. Different scale (~100 vs 1k-1M), direction (top-down vs bottom-up), output (universal forkable RunArtifact vs aggregate forecast). Classical ABM (Mesa, NetLogo, MASON, ABIDES, AnyLogic) is rule-based and largely non-LLM; Paracosm threads LLMs into events while keeping a deterministic kernel for state."}},
60
60
  {"@type":"Question","name":"How does a single turn run end-to-end?","acceptedAnswer":{"@type":"Answer","text":"A turn takes 30-90 seconds and runs four phases. (1) Event Director reads world state and prior decisions, generates events that target weak points. (2) Department Analysis: five specialist agents analyze in parallel, can recall research, may forge new computational tools. (3) Commander Decision: the leader weighs department input through their HEXACO profile and emits an action category, parameter set, rationale, and confidence score. (4) Kernel Resolution: the deterministic state machine applies effects, agents react, HEXACO traits drift through leader-pull, role-activation, and outcome-reinforcement. The full per-turn record appends to the RunArtifact."}},
61
- {"@type":"Question","name":"Is the simulation deterministic? How is replay verified?","acceptedAnswer":{"@type":"Answer","text":"The kernel is fully deterministic, seeded by Mulberry32 (32-bit PRNG). Given the same seed, scenario, and actor profile, agent rosters, lifecycle schedules, promotion sequences, and resource starting values are identical. Divergence between parallel worlds comes entirely from the AI commander's decisions. wm.replay(artifact) re-executes the deterministic between-turn progression hook from each recorded snapshot and compares under canonical JSON: matches=true proves byte-equal-determinism; matches=false names the first divergence path. wm.forkFromArtifact(trunk, atTurn).simulate(altLeader) branches a counterfactual from any captured turn — the CWSM pattern (Kirfel et al, 2025)."}},
61
+ {"@type":"Question","name":"What decides what happens, the dice or the model?","acceptedAnswer":{"@type":"Answer","text":"Seeded dice decide luck: who dies, who is born, who recovers and who is promoted, each against a chance a fixed formula sets, and whether the option a leader picks succeeds. The language model writes the events of the turns the scenario does not fix, the department reports, the leader's choice, the reactions and the verdict; the effects a leader adopts from the reports move only numbers the run holds, each by at most a set amount per decision, and an event's outcome moves what the scenario's own table for its category names. A rerun of the same seed rolls the same dice but makes new model calls, so it can go differently; the FAQ at https://github.com/framerslab/paracosm/blob/master/docs/FAQ.md walks through each part with links to the code."}},
62
+ {"@type":"Question","name":"Is the simulation deterministic? How is replay verified?","acceptedAnswer":{"@type":"Answer","text":"The kernel is deterministic, seeded by Mulberry32 (a 32-bit pseudo-random number generator). Given the same seed, scenario, population and key personnel, a run starts with the same roster, and each person rolls the same dice for each cause each year whoever leads. What differs between two leaders' worlds comes from each leader's traits, which scale an event's outcome and pull the department heads' personalities, from what the model writes for each (events, department reports, choices), and from the states those leave. wm.replay(artifact) re-runs the between-turn step from each recorded snapshot without calling a model and compares the result under canonical JSON; matches=false names the first divergence path. The turn loop records each snapshot after the turn's decisions, which replay does not re-apply, so a run of two or more turns that it saved reports a mismatch at its second snapshot, while a one-turn run holds one snapshot and matches with no transition checked; the FAQ at https://github.com/framerslab/paracosm/blob/master/docs/FAQ.md says what replay proves. wm.forkFromArtifact(trunk, atTurn).simulate(altLeader) branches a counterfactual from any captured turn, the CWSM pattern (Kirfel et al, 2025)."}},
62
63
  {"@type":"Question","name":"How does runtime tool forging work, and is it safe?","acceptedAnswer":{"@type":"Answer","text":"When a department agent needs a calculation the codebase doesn't provide, it writes one. Specialist proposes a tool with a Zod-validated input/output schema, the LLM authors a JavaScript body, and the code runs in an in-process node:vm context with a 10-second wall clock, its heap use reported against a nominal 128 MB budget. The forge always rejects code that uses eval, Function, require, dynamic import, process, child_process or destructive fs calls, and paracosm grants forged code no network, file or crypto access. An LLM judge reviews output against the specialist's stated intent — match approves, mismatch rejects. Approved tools land in a discoverable registry; reuse via call_forged_tool costs tens of tokens vs full tokens for a fresh forge. After turn three, most decisions invoke a previously-forged tool and total run cost flattens."}},
63
64
  {"@type":"Question","name":"What is the HEXACO personality model and why use it?","acceptedAnswer":{"@type":"Answer","text":"HEXACO is a six-factor framework with extensive cross-cultural validation: Honesty-Humility, Emotionality, Extraversion, Agreeableness, Conscientiousness, Openness to Experience — a six-factor extension of the Big Five with Honesty-Humility split out as a separate axis. Each agent carries six continuous values in [0,1]; values drift across turns through three mechanisms encoded in the kernel: leader-pull, role-activation, outcome-reinforcement. Personality biases which specialists are consulted, which decisions are accepted, and which tools get forged. Source: Ashton & Lee, Personality and Social Psychology Review 11(2), 150-166, 2007 (doi:10.1177/1088868306294907)."}},
64
65
  {"@type":"Question","name":"Are leaders locked to human personality?","acceptedAnswer":{"@type":"Answer","text":"No. Paracosm ships a pluggable TraitModel registry with two built-ins: hexaco (human personality) and ai-agent (six axes for AI-system leaders: exploration, verification-rigor, deference, risk-tolerance, transparency, instruction-following). Each model declares its axes, drift table, and prompt cues. Custom models register in a single call. The same agent under two different leaders, on the same seed, becomes a measurably different entity by turn 12."}},
@@ -66,8 +67,8 @@
66
67
  {"@type":"Question","name":"How is paracosm architected? Three layers, why?","acceptedAnswer":{"@type":"Answer","text":"Three layers, strict boundaries, no circular dependencies. Engine layer owns types and the deterministic kernel: SimulationKernel, SeededRng, ScenarioPackage types, Effect/Metric registries (~71 source files). Runtime layer orchestrates simulations via 6 scenario hooks: Orchestrator, Director, Departments, Batch Runner (~43 files). CLI layer serves the dashboard, batch runner, HTTP server (~30 files plus the React/Vite/Tailwind dashboard). The engine never imports from runtime; the runtime never imports from CLI. Underneath: @framers/agentos — agent() API, EmergentCapabilityEngine, EmergentJudge, ForgeToolMetaTool, AgentMemory."}},
67
68
  {"@type":"Question","name":"Can I model a single subject (digital twin)?","acceptedAnswer":{"@type":"Answer","text":"Yes. The paracosm/digital-twin subpath: supply a SubjectConfig + InterventionConfig, get the same Zod-validated RunArtifact shape with artifact.subject and artifact.intervention populated. artifact.trajectory.timepoints[t].worldSnapshot carries per-timepoint metrics. Same shape applies to medical interventions (subject=patient, intervention=treatment), policy modeling (subject=jurisdiction, intervention=ordinance), and product launches (subject=market, intervention=pricing change). Counterfactual semantics: Kirfel et al, AI & Ethics 2025."}},
68
69
  {"@type":"Question","name":"Where can I see real input and output JSON?","acceptedAnswer":{"@type":"Answer","text":"Every method in the public API has its real input JSON and real output JSON captured in docs/COOKBOOK.md. One run threads through seven public surfaces: prompt-to-world, quickstart parallel leaders (runMany), branch at turn N (wm.forkFromArtifact), kernel replay (wm.replay), HTTP /simulate endpoint, digital-twin intervene(), batch dispatch (runBatch). Plus scripts/cookbook-e2e.ts in the repo runs the full pipeline against your scenario / leader profiles / seed."}},
69
- {"@type":"Question","name":"What LLM providers work with Paracosm?","acceptedAnswer":{"@type":"Answer","text":"OpenAI (GPT-5.4 family) and Anthropic (Claude Sonnet 4.6, Claude Haiku 4.5). Each role (commander, departments, director, judge, agent reactions) is configurable independently. Cost presets quality and economy bundle sensible defaults; per-role overrides win. Paracosm auto-detects which API key is present and falls back between providers."}},
70
- {"@type":"Question","name":"What does a typical run cost?","acceptedAnswer":{"@type":"Answer","text":"A six-turn run on a small scenario runs roughly tens of cents under economy and a few dollars under quality. Compile-from-seed adds ~$0.10 (cached to disk by seed signature). Tool reuse after turn three is the largest cost lever. Anthropic prompt cache hits the shared system prefix from turn 2 onward (10x input-cost reduction); OpenAI auto-caches any prompt over 1024 tokens. The cost field reports tokens read, tokens created, and USD saved per run."}},
70
+ {"@type":"Question","name":"What LLM providers work with Paracosm?","acceptedAnswer":{"@type":"Answer","text":"OpenAI and Anthropic. OpenAI is the default for a dashboard run and for runSimulation and WorldModel.simulate; WorldModel.quickstart and the compile command default to Anthropic. The default OpenAI models for runSimulation and WorldModel.simulate are GPT-5.4 for the departments, GPT-4o for the commander, GPT-5.4 mini for the Event Director and the tool judge, and GPT-5.4 nano for agent reactions; the dashboard's model picker keeps those but sets the commander to GPT-5.4 mini. On Anthropic, Claude Sonnet 4.6 for the departments and Claude Haiku 4.5 for every other role. The hosted demo, on the host's keys, runs GPT-5.4 mini for the departments, the tool judge and the verdict, and GPT-5.4 nano for the commander, the Event Director and agent reactions. Each role (commander, departments, director, judge, agent reactions) is configurable independently. Cost presets quality and economy bundle sensible defaults; per-role overrides win. Paracosm auto-detects which API key is present and falls back between providers."}},
71
+ {"@type":"Question","name":"What does a typical run cost?","acceptedAnswer":{"@type":"Answer","text":"A six-turn run on a small scenario runs roughly tens of cents under economy and a few dollars under quality. Compile-from-seed adds ~$0.10 (cached to disk by seed signature). Tool reuse after turn three is the largest cost lever. Anthropic prompt cache hits the shared system prefix from turn 2 onward (10x input-cost reduction); OpenAI auto-caches any prompt over 1024 tokens. A run's cost field reports its spend in US dollars and its number of model calls; the cost breakdown on each streamed event carries the tokens, the prompt-cache reads and writes, and the USD the cache saved, per stage."}},
71
72
  {"@type":"Question","name":"What verticals does this apply to?","acceptedAnswer":{"@type":"Answer","text":"Digital-twin medicine, corporate strategy (M&A, market entry, leadership replays), policy simulation (tax, regulation, congestion pricing, healthcare reform), defense / wargaming (commander HEXACO under shared starting conditions; replay any past run after a code change), game design playtesting (procedural NPC civilizations, runtime tool forge), AI alignment red-teaming (pressure-test agent behavior under specific HEXACO weights). The engine is domain-agnostic; the scenario contract names the world."}},
72
73
  {"@type":"Question","name":"Can I build my own scenario?","acceptedAnswer":{"@type":"Answer","text":"Three paths. (1) Write a ScenarioPackage in TypeScript with custom hooks for progression, crisis generation, milestones, and politics — full control. (2) Write a scenario JSON draft and run it through compileScenario() — zero-code authoring, $0.10 per compile, caches to disk. (3) Pass a brief or URL to WorldModel.fromPrompt() and let an LLM draft the JSON contract first. All three produce the same canonical ScenarioPackage."}},
73
74
  {"@type":"Question","name":"Does Paracosm need an internet connection?","acceptedAnswer":{"@type":"Answer","text":"Yes. Compiling a scenario and running it both call the OpenAI or Anthropic API. Web search is optional. Live search is off by default for a run, and department research then comes from the scenario's knowledge bundle."}},
@@ -307,7 +308,7 @@
307
308
  <ul class="l-list-md">
308
309
  <li><strong style="color:var(--t1)">Output:</strong> typed JSON state, decisions, citations</li>
309
310
  <li><strong style="color:var(--t1)">Audience:</strong> AI agents deciding and measuring</li>
310
- <li><strong style="color:var(--t1)">Replay:</strong> deterministic kernel, byte-equal output</li>
311
+ <li><strong style="color:var(--t1)">Replay:</strong> re-run the seeded kernel step from saved snapshots, no model call</li>
311
312
  <li><strong style="color:var(--t1)">For agents:</strong> direct. Each turn is a state transition the agent can reason over.</li>
312
313
  </ul>
313
314
  </div>
@@ -464,9 +465,9 @@ setTimeout(() =&gt; ctrl.<span class="fn">abort</span>(), <span class="num">120_
464
465
  console.<span class="fn">log</span>(<span class="str">'baseline:'</span>, baseline.fingerprint);
465
466
  console.<span class="fn">log</span>(<span class="str">'fork(reyes -&gt; okafor):'</span>, alt.fingerprint);
466
467
 
467
- <span class="cm">// 3. Replay the original deterministically. Proves the kernel is byte-equal.</span>
468
+ <span class="cm">// 3. Replay the original: re-runs the kernel's between-turn step from each snapshot, no model call.</span>
468
469
  <span class="kw">const</span> { matches, divergence } = <span class="kw">await</span> wm.<span class="fn">replay</span>(baseline);
469
- console.<span class="fn">log</span>(<span class="str">'replay matches:'</span>, matches); <span class="cm">// true</span>
470
+ console.<span class="fn">log</span>(<span class="str">'replay matches:'</span>, matches); <span class="cm">// false on a turn-loop run: decisions are not re-applied (#235)</span>
470
471
  <span class="kw">if</span> (!matches) console.<span class="fn">error</span>(<span class="str">'first divergence at:'</span>, divergence);
471
472
 
472
473
  <span class="cm">// 4. Inject an event at turn 4 by forking + running with a custom event.</span>
@@ -722,7 +723,7 @@ npm run dashboard <span class="cm"># opens http://localhost:3456</span>
722
723
  <div class="arch-row" style="border-left:3px solid var(--amber)">
723
724
  <svg style="color:var(--amber);width:24px;height:24px" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="5" width="16" height="14" rx="2"/><line x1="4" y1="10" x2="20" y2="10"/><line x1="9" y1="14" x2="9" y2="14.01"/><line x1="13" y1="14" x2="17" y2="14"/></svg>
724
725
  <div class="arch-label" style="color:var(--amber)">Structured state, deterministic spine</div>
725
- <div class="arch-desc">A JSON-contract-backed world schema with metrics, capacities, statuses, politics, and environment. The kernel is a seeded Mulberry32 state machine — given the same seed, scenario, and actor profiles, every run produces an identical agent roster, lifecycle schedule, and resource trajectory. Divergence comes from personality, not luck. <code>wm.replay(artifact)</code> is byte-equal-deterministic.</div>
726
+ <div class="arch-desc">A JSON-contract-backed world schema with metrics, capacities, statuses, politics, and environment. The kernel is a seeded Mulberry32 state machine: given the same seed, scenario, population and key personnel, every run starts with an identical agent roster, and each person rolls the same dice each year. Divergence comes from the leaders and the choices they make, not luck. <code>wm.replay(artifact)</code> re-runs the kernel's between-turn step from each saved snapshot with no model call.</div>
726
727
  <div class="arch-tech">Zod schema · Mulberry32 PRNG · ScenarioPackage</div>
727
728
  </div>
728
729
  <div class="arch-row" style="border-left:3px solid var(--amber)">
@@ -942,14 +943,14 @@ npm run dashboard <span class="cm"># opens http://localhost:3456</span>
942
943
  </tr>
943
944
  <tr>
944
945
  <th scope="row">Determinism</th>
945
- <td><strong>Byte-equal at fixed seed</strong> via Mulberry32 + canonical JSON</td>
946
+ <td><strong>Seeded kernel</strong>: the same roster and the same dice at a fixed seed (Mulberry32); model calls are not deterministic</td>
946
947
  <td>None — LLM non-determinism throughout</td>
947
948
  <td>None — LLM non-determinism throughout</td>
948
949
  <td>Partial — graph control flow is deterministic, agent calls are not</td>
949
950
  </tr>
950
951
  <tr>
951
952
  <th scope="row">Counterfactual replay</th>
952
- <td><code>wm.replay(artifact)</code> reproduces byte-equal artifacts</td>
953
+ <td><code>wm.forkFromArtifact(artifact, turn)</code> branches from any captured turn; <code>wm.replay(artifact)</code> re-runs the kernel's between-turn step</td>
953
954
  <td>Not supported</td>
954
955
  <td>Not supported</td>
955
956
  <td>Not supported (rerun the graph from scratch)</td>
@@ -1013,7 +1014,7 @@ npm run dashboard <span class="cm"># opens http://localhost:3456</span>
1013
1014
  </tbody>
1014
1015
  </table>
1015
1016
  </div>
1016
- <p class="compare-footer">Picking a framework is downstream of picking a task. Use <strong>AutoGen / CrewAI</strong> when the task is multi-agent <em>conversation</em> with predefined tools. Use <strong>LangGraph</strong> when the task is a state machine you want explicit control over. Use <strong>paracosm</strong> when the task is a <em>simulation</em>: world state evolves over turns, decisions affect outcomes, you need to fork or replay at a past turn, or you need byte-equal reproducibility for evals or compliance.</p>
1017
+ <p class="compare-footer">Picking a framework is downstream of picking a task. Use <strong>AutoGen / CrewAI</strong> when the task is multi-agent <em>conversation</em> with predefined tools. Use <strong>LangGraph</strong> when the task is a state machine you want explicit control over. Use <strong>paracosm</strong> when the task is a <em>simulation</em>: world state evolves over turns, decisions affect outcomes, you need to fork or replay at a past turn, or you need the same starting world and the same dice across runs for evals or compliance.</p>
1017
1018
  </div>
1018
1019
  </details>
1019
1020
  </div>
@@ -1049,8 +1050,12 @@ npm run dashboard <span class="cm"># opens http://localhost:3456</span>
1049
1050
  <div class="faq-cite">Inspired by interactive-narrative directors (Riedl &amp; Bulitko, <a href="https://ojs.aaai.org/aimagazine/index.php/aimagazine/article/view/2449" target="_blank" rel="noopener">Interactive Narrative: An Intelligent Systems Approach</a>, AI Magazine 34(1), 2013).</div>
1050
1051
  </div></details>
1051
1052
 
1053
+ <details class="faq-item"><summary>What decides what happens, the dice or the model?</summary><div class="faq-body">
1054
+ Seeded dice decide luck: who dies, who is born, who recovers and who is promoted, each against a chance a fixed formula sets, and whether the option a leader picks succeeds. The language model writes the events of the turns the scenario does not fix, the department reports, the leader's choice, the reactions and the verdict; the effects a leader adopts from the reports move only numbers the run holds, each by at most a set amount per decision, and an event's outcome moves what the scenario's own table for its category names. A rerun of the same seed rolls the same dice but makes new model calls, so it can go differently; the <a href="https://github.com/framerslab/paracosm/blob/master/docs/FAQ.md" target="_blank" rel="noopener">FAQ</a> walks through each part with links to the code.
1055
+ </div></details>
1056
+
1052
1057
  <details class="faq-item"><summary>Is the simulation deterministic? How is replay verified?</summary><div class="faq-body">
1053
- The kernel is fully deterministic, seeded by <a href="https://en.wikipedia.org/wiki/Multiply-with-carry_pseudorandom_number_generator" target="_blank" rel="noopener">Mulberry32</a> (32-bit PRNG). Given the same seed, scenario, and actor profile, the kernel produces identical agent rosters, lifecycle schedules, promotion sequences, and resource starting values on every run. Divergence between parallel worlds comes entirely from the AI commander's decisions. <code>wm.replay(artifact)</code> re-executes the deterministic between-turn progression hook from each recorded snapshot, captures fresh snapshots, and compares under canonical JSON: <code>matches=true</code> proves byte-equal-determinism for that artifact's transitions; <code>matches=false</code> names the first divergence path so changes can be localized. <code>wm.forkFromArtifact(trunk, atTurn).simulate(altLeader)</code> branches a counterfactual from any captured turn — the <a href="https://link.springer.com/article/10.1007/s43681-025-00718-4" target="_blank" rel="noopener">CWSM pattern</a>.
1058
+ The kernel is deterministic, seeded by <a href="https://en.wikipedia.org/wiki/Multiply-with-carry_pseudorandom_number_generator" target="_blank" rel="noopener">Mulberry32</a> (a 32-bit pseudo-random number generator). Given the same seed, scenario, population and key personnel, a run starts with the same roster, and each person rolls the same dice for each cause each year whoever leads. What differs between two leaders' worlds comes from each leader's traits, which scale an event's outcome and pull the department heads' personalities, from what the model writes for each (events, department reports, choices), and from the states those leave. <code>wm.replay(artifact)</code> re-runs the between-turn step from each recorded snapshot without calling a model and compares the result under canonical JSON; <code>matches=false</code> names the first divergence path. The turn loop records each snapshot after the turn's decisions, which replay does not re-apply, so a run of two or more turns that it saved reports a mismatch at its second snapshot, while a one-turn run holds one snapshot and matches with no transition checked; the <a href="https://github.com/framerslab/paracosm/blob/master/docs/FAQ.md#what-does-replay-do" target="_blank" rel="noopener">FAQ</a> says what replay proves. <code>wm.forkFromArtifact(trunk, atTurn).simulate(altLeader)</code> branches a counterfactual from any captured turn, the <a href="https://link.springer.com/article/10.1007/s43681-025-00718-4" target="_blank" rel="noopener">CWSM pattern</a>.
1054
1059
  <div class="faq-cite">PRNG methodology: Law &amp; Kelton, <em>Simulation Modeling and Analysis</em> (5th ed., McGraw-Hill, 2015) · CWSM framing: Kirfel L. et al. (2025) · API surface: <code>WorldModel.replay()</code>, <code>canonicalJson</code>, <code>firstDivergence</code> in <code>paracosm/runtime/world-model</code>.</div>
1055
1060
  </div></details>
1056
1061
 
@@ -1091,11 +1096,11 @@ npm run dashboard <span class="cm"># opens http://localhost:3456</span>
1091
1096
 
1092
1097
  <!-- ============== USE / INTEGRATION ============== -->
1093
1098
  <details class="faq-item"><summary>What LLM providers work with Paracosm?</summary><div class="faq-body">
1094
- OpenAI (GPT-5.4 family) and Anthropic (Claude Sonnet 4.6, Claude Haiku 4.5). Each role (commander, departments, director, judge, agent reactions) is configurable independently. Cost presets <code>quality</code> and <code>economy</code> bundle sensible defaults; per-role overrides win. Paracosm auto-detects which API key is present in env and falls back between providers. Mini models are available for cost iteration but produce lower-quality structured output and trip the judge more often.
1099
+ OpenAI and Anthropic. OpenAI is the default for a dashboard run and for <code>runSimulation</code> and <code>WorldModel.simulate</code>; <code>WorldModel.quickstart</code> and the <code>compile</code> command default to Anthropic. The default OpenAI models for <code>runSimulation</code> and <code>WorldModel.simulate</code> are GPT-5.4 for the departments, GPT-4o for the commander, GPT-5.4 mini for the Event Director and the tool judge, and GPT-5.4 nano for agent reactions; the dashboard's model picker keeps those but sets the commander to GPT-5.4 mini. On Anthropic, Claude Sonnet 4.6 for the departments and Claude Haiku 4.5 for every other role. The hosted demo, on the host's keys, runs GPT-5.4 mini for the departments, the tool judge and the verdict, and GPT-5.4 nano for the commander, the Event Director and agent reactions. Each role (commander, departments, director, judge, agent reactions) is configurable independently. Cost presets <code>quality</code> and <code>economy</code> bundle sensible defaults; per-role overrides win. Paracosm auto-detects which API key is present in env and falls back between providers. Mini models are available for cost iteration but produce lower-quality structured output and trip the judge more often.
1095
1100
  </div></details>
1096
1101
 
1097
1102
  <details class="faq-item"><summary>What does a typical run cost?</summary><div class="faq-body">
1098
- A six-turn run on a small scenario with default settings costs roughly tens of cents under <code>economy</code> and a few dollars under <code>quality</code>. Compile-from-seed adds ~$0.10 (cached to disk by seed signature). Tool reuse after turn three is the largest cost lever; the artifact records every token spend with cache-hit accounting. Anthropic's prompt cache TTL hits the shared system prefix from turn 2 onward (10× input-cost reduction); OpenAI auto-caches any prompt over 1024 tokens. The <code>cost</code> field reports tokens read, tokens created, and USD saved per run.
1103
+ A six-turn run on a small scenario with default settings costs roughly tens of cents under <code>economy</code> and a few dollars under <code>quality</code>. Compile-from-seed adds ~$0.10 (cached to disk by seed signature). Tool reuse after turn three is the largest cost lever. Anthropic's prompt cache TTL hits the shared system prefix from turn 2 onward (10× input-cost reduction); OpenAI auto-caches any prompt over 1024 tokens. A run's <code>cost</code> field reports its spend in US dollars and its number of model calls; the cost breakdown on each streamed event carries the tokens, the prompt-cache reads and writes, and the USD the cache saved, per stage.
1099
1104
  </div></details>
1100
1105
 
1101
1106
  <details class="faq-item"><summary>What verticals does this apply to?</summary><div class="faq-body">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paracosm",
3
- "version": "0.9.1096",
3
+ "version": "0.9.1097",
4
4
  "description": "Agent swarm simulation for structured world modeling with LLMs. Multi-agent worlds with HEXACO personalities, deterministic kernels, runtime tool forging, and reproducible forkable RunArtifacts. Built on AgentOS.",
5
5
  "type": "module",
6
6
  "engines": {