Skip to content

Reference

Rules

Rules bend individual responses so you can prove your integration survives the failures real vendors produce and sandboxes never do.

Matching

Each rule has a method (or *) and a pathPattern. The pattern matches the request path with * wildcards, or equals the spec path template exactly (for example /tasks/{task_gid}). Rules are evaluated in priority order; latency rules accumulate, a drift rule changes the reply a request was really served, and the first fixed, error, conditional, chaos or fault rule that applies decides the response.

Config fieldUsed byMeaning
statusfixed, error, conditional, chaosHTTP status to return.
bodyfixed, error, conditional, chaosJSON body. Optional for errors.
headersallExtra response headers. Content-Type, Set-Cookie, Location and CSP cannot be overridden.
probabilityany0 to 1. The rule only applies to this share of requests.
latencyMslatencyAdded delay in milliseconds (total capped at 30 seconds).
latencyJitterMslatencyRandom extra delay between 0 and this value.
perRpslatency{ thresholdRps, addMsPerRps, maxMs }: slower under load (see Slower under load).
whenanyCondition on query, header or body: key plus equals or exists.
faultfaultreset, empty, malformed, not_json, partial_page or committed_error: the failure to produce.
driftdriftA list of 1 to 20 changes to a successful JSON reply: remove, rename, retype, add, unknown_value (see drift).
failFirstfixed, error, conditional, chaos, fault1 to 1,000. The rule applies to the first N matching requests, then stops (see Fail, then recover).
expireAftererror1 to 100,000. A credential that expires: the first N requests of each credential pass, then that credential is refused (default 401, in the vendor's error shape, with WWW-Authenticate invalid_token) until a different one is used, so only a real token refresh recovers. Slurry-Force: token_expired gives the same reply once. Not with failFirst or passFirst.
passFirstfixed, error, conditional, chaos, fault1 to 10,000. The first N matching requests pass, then the rule applies: fail on the third page. Not with failFirst.
seedchaos, error, fault, latency1 to 64 letters, digits, ".", "_" or "-". Its probability and jitter draws repeat the same way every run instead of being random (see Repeatable faults).
Rules are created with POST /v1/simulations/{id}/rules, the MCP add_rule tool, or the Rules tab in the dashboard. Responses always stay JSON, whatever a rule says; the only exception is the not_json fault, which sends a fixed line of plain text, never your content.

Why did my rule not fire?

Describe a request and Slurry shows the operation it reaches and every rule in priority order: matches, chance (it has a probability), or why not: disabled, pending_review, expired, method, path, when (with the condition), collection, pass_first or fail_first_used. It names the rule that would answer (decides), chance rules that might answer first (mayDecide) and latency rules that add delay. Nothing is served, logged or counted, so a failFirst rule still fires on your next real request; pass session to see what is left for one Slurry-Session. Counts belong to the engine that serves your simulation. delays says what each delay rule adds (latencyMs, jitterMs, and for a latency rule with perRps how the delay grows with the request rate: explain measures no rate, so the delay at the time is not shown), and drift lists the rules that would change the reply.

terminal
slurry rules explain acme-jira POST /rest/api/3/issue --body '{"fields":{"summary":"x"}}' --session run-42

Over the API: POST /v1/simulations/{id}/rules/explain with { method, path, headers?, body?, session? } (the body at most 64 KB, at most 50 headers; none of it is kept). MCP: explain_rules.

Rules that can never fire

A rule set built up over many runs collects rules that can never fire, and every test that relies on one is weaker than it looks. Lint lists every rule with a verdict: ok, or disabled, pending_review, expired, no_operation (its method and path reach no operation in the API's spec), method (the operations it reaches take other methods), collection (none of them is on its collection) or shadowed (an earlier rule that always answers, with no condition, chance or count, takes every request it would match). It reads the rules and the spec only. Microsoft Graph, Jira and DocuSign serve paths beyond their spec, so their rules are checked for everything but operations. A lint counts towards the 20 expensive calls a minute, with creates and fast-forwards. With --strict the command exits 1 when any rule is not ok.

terminal
slurry rules lint acme-jira --strict

Over the API: GET /v1/simulations/{id}/rules/lint. MCP: lint_rules.

Which rules a run hit

A fault rule your system never reached has tested nothing, and the run still passes. After a run, rule coverage reads the request log for one Slurry-Session (or a since and before window) and lists, per rule, the calls that hit it and the statuses served, and the rules no call hit, with why when a rule is disabled, pending_review or expired. With requireAll it fails when any rule that could have fired was not hit: a disabled or held rule is excused, a temporary rule that ran out unhit is not (unless it expired before since), and a temporary rule already removed is best named in require; with require it fails when a named rule (by name or id) was not. With neither it is a report. The log names one rule per call: the rule that decided it, otherwise the first delay rule, otherwise a drift rule that changed the reply, so a delay or drift rule is not counted on a call another rule decided. It reads the newest 5,000 calls that name a rule; past that a gate fails unless allowPartial.

terminal
slurry rules coverage acme-jira --session run-42 --all

Over the API: POST /v1/simulations/{id}/rules/coverage. MCP: rule_coverage.

Repeatable faults

Probability, latency jitter and the simulation error rate are random, so a run that failed on a random fault cannot be replayed. Send Slurry-Seed: run-42 (1 to 64 letters, digits, ., _ or -) on your requests and every draw becomes a function of the seed, the simulation, the operation and how many earlier requests with that seed reached the same operation: the same calls in the same order meet the same faults and the same delays. Each reply to a seeded request carries x-slurry-seed-draw, its place in that operation's sequence. A rule's own config.seed does the same for requests without the header, counted per rule; the header wins. Sequences start again when the simulation is reset (and when the engine restarts); each simulation keeps up to 32 recent sequences. A rule's passFirst count is not part of the sequence. An invalid header is ignored. Without a seed nothing changes.

Slower under load

Real vendor APIs slow down when a client hammers them, and an agent that fans out fifty calls at once should feel it. A latency rule with config.perRps measures how many requests it matched in the last 5 seconds, per Slurry-Session (one shared count without one), and over thresholdRps requests a second adds addMsPerRps milliseconds for each request a second above it, at most maxMs. A trickle is served at the rule's usual delay; a burst gets slower and slower up to the cap. Each slowed reply says what was added in x-slurry-rate-latency, for example 400ms at 9.0/s. The total delay is still capped at 30 seconds.

terminal
slurry rules add acme-jira --latency-per-rps 5:100:3000 --data '{"name":"busy","kind":"latency","pathPattern":"/rest/api/3/**","config":{}}'

Over the API or MCP add_rule: "config": { "perRps": { "thresholdRps": 5, "addMsPerRps": 100, "maxMs": 3000 } }. Rates are kept by the engine process, like failFirst counts, and start again when the simulation is reset.

Fail, then recover

The commonest retry test is "fail twice, then work". With config.failFirst a rule applies to the first N matching requests and then stops, so the test passes the same way every time, with no probability and no removing the rule part way. It works on error, chaos, fault, fixed and conditional rules. passFirst is the other direction, and a rule takes one or the other.

terminal
slurry rules add acme-jira --fail-first 2 --data '{"name":"retry test","kind":"error","config":{"status":503}}'

Each Slurry-Session gets its own count, so parallel runs on one simulation do not use up each other's failures; without one there is one shared count. A client that sends a new session on every request therefore fails every time. passFirst has one count per rule, across sessions. With a probability, only requests that draw a failure count. Resetting the simulation or adding the rule again restarts the count. Counts are kept by the engine process, so a restart of Slurry restarts them too.

To get the first failure back without wiping the records, start the counts again: every counted rule of the simulation (failFirst, passFirst, expireAfter and the request rates behind perRps), or one rule with rule. That makes one simulation serve several test cases, each meeting the failure from the start. seeds: true also restarts the seeded sequences, as a reset does; it is off by default because a run half way through a seeded sequence would change under it, and it cannot be combined with rule.

terminal
slurry rules reset-counts acme-jira

Over the API: POST /v1/simulations/{id}/rules/reset-counts with an optional { rule, seeds }. MCP: reset_rule_counts.

Wrong method: 405 or 404

Most REST vendors answer a path they have, called with a method it does not take, with 405 Method Not Allowed and an Allow header; some answer 404. Turn this on and the simulation answers 405 in the vendor's error shape with Allow listing the methods the path takes, and x-slurry-reason: method_not_allowed, so a client can tell a wrong verb from a wrong path. Off by default: a wrong method is 404, as before. A path the API does not have stays 404, and RPC-style methods that take GET or POST still work.

terminal
slurry sims method-not-allowed acme-orders on
curl -X PUT $SIM/orders  # 405, Allow: GET, POST

Over REST: GET and PUT /v1/simulations/{id}/method-not-allowed with { "on": true }. Over MCP: get_method_not_allowed and set_method_not_allowed.

Idempotency-Key

A committed_error makes a write land while the client is told it failed. A correct client retries with the same Idempotency-Key, and a vendor that honours the key answers with the first reply and writes nothing. Turn this on and a simulation does the same, so the test can tell a correct client from a broken one: one record against two. Off by default, so a simulation that does not ask for it ignores the header.

terminal
slurry sims idempotency acme-orders on
slurry rules add acme-orders --data '{"name":"double write","kind":"fault","method":"POST","config":{"fault":"committed_error"}}'

Over REST: GET and PUT /v1/simulations/{id}/idempotency with { "on": true }. Over MCP: get_idempotency and set_idempotency. It covers POST and PATCH, with a key of 1 to 255 printable characters.

RequestAnswer
First use of a keyServed as usual. The real reply is kept, before any committed_error replaces what the client is told.
Same key, same method, path and bodyThe kept reply, with Idempotent-Replayed: true. No write, no event, no webhook. Logged as a normal request and counted.
Same key, a different request400 with the vendor's error body, and x-slurry-error: idempotency_key_reused.
Same key while the first is being served409 with the vendor's error body, and x-slurry-error: idempotency_in_progress.
A request refused or failed (a rule, a dropped connection, a reply of 400 or over)Nothing is kept, so a retry is a first use.
A first reply over 256 KB, or a fileServed, not kept. A retry gets a 409 with x-slurry-error: idempotency_reply_not_stored and writes nothing.
More than 10,000 live keys in the simulationServed without keeping a key, with x-slurry-idempotency: not_stored, also when a committed_error answers in place of the real reply.

Keys last 24 hours and are kept only as a hash; the reply a retry gets is kept with them, also when logBodies is off. Resetting a simulation, restoring a snapshot or turning the setting off clears them. A fork inherits the setting and starts with no keys. Calls through a simulation's MCP server send no key.

Read lag

On many vendors a write is acknowledged before lists and search can see it. An agent that creates a record, lists to confirm it, and creates it again on a miss writes duplicates in production and passes against a simulation that is always consistent. Set a read lag and a record created through the simulated API stays out of lists and SOQL for that many seconds; the reply carries x-slurry-read-lag with how many records were created in the window. Seeded records and updates never lag, and the management API, verify_state and the state diff always see the truth. With scope list_and_get, a GET of the record by id answers 404 as well. Vendor search views (Jira JQL, Graph, Gmail) are not covered yet.

terminal
slurry sims read-lag acme-crm 5
slurry sims read-lag acme-crm 10 --collection contacts --get
slurry sims read-lag acme-crm off

Over REST: GET, PUT and DELETE /v1/simulations/{id}/read-lag with { "seconds": 5, "collections": ["contacts"], "scope": "list" }. Over MCP: get_read_lag and set_read_lag. A fork inherits the setting.

Rules as code

Keep a simulation's rules in your repository so every CI run meets the same faults and a pull request shows when they change. slurry rules export <sim> --out slurry/rules.yaml writes them as YAML (name, kind, method, path, priority, enabled, config; no ids, and temporary rules from scenarios or a TTL are left out). slurry rules apply <sim> slurry/rules.yaml makes any simulation match the file by rule name: rules it names are added or replaced when they differ, the rest are left alone unless you add --prune. --dry-run shows the plan; a change that fails exits 1.

slurry/rules.yaml
rules:
  - name: Jira is down
    kind: error
    pathPattern: /rest/api/3/**
    config: { status: 503 }
  - name: flaky search
    kind: chaos
    method: GET
    pathPattern: /rest/api/3/search
    config: { status: 502, probability: 0.3, seed: ci }

Kinds

Every kind takes a name, a method, a path pattern and a config. A config is at most 200 KB as JSON (a fixed body at most 100 KB of it) and 32 levels deep; a NUL character anywhere in a rule is refused with a 400 naming the field, and half a surrogate pair is stored as U+FFFD, as in records.

fixed

Always return this status and body. Useful for pinning an awkward edge case, such as an empty page or a deprecated field.

POST /v1/simulations/{id}/rules
{
  "name": "Empty project list",
  "kind": "fixed",
  "method": "GET",
  "pathPattern": "/projects",
  "config": { "status": 200, "body": { "data": [], "next_page": null } }
}

error

Fail with a status, some of the time. Leave out body and Slurry builds an error in the API's own error shape. A 429 adds Retry-After: 30 unless you set headers.

POST /v1/simulations/{id}/rules
{
  "name": "Rate limited writes",
  "kind": "error",
  "method": "POST",
  "pathPattern": "/tasks",
  "config": { "status": 429, "probability": 0.2 }
}

latency

Add delay, with random jitter on top. Latency rules stack with each other and with other rules, so you can combine a slow response with an error. latencyMs and latencyJitterMs are numbers from 0 to 30000 (a string holding one is taken); anything else is refused with a 400 naming the field, as is a status that is not a whole number from 100 to 599. The total delay of a request is at most 30 seconds.

POST /v1/simulations/{id}/rules
{
  "name": "Slow search",
  "kind": "latency",
  "method": "GET",
  "pathPattern": "/workspaces/*/tasks/search",
  "config": { "latencyMs": 2500, "latencyJitterMs": 1500 }
}

conditional

Return a fixed response only when the request matches. when.source is query, header or body; match with equals or exists.

POST /v1/simulations/{id}/rules
{
  "name": "Archived projects are forbidden",
  "kind": "conditional",
  "method": "GET",
  "pathPattern": "/projects",
  "config": {
    "when": { "source": "query", "key": "archived", "equals": "true" },
    "status": 403,
    "body": { "errors": [{ "message": "Not authorised to view archived projects" }] }
  }
}

chaos

A low-probability failure across a wide pattern, for soak tests. Behaves like error, intended for broad paths and small probabilities.

POST /v1/simulations/{id}/rules
{
  "name": "Background turbulence",
  "kind": "chaos",
  "method": "*",
  "pathPattern": "*",
  "config": { "status": 502, "probability": 0.02 }
}

fault

A broken connection or reply instead of a clean HTTP error, for the parsing and retry code a 503 never reaches. config.fault is reset (the connection closes with no response; through Slurry's edge proxy your client may see a 502 instead), empty (the success status with an empty body), malformed (the real JSON cut off part way) or not_json (a plain-text proxy error). partial_page is the quiet one: a list reply keeps its status, its totals and its paging links but loses the second half of its rows, the largest list of records within two levels of the top, and says so only in an x-slurry-fault: partial_page header; a sync that never checks what it got against what it was told drops data without an error. A single record, an error or a raw file is served as it was, and so is any reply that is one object, such as /me or a record holding several lists of its own (a contact with its addresses and phone numbers): only a reply that is an array, or holds exactly one list, counts as a page. Apart from reset, the request is served first, so a write happens even though its reply is broken: did it go through or not? committed_error is the classic double write: the request is served, change events and webhooks fire, and the client gets an error in the vendor's shape, config.status from 500 to 599, default 503. A retry then makes a second record unless the client guards against it; verify_state shows which. A request that fails anyway keeps its own answer, because nothing landed. All six work once with the Slurry-Force header (committed_error_504 for another status).

POST /v1/simulations/{id}/rules
{
  "name": "Flaky network on issue creation",
  "kind": "fault",
  "method": "POST",
  "pathPattern": "/rest/api/3/issue",
  "config": { "fault": "malformed", "probability": 0.2 }
}

drift

A successful JSON reply changed as a vendor change would change it, so a test shows whether your integration copes before the vendor does it. The request is served as usual and the stored records never change. config.drift lists 1 to 20 changes: remove a field, rename it (to is the new name), retype it (to is string, number, boolean, null, array or object), add a new one (value "slurry_drift"; at names a field whose objects get it, default the top level or each item of a list reply), or unknown_value (a string field becomes SLURRY_UNKNOWN_VALUE). field is a name matched at any depth, or a dotted path from the top (fields.assignee.displayName), and arrays are walked through. A name the rule puts into replies (the new name of a rename, the field of an add) is a single name of at most 64 characters. A rule that decides the reply, a fault, Slurry-Force or a refusal wins, and a reply of 300 or over is never changed. The first drift rule to match applies, and the reply carries x-slurry-drift with its id. passFirst makes the vendor change part way through a run. From the CLI: slurry rules add --drift remove:assignee,rename:summary=title.

POST /v1/simulations/{id}/rules
{
  "name": "Assignee gone, summary renamed",
  "kind": "drift",
  "pathPattern": "/rest/api/3/**",
  "config": { "drift": [
    { "op": "remove", "field": "assignee" },
    { "op": "rename", "field": "summary", "to": "title" },
    { "op": "retype", "field": "id", "to": "number" }
  ] }
}