Generation Engine
The engine is a deterministic simulator. Given a spec and a seed it produces truth events, their labels, and each sink's delivered copy. It has no access to the wall clock and no unseeded randomness.
Determinism
Same seed + same spec = byte-identical output.
- Seeding. The full 64 bits of the seed are spread across the generator state with SplitMix64. The generator is xoroshiro128+.
- Independent streams. Each partition gets its own non-overlapping random substream. Named streams, such as the merchant pool and party names, are seeded from the seed and the stream's name.
- Simulated time only. Every timestamp comes from arithmetic on
clock.start. Event IDs are ULIDs built from simulated time and the seeded generator. - Enforced by lint.
Math.random,Date.now()andnew Date()are banned inside the engine package.
Engine version
Any change that alters generated output bumps ENGINE_VERSION (currently 6) and is recorded in the changelog. A golden-master test pins the output of a reference spec and seed to the current version.
Each run records the engine version that made it. Regenerating, retrying or streaming a run made by a different version returns 409 engine_version_mismatch rather than quietly producing different data. Regeneration can proceed if you accept the change explicitly by sending accept_engine_change: true.
Partitioning
The consumer population is cut into contiguous partitions of about 20,000 consumers. The partition count is a function of the consumer count and the chunk size, and it is stored on the run, so it does not depend on how many threads are available.
Partitions are generated in parallel in worker threads. The number generated at once is min(CPUs − 1, 60% of RAM in GiB) by default, and can be set with TXLOOM_MAX_WORKER_THREADS.
Because each partition is a pure function of the seed, the spec and its partition number, a retry or a crash resume simply runs the partition again and rewrites the same files.
Simulating a Day
Generation proceeds one simulated day at a time per partition. A day is a pure function of the world state and the day index. Memory use is one day of events plus the queue of pending fraud, so it stays flat for any number of days.
For each day the engine:
- Plans fraud that starts today.
- Generates legitimate activity for each consumer: spending drawn from the archetype's spend rhythm, scaled by the weekend multiplier and any seasonality window; income credits according to the archetype's income pattern. Each event is placed in time using a built-in hour-of-day activity curve, so traffic has a daily shape instead of being spread evenly. Its outcome is drawn at the same time: legitimate events are declined at the baseline decline rate. An account-takeover victim that is still dormant generates nothing before its attack time.
- Merges in the fraud events that fall on this day and sorts the day by time.
- Emits truth events and labels.
The partition worker (or, in the live phase, the live world) then passes each event through every sink's imperfection transformer.
Population
Consumers are instantiated from the weighted archetypes; merchants from the weighted categories. Display names come from the locale's name pack: given and family names for people, naming grammars per category for merchants. Names are part of the deterministic output.
Amounts are drawn from each merchant category's distribution: lognormal, normal or exponential.
Fraud Planning
Fraud is planned per day by feedback toward the target rate. Each typology is owed a share of fraud in proportion to the legitimate volume so far plus today's expected volume, and each day plans whatever is still short. Planned events that turn out to be impossible are subtracted again, so the shortfall is planned again later.
Campaigns are queued by simulated time. A campaign that starts late on the last history day continues into the live phase.
| Typology | How a campaign is built |
|---|---|
| Card testing | A burst of burst_size_min to burst_size_max payments between amount_min and amount_max, spread at random inside burst_window_minutes and placed at a random point in the day. Each probe has a 15% chance of approval; the final step has 60%. |
| Account takeover | The attack day is drawn uniformly from the planning day plus dormancy_days to the end of history, at a random time in the first half of that day; in the live phase it is exactly dormancy_days ahead. The victim makes no legitimate transactions until then. drain_step_count P2P transfers of 500 to 5,000 then follow 15 minutes apart, with up to 5 minutes of jitter, each with an 85% chance of approval. |
| Refund abuse | Each campaign makes up to max_refunds_per_actor attempts, each with probability refund_rate. An attempt refunds a random purchase among the consumer's last 16, 30 minutes to 4.5 hours after it. An attempt is dropped if there is nothing to refund or if the refund would fall after the end of that day. |
Every fraud event carries a label with is_fraud, typology, actor_id and campaign_step.
Imperfections
Imperfections are applied by a transformer that runs once per sink, one event at a time. It receives the truth event and returns what that sink is delivered. The truth event is never modified.
| Type | Mechanism |
|---|---|
| Late arrival | With probability rate, the delivery waits until simulated time passes ts + delay, where the delay is drawn from a normal distribution and floored at zero. Payload ts is unchanged; delivered_at holds the arrival time. |
| Clock skew | Applies only to a sink listed in sources. With probability rate, that source's offset_seconds is added to payload ts. Order is unchanged. |
| Out of order | The flagged delivery is held for one slot so the next one overtakes it. The label is written only when an overtake really happens. |
| Duplicate | One extra copy follows the original immediately, with a new delivery_id. |
Each sink's transformer has its own random stream. Adding or removing a sink does not change another sink's output.
Every corruption produces a label, so the answer key lists exactly which deliveries were affected and how.
From History to Live
At the end of history each partition's world is checkpointed, including its random state, its pending fraud campaigns and each sink's transformer state.
The live phase restores that checkpoint and keeps calling the same day simulator for days D, D+1 and so on. History days followed by live days produce exactly what one uninterrupted simulation would.
- Per sink, the partitions' deliveries are merged by
delivered_at - A token bucket releases them at the target rate
- Live events are stamped with simulated time;
sent_atrecords the wall-clock publish time - Checkpoints are taken as the stream runs, so a stopped or crashed session resumes from a known day
Realism Report
While generating, each partition keeps running statistics. When the run completes they are merged into the realism report:
| Section | Contents |
|---|---|
| Event count | Total truth events |
| Amount | Mean, standard deviation, minimum, maximum |
| Inter-arrival time | Mean and standard deviation |
| Fraud | Achieved rate and counts per typology |
| Benchmark comparison | Reference ranges supplied by the template, where it has them |
| Chart data | Daily volume, amounts per event type, day-of-week by hour-of-day activity, daily fraud per typology |
The report is stored as report.json in the run's folder and served at GET /api/v1/runs/:id/report.
Reference Scale
The documented reference scale is 200,000 consumers and 5,000 merchants over 90 days, streamed at up to 1,000 events per second. Larger populations still generate; the validator raises a warning when the consumer or merchant count, or clock.then_stream_tps, is above the benchmarked range.
Extending the Engine
Adding a typology, an imperfection type or a locale name pack is described in Extending TxLoom.
