SDKs
Kavach SDKs for 12 languages. Every one has the same three pieces, records to the same recorder and replays through the same CLI.
| Language | Requires | Dependencies | Page |
|---|---|---|---|
| Go | Go 1.23+ | none | Go |
| Python | Python 3.10+ | standard library only | Python |
| TypeScript / JavaScript | Node 22+ (ESM) | none | TypeScript |
| Rust | Rust 1.75+, Unix | none | Rust |
| Java | Java 21+ | JDK only | Java |
| C and C++ | C11 / C++17, POSIX | libc, pthreads | C and C++ |
| Ruby | Ruby 3.1+ | none | Ruby |
| PHP | PHP 8.2+, CLI workers | none | PHP |
| Elixir | Elixir 1.15+ | standard library only | Elixir |
| Haskell | GHC 9.4+ | boot packages only | Haskell |
| OCaml | OCaml 5.1+ | compiler distribution only | OCaml |
| Julia | Julia 1.10+ | standard library only | Julia |
No SDK for your language? An SDK is a thin wrapper over two small protocols. See Integrate without an SDK.
The same shape everywhere#
Every SDK has three pieces:
- A handler, called once per input. It reads the clock, random bytes, external systems and config, and emits its effects, only through the env it is given.
- A recorder that wraps your consume loop: one
stepper input, with effects delivered after the step succeeds. It startskavach-recorderas a child process (from$KAVACH_RECORDER, elsePATH). - A host mode: when the program is started with
kavach-hostas its last argument, it serves replays to the CLI instead of consuming. One call at the top ofmaindoes this.
Optionally, a handler can provide snapshots (snapshot / restore), so fixtures start from recent state, and invariants, checked after every step, live and in replay.
The env#
| Purpose | Go | Python | TypeScript |
|---|---|---|---|
| Clock | env.Now() |
env.now(), env.now_ns() |
env.now(), env.nowNanos() |
| Random bytes | env.Read(buf) |
env.random(n) |
env.random(n) |
| External query | env.Query(gw, req) |
env.query(gw, req) |
await env.query(gw, req) |
| Config / flag | env.Config(key) |
env.config(key) |
env.config(key) |
| Effect | env.Emit(sink, data) |
env.emit(sink, data) |
env.emit(sink, data) |
Failures are recorded the same way#
| The handler | Marker | Message compared on replay |
|---|---|---|
| panics / throws | panic |
the panic value or ErrorName: message; the stack is marker data |
| returns an error | error |
the error's message |
| ends ok but an invariant fails | invariant |
the invariant's name |
dies mid-step (killed, out of memory, abort) |
crash |
written by the recorder, which sees the pipe close |
Keep paths, line numbers and addresses out of failure messages; they belong in marker data, which is not compared.
Every SDK passes the same conformance suites#
Each SDK passes the host-protocol transcripts and recorder cases in the Kavach repository's spec/ directory. Those suites are the contract: a fixture recorded by one SDK replays through the same CLI as any other, and verdicts mean the same thing in every language.
Every SDK ships the demo#
Each SDK includes a port of the quickstart ledger with the same "amount": null bug, and a flag (--fix or --fixed) that selects the fixed handler. Behaviour is always chosen by flag, never by environment variable, because environment values are served from the fixture on replay.
Something wrong or missing on this page? Report it on GitHub, or write to hello@thekavachlabs.com.