Deterministic
The same seed yields a bit-identical run. Failure capsules reproduce violating traces from one integer seed on any machine.
Find the race condition and replay it from a single seed.
Chronos brings deterministic simulation testing, used in systems like FoundationDB and TigerBeetle, to Node.js and TypeScript.
It runs concurrent or distributed code on a single controlled thread with virtual time, seeded randomness, and a simulated network. Any race condition reproduces consistently from one integer seed.
import { simTest, expectInvariant } from "@sx4im/chronos-vitest";
simTest(
"counter never loses increments",
{
seeds: 100,
nodes: 3,
network: { dropProb: 0.05 },
chaos: { partitionProb: 0.05, crashProb: 0.05 },
},
async (sim) => {
for (const n of sim.nodes) n.env.net.send(/* … */);
expectInvariant("no lost increments", () => total === expected);
}
);✗ seed 8273461 violated "no lost increments" (total=99, expected=100)
-> wrote capsule: .chronos/failures/8273461.json
-> replay with: npx chronos replay .chronos/failures/8273461.jsonA failing run reproduces identically on any machine. You can pass the capsule file to a teammate or load it in the Inspector UI to trace event delivery.
@sx4im/chronos-core: PRNG (xoshiro256**), VirtualClock, MinHeap scheduler, SimEnv, strict guards, invariants, trace, and RealEnv. Zero runtime dependencies.@sx4im/chronos-net: Simulated network, partitions, chaos engine, and crash/restart handlers.@sx4im/chronos-vitest: simTest, expectInvariant, replayTest, failure capsules, and state shrinker.@sx4im/chronos-cli: Commands for replay, trace, sweep, shrink, open, and explain.pnpm add -D @sx4im/chronos-core @sx4im/chronos-net @sx4im/chronos-vitest @sx4im/chronos-cliSee the repository README for setup steps and the determinism checklist.
This site documents Chronos v0.0.0. Start with the 15-minute quickstart, read the determinism model for execution rules, or check the API reference for function signatures.