TxLoomTxLoom
Home
  • What is TxLoom?
  • How It Works
  • Features
  • Screenshots
  • Demo Videos
  • Installation Guide
  • Configuration
  • Scenario Spec
  • Under the Hood
Home
  • What is TxLoom?
  • How It Works
  • Features
  • Screenshots
  • Demo Videos
  • Installation Guide
  • Configuration
  • Scenario Spec
  • Under the Hood
  • Getting Started

    • Installation Guide
    • Configuration
    • Scenario Spec

Scenario Spec

A scenario spec is the JSON document a run is generated from. It describes the world, the fraud, the imperfections and the outputs. It is validated before anything runs, versioned in the scenario's history, and snapshotted into every run.

You can write it in the studio editor, start from a template, or have an AI agent write it through the MCP server.

A Complete Example

A small UPI-style scenario with all three fraud typologies, two imperfections and one Kafka sink:

{
  "seed": 20260101,
  "currency": "INR",
  "locale": "en-IN",
  "channel": "upi",
  "clock": { "start": "2026-01-01", "days": 90, "then_stream_tps": 50 },
  "population": {
    "consumers": {
      "count": 5000,
      "archetypes": [
        {
          "name": "salaried",
          "weight": 0.55,
          "income_pattern": { "kind": "fixed_credit_day", "day_of_month": 1, "amount_mean": 60000, "amount_stddev": 15000 },
          "spend_rhythm": { "daily_transaction_count_mean": 2.5, "daily_transaction_count_stddev": 1.2, "weekend_multiplier": 1.4 }
        },
        {
          "name": "gig_worker",
          "weight": 0.45,
          "income_pattern": { "kind": "irregular_weekly", "amount_mean": 9000, "amount_stddev": 3000 },
          "spend_rhythm": { "daily_transaction_count_mean": 3.5, "daily_transaction_count_stddev": 1.5, "weekend_multiplier": 1.1 }
        }
      ]
    },
    "merchants": {
      "count": 400,
      "categories": {
        "grocery": { "name": "grocery", "weight": 0.6, "amount_distribution": { "kind": "lognormal", "mean": 400, "stddev": 150 } },
        "fuel": { "name": "fuel", "weight": 0.4, "amount_distribution": { "kind": "normal", "mean": 800, "stddev": 300 } }
      }
    }
  },
  "seasonality": [
    { "event": "diwali", "window": ["2026-02-10", "2026-02-17"], "volume_multiplier": 2.2 }
  ],
  "fraud": {
    "target_rate": 0.015,
    "typologies": [
      { "type": "card_testing", "share": 0.4, "params": { "burst_size_min": 3, "burst_size_max": 8, "burst_window_minutes": 4, "amount_min": 1, "amount_max": 25 } },
      { "type": "account_takeover", "share": 0.4, "params": { "dormancy_days": 45, "drain_step_count": 4 } },
      { "type": "refund_abuse", "share": 0.2, "params": { "refund_rate": 0.25, "max_refunds_per_actor": 4 } }
    ]
  },
  "outcomes": { "baseline_decline_rate": 0.02 },
  "imperfections": {
    "duplicate_delivery": { "rate": 0.01, "sinks": ["upi-stream"] },
    "late_arrival": { "rate": 0.03, "delay_seconds_mean": 20, "delay_seconds_stddev": 8, "sinks": ["upi-stream"] }
  },
  "output": {
    "sinks": [{ "type": "kafka", "name": "upi-stream", "format": "json" }],
    "labels": "separate_export"
  }
}

The four gallery templates are complete worked examples. They are also listed in the agent reference.


Top Level

FieldTypeDescription
seedinteger0 to 9007199254740991. The same seed and spec always reproduce byte-identical output. Larger 64-bit seeds can be passed at launch.
currencystringISO 4217 code, for example INR or USD. One currency per scenario.
localestringName pack for consumer and merchant display names. Shipped: en-IN, en-US.
channelstringFree-text label stamped on every event, for example upi, card_present, wallet.
clockobjectSimulation clock
populationobjectConsumers and merchants
seasonalityarrayVolume windows. May be empty.
fraudobjectFraud rate and typologies
outcomesobjectDecline rate
imperfectionsobjectDelivery faults. May be empty.
outputobjectSinks and label handling

Clock

FieldDescription
startISO date the history begins, for example "2026-01-01"
daysLength of the history in days, at least 1
then_stream_tpsOptional. If set, the run can continue as a live stream at this target rate. Omit for a files-only scenario.

Population

Consumers

FieldDescription
countNumber of consumers
archetypes[].nameArchetype name
archetypes[].weightShare of the population. All weights must sum to 1.
archetypes[].income_pattern.kindfixed_credit_day (salaried; needs day_of_month, 1 to 28) or irregular_weekly (gig work)
archetypes[].income_pattern.amount_mean, amount_stddevIncome amount
archetypes[].spend_rhythm.daily_transaction_count_mean, daily_transaction_count_stddevTransactions per day
archetypes[].spend_rhythm.weekend_multiplierMultiplier applied on Saturday and Sunday

Merchants

FieldDescription
countNumber of merchants
categoriesObject keyed by category name
categories.<key>.nameCategory name
categories.<key>.weightShare of merchants. All weights must sum to 1.
categories.<key>.amount_distribution.kindlognormal, normal or exponential
categories.<key>.amount_distribution.mean, stddevPayment amount. stddev is not used by exponential.

Seasonality

Each entry raises (or lowers) volume inside a date window.

FieldDescription
eventLabel shown on the volume chart
window[startDate, endDate]. Must overlap the simulation clock.
volume_multiplierFactor applied to volume inside the window

Fraud

FieldDescription
target_rateShare of events that are fraud, 0 to 0.5
typologies[].typecard_testing, account_takeover or refund_abuse
typologies[].shareShare of fraud given to this typology. Shares must sum to 1.
typologies[].paramsDepends on the type, see below

Card testing

ParamDescription
burst_size_min, burst_size_maxNumber of probe payments in a burst
burst_window_minutesTime window the burst falls in
amount_min, amount_maxAmount range of each probe

Account takeover

ParamDescription
dormancy_daysDays the victim's account is dormant before the attack. Must be less than clock.days.
drain_step_countNumber of draining P2P transfers

Refund abuse

ParamDescription
refund_rateRate at which the actor requests refunds
max_refunds_per_actorCap on refunds per actor

Outcomes

FieldDescription
baseline_decline_rateShare of legitimate events that are declined, 0 to 1

Imperfections

Every imperfection takes a rate from 0 to 0.2 and an optional sinks list of sink names. Leave sinks out to apply it to every sink.

KeyExtra fieldsEffect
duplicate_deliveryAn extra copy of the event is delivered
late_arrivaldelay_seconds_mean, delay_seconds_stddevThe event is delivered later than it happened
out_of_orderThe next delivery overtakes this one
clock_skewsources[] of { source, offset_seconds }The named sink's event times are shifted by the offset. source must be a declared sink name.

Output

FieldDescription
sinks[].typefile, kafka, rabbitmq or webhook
sinks[].nameUnique name. Imperfections and launch destinations refer to it.
sinks[].formatcsv, parquet or json
labelsseparate_export (recommended) keeps the answer key out of the main export. merged_with_warning allows a merged export after the warning is acknowledged.
stream_label_channelOptional boolean. Enables the label channel for live streams.

A spec names sinks by type only. Broker addresses and credentials live in connections, and each non-file sink is bound to one at launch.


Validation

A spec is checked against the JSON Schema, then against the semantic invariants below. Each violation is reported with a JSON Pointer path, a code and a message.

Errors

CodeRule
seed-out-of-rangeseed must be an integer from 0 to 9007199254740991
seasonality-window-outside-clockEvery seasonality window must overlap the simulation clock
archetype-weights-not-normalizedArchetype weights must sum to 1
merchant-category-weights-not-normalizedMerchant category weights must sum to 1
fraud-typology-shares-not-normalizedTypology shares must sum to 1
fraud-rate-out-of-boundsfraud.target_rate must be between 0 and 0.5
dormancy-not-satisfiabledormancy_days must be less than clock.days
imperfection-rate-out-of-boundsEvery imperfection rate must be between 0 and 0.2
imperfection-sink-not-declaredAn imperfection's sinks must name declared sinks
clock-skew-source-not-declaredA clock-skew source must name a declared sink
locale-pack-not-foundlocale must be a shipped name pack

Warnings

Warnings do not block a run.

CodeMeaning
population-above-reference-scaleMore than 200,000 consumers or 5,000 merchants. Generation works, but is outside the benchmarked range.
stream-tps-above-benchmarkthen_stream_tps above 1,000. Delivery at that rate is not covered by the published benchmark.

Ways to validate

  • Studio: errors appear inline in the editor as you type
  • CLI: txloom validate spec.json
  • API: POST /api/v1/spec/validate with { "spec": { ... } }
  • MCP: the validate_spec tool

The JSON Schema itself is served at GET /api/v1/spec/schema.


Sizing a Scenario

The launch drawer and POST /api/v1/spec/estimate report the expected number of history events, partitions and generation time before you launch.

As a reference point, the UPI template (5,000 consumers, 400 merchants, 90 days) produces about 1.3 million history events.

Prev
Configuration