# 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](https://www.thekavachlabs.com/docs/sdks/go) |
| Python | Python 3.10+ | standard library only | [Python](https://www.thekavachlabs.com/docs/sdks/python) |
| TypeScript / JavaScript | Node 22+ (ESM) | none | [TypeScript](https://www.thekavachlabs.com/docs/sdks/typescript) |
| Rust | Rust 1.75+, Unix | none | [Rust](https://www.thekavachlabs.com/docs/sdks/other-languages#rust) |
| Java | Java 21+ | JDK only | [Java](https://www.thekavachlabs.com/docs/sdks/other-languages#java) |
| C and C++ | C11 / C++17, POSIX | libc, pthreads | [C and C++](https://www.thekavachlabs.com/docs/sdks/other-languages#c-and-c) |
| Ruby | Ruby 3.1+ | none | [Ruby](https://www.thekavachlabs.com/docs/sdks/other-languages#ruby) |
| PHP | PHP 8.2+, CLI workers | none | [PHP](https://www.thekavachlabs.com/docs/sdks/other-languages#php) |
| Elixir | Elixir 1.15+ | standard library only | [Elixir](https://www.thekavachlabs.com/docs/sdks/other-languages#elixir) |
| Haskell | GHC 9.4+ | boot packages only | [Haskell](https://www.thekavachlabs.com/docs/sdks/other-languages#haskell) |
| OCaml | OCaml 5.1+ | compiler distribution only | [OCaml](https://www.thekavachlabs.com/docs/sdks/other-languages#ocaml) |
| Julia | Julia 1.10+ | standard library only | [Julia](https://www.thekavachlabs.com/docs/sdks/other-languages#julia) |

No SDK for your language? An SDK is a thin wrapper over two small protocols. See [Integrate without an SDK](https://www.thekavachlabs.com/docs/sdks/no-sdk).

```callout
note | Installing SDKs
The SDKs are not yet published to package registries. Install them from a checkout of the Kavach repository: each page shows the path. The Go SDK is a regular Go module.
```

## The same shape everywhere

Every SDK has three pieces:

1. **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.
2. **A recorder** that wraps your consume loop: one `step` per input, with effects delivered after the step succeeds. It starts `kavach-recorder` as a child process (from `$KAVACH_RECORDER`, else `PATH`).
3. **A host mode**: when the program is started with `kavach-host` as its last argument, it serves replays to the CLI instead of consuming. One call at the top of `main` does 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](https://www.thekavachlabs.com/docs/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.

Source: https://www.thekavachlabs.com/docs/sdks
