This document tracks the features, validation steps, and progress of the Chronos Deterministic Simulation Testing (DST) framework.
- Virtual Clock: A virtual source of time that only advances when the scheduler processes future events. Strict bounds block backwards time travel or non-finite values.
- PRNG: xoshiro256** pseudorandom number generator seeded via SplitMix64. State snapshotting (
getState/setState) is fully supported for deterministic checkpointing/restarts. - Min-Heap: Binary min-heap implementation used as a priority queue by the scheduler.
- Scheduler: Controlled, single-threaded event loop executing events in
(time, seq)order. Drains the Node.js microtask queue using a singlesetImmediatemacro-task barrier per step. - Strict Mode Guards: Global patches (
Date.now(),Math.random(),performance.now(),setTimeout,setInterval) to redirect or throw on accidental entropy leaks. - Invariants: Property-based safety invariants (checked after every step) and liveness invariants (checked at end-of-run).
- SimNetwork: Virtual network implementation supporting latency injection, message dropping, and duplication.
- PartitionManager: Simulates network partitions (splitting nodes into groups) and resolves them dynamically.
- Crash & Restart: Enables simulation of node failures by canceling their pending events on crash and resuming them on restart.
- Testing Primitives:
simTestandreplayTestVitest integrations. - Failure Capsules: JSON-based serialization format containing
{ seed, config, nodes }plus theTrace. - Capsule Security & I/O: Atomic writes (
writeCapsuleTousing temp file + rename) and safe parsing (readCapsule+ strict schema validation) to prevent local file leaks, DoS, and logic corruption. - Expect Invariants: In-body check helper
expectInvariantto halt the simulation instantly on violations.
chronos doctor: Runtime environment diagnosis (Node version, inspector asset availability, NVIDIA NIM configurations, and static DST compliance verification).chronos sweep: Runs a scenario across thousands of seeds to find first-violating inputs and output capsules.chronos replay: Re-runs a specific capsule to prove reproduction with bit-identical traces.chronos shrink: Coordinate descent probability reduction and binary-search step-shrinking to reduce chaos scenarios to minimal reproduction.chronos trace: ASCII timeline pretty-printing with customizable/TTY-gated coloring.chronos open: Launches the Inspector UI preloaded with a given capsule.chronos explain: Summarizes a failure in natural language using LLM inference (NVIDIA NIM).chronos stats: Generates detailed trace statistics (sends, delivers, drops, duplicate rates, latency bounds).chronos check: Static analysis compliance checker to find non-deterministic code blocks and global entropy references in source directories.chronos export: Converts trace event timelines to Markdown tables or CSV files.
- Vite + React web interface.
- Renders sequence diagrams, events, node statuses, and timelines.
- Interactive timeline scrubber to inspect system states chronologically.
- Metrics & Link Matrix Dashboard: Highlights total events, drop rate, duplicate rate, and fault counts. Offers an interactive node-to-node link matrix detailing traffic statistics and losses.
A full audit against the vibe-security
checklist, with every finding fixed and pinned by a regression test. The threat
model is written up in SECURITY.md; its central assumption is
that a failure capsule is untrusted input, since capsules exist to be shared.
- Capsule trust boundary: the whole capsule — trace envelope and every event
against the
TraceEventunion — is validated at read time, so renderers can stay simple. File size is capped before reading,__proto__is rejected at the parse boundary, and writes use an unpredictable temp name with an exclusive0600create. - Per-sink output escaping: terminal control sequences are stripped before printing, CSV cells are neutralized against spreadsheet formula injection, and Markdown cells against table breakout.
- Credential handling:
chronos explainsends API keys as headers only, requireshttpsoff-loopback, and masks the interactive key prompt. - Bounded rendering: the Inspector drops malformed events and caps event count, node count, and laid-out time span — surfacing any truncation in the UI.
- Deployment: security headers on the hosted Inspector, no published source maps, and least-privilege CI token permissions.
All components of the monorepo are fully operational and verified:
- Build: Successfully compiles ESM and TypeScript definitions (
dts) across all packages. - Typecheck: Zero TypeScript compile errors (
tsc --noEmitis clean). - Lint: Zero ESLint warnings or errors.
- Tests: All 326 tests are passing.