ThrottleKit ships twoDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/AmeyaBorkar/throttlekit/llms.txt
Use this file to discover all available pages before exploring further.
@experimental opt-in subpaths for pre-deployment validation: throttlekit/testkit
provides a deterministic decision recorder and replayer, and throttlekit/policy builds on it to
give you a terraform plan-style decision diff between your current and candidate policy sets. Both
are excluded from the 1.x SemVer guarantee — pin an exact version if you depend on their exact shapes.
throttlekit/testkit
recordLimiter
Wrap a leaf limiter — built deterministically from aLimiterSpec — and record every synchronous
decision into a bounded ReplayTrace. The recording limiter is constructed the same way replay
does (MemoryStore, sweepIntervalMs: 0, shared ManualClock), so a recording and its replay
start from the same cold state and evolve identically.
Declarative limiter spec (strategy name + options). The
LimiterSpec type is from
throttlekit/config. Only leaf-rate limiters are replayable.The
ManualClock the recording is driven by — advance it between checks to simulate arrivals.
Default: a fresh ManualClock(0), exposed as Recording.clock. Must be a ManualClock.Key prefix for the underlying limiter.
Config name for error context and labelling. Default
"recorded".Cap on recorded steps. At the cap, recording stops appending: the kept prefix stays a faithful
recording but the trace is flagged
truncated and replay refuses it. Default 1_000_000.Redact each key at capture so the trace stores only redacted keys. A redaction that maps two
distinct keys to the same value throws a
ReplayRefusedError. Default: identity (no redaction).The recording limiter. Call
checkSync / checkManySync; each decision appends a step at the
clock’s current instant. check, checkMany, and reset are refused (not_implemented).The
ManualClock driving the recording. Advance it to simulate arrivals.Snapshot the immutable
ReplayTrace recorded so far.runStoreConformance
Register the store-conformance suite underdescribe(name). Any Store implementation passes
when this suite is green.
throttlekit/policy
policy
Build onePolicy from a declarative leaf LimiterSpec. Validates the spec eagerly via
buildStrategy — an unbuildable leaf throws here.
Non-empty policy name. Used as the corpus key.
Declarative limiter spec (strategy name + options from
throttlekit/config).policySet
Assemble a content-addressedPolicySet from an array of Policy objects. Refuses duplicate names.
Array of named policies. All names must be unique.
Human-readable label for this set (e.g.
"production", "v2-candidate").Non-replayable axes (concurrency / escrow / joint-LP) that exist operationally but cannot be
diffed. Listed in the plan as
"not-replayable" rather than silently omitted.policySetFromConfig
Build aPolicySet from throttlekit/config YAML or JSON text. Reads the limiters map as
declarative specs — no live store needed, safe to run in CI.
Config file contents as a string (YAML or JSON, auto-detected).
Human-readable label.
Force a format. Default: auto-detect (text starting with
{/[ is JSON, else YAML).plan
Replay recorded traffic against both the current and candidate policy sets and return the exact per-policy, per-key allow↔deny decision diff.The currently deployed policy set. Used as the baseline.
The proposed policy set. Diff target.
The recorded traffic to replay. Built from
corpusFromRecordings or corpusFromTraces.renderPlan
Render aPlan as a human-readable string for CLI output.
assertPlanAcceptable
Assert that aPlan passes configured thresholds — the CI gate. Throws PlanRejectedError
(a ThrottleKitError with code: "config_invalid") when thresholds are exceeded.
Maximum allow→deny flips permitted (newly blocked traffic). Default
0.Maximum deny→allow flips permitted (newly admitted traffic). Default
Infinity.corpusFromRecordings
Build aPolicyCorpus from a map of policy name → Recording.
POLICY_SET_FORMAT_VERSION
The current serialization format version. A serialized set from a different version is refused on parse.End-to-End Example
throttlekit/config
The config loader used internally bypolicySetFromConfig and recordLimiter. Useful for
programmatic policy management.
Absolute or relative path to a
.throttlekit.yaml or .throttlekit.json config file.