# Rastok documentation > Rastok is an open-source (Apache-2.0) integration platform written in Rust. An integration is written as a typed, declarative graph in a `.rkg` file: Operators transform data without side effects, Connectors talk to external systems under typed Contracts with declared outcomes, and the wiring, instances and bounded loops are checked by the compiler (`rastok check`). The same file holds the Lab: scenarios that script partner replies, faults and logical time, run deterministically on one machine without any external system (`rastok simulate`), and compared to sealed reference traces. The same program runs against real systems through Drivers (`rastok run`); every run leaves a causal journal that can be recorded and replayed without repeating its effects (`rastok replay`). Current public release: v0.2.0-alpha; the CLI installs from crates.io or the release archives (see Getting Started). Source revision: v0.2.0-alpha. ## Vocabulary - Graph: the application, a typed program of Nodes and explicit wiring, checked by the compiler before any run. - Operator: a Node that transforms and decides without touching the outside; Connector: the only Node that talks to an external system, under a typed Contract with declared outcomes. - Lab: the simulated world written in the same source file; scenarios inject inputs, script partner replies and faults, and advance logical time by instruction. - App: the same checked program run against real systems through Drivers, without a rewrite. - Journal: typed causal records of a run that link each output to the decision and input that caused it; a Lab scenario produces the same records on another machine, byte for byte. - Files: `.rkg` source, `.rkp` plan package, `.rkc` causal reference trace (golden), `.rkr` diagnostic recording replayed without Driver I/O. ## Minimal program The complete file that `rastok new starter` writes: one App graph with typed ports, one Operator with a handler, and a Lab with one scenario. No Connector, no external system. `rastok check starter.rkg` accepts it and `rastok simulate starter.rkg` prints `PASS starter.roundtrip_greeting`. Start from it rather than from the grammar. ```rkg graph starter : App { input in: string output out: string operator greet { input in: string output out: string on in { out = "Hello, " + data } } in -> greet -> out } lab starter { scenario roundtrip_greeting { app.in = "world" expect app.out == "Hello, world" } } ``` ## General - [Overview](https://docs.rastok.com/index.md): What Rastok is, what it is for and how it works: a situation every integration team knows, one file that outlives the project, one plan for two worlds, and a journal that explains every run. - [Getting Started](https://docs.rastok.com/getting-started.md): Install the current Rastok CLI, create a typed graph with a Lab scenario, and inspect a simulation without external services. - [The debugger, a guided tour](https://docs.rastok.com/debugger.md): Read a simulation or a recorded execution through its source, transitions, envelopes and assertions. - [AI Agents](https://docs.rastok.com/ai-agents.md): Read the documentation, the examples and their reference traces from a coding assistant through Markdown twins, llms.txt, content negotiation and the agent index. - [Migrating from 0.1 to 0.2](https://docs.rastok.com/migration.md): Port a 0.1 graph, handle missing values and check its scenarios against your existing reference traces. ## User Guide - [A program](https://docs.rastok.com/guide/01-a-program.md): Read a complete Rastok program by separating its Graph, Operators, Connectors, wiring and Lab. - [Types and expressions](https://docs.rastok.com/guide/02-types-and-expressions.md): Follow typed payloads through guards, narrowing and pure expressions without confusing text, bytes or decoded JSON. - [Connectors and outcomes](https://docs.rastok.com/guide/03-connectors-and-outcomes.md): Read a Connector Contract, choose a supported mode, and route data and terminal outcomes explicitly. - [The Lab: scenarios, mocks and time](https://docs.rastok.com/guide/04-the-lab.md): Describe inputs, boundary outcomes and elapsed time as executable scenarios while keeping the application graph unchanged. - [Running for real](https://docs.rastok.com/guide/05-running-for-real.md): Move from scripted outcomes to physical Drivers while keeping deployment settings, secrets, evidence and alpha limits explicit. - [Instances, state and time](https://docs.rastok.com/guide/06-instances-state-and-time.md): Choose the owner of state, separate instance keys from lifetimes, and make closure and bounded waiting explicit. - [Loops and retries: bounded recurrence](https://docs.rastok.com/guide/07-loops-and-retries.md): Separate authored state progression from safe repetition of one prepared Call, with explicit bounds, delays and terminal outcomes. - [Privacy, secrets and measurements](https://docs.rastok.com/guide/08-privacy-secrets-and-measurements.md): Classify typed data, bind credentials outside the graph, and retain exact business quantities on their original responses. - [Command line](https://docs.rastok.com/guide/09-command-line.md): Choose a Rastok command, supply its options, and distinguish read-only checks from real execution and file writes. - [When the answer is lost](https://docs.rastok.com/guide/10-when-the-answer-is-lost.md): Read a Call terminal, distinguish a lost answer from a refused operation, and choose what to tell the caller. ## Examples - [Echo: one graph, two worlds](https://docs.rastok.com/examples/01-echo.md): Run one graph with a real cat process or scripted Lab responses, then inspect a recording without starting the process again. - [File pipeline: effects with a contract](https://docs.rastok.com/examples/02-file-pipeline.md): Read a bounded file, reject an empty input, count its bytes and atomically replace a second file, then replay without disk access. - [Two tenants: whose state is this?](https://docs.rastok.com/examples/03-two-tenants.md): Watch Bob finish once while Alice alone times out, waits for backoff and retries in an isolated keyed instance. - [Webhook to partner: put it together](https://docs.rastok.com/examples/04-webhook-to-partner.md): Admit a webhook, validate and deduplicate it, then exercise bounded partner retries with privacy, secret and cost evidence. - [Sensor alarm: make time an input](https://docs.rastok.com/examples/05-sensor-alarm.md): Isolate hysteresis state by sensor, detect a missed heartbeat with a bounded join, and advance through a virtual day without waiting a day. - [Agent gateway: keep a conversation isolated](https://docs.rastok.com/examples/06-agent-gateway.md): Connect WebSocket conversations to resident JSONL processes, simulate interleaved app-server requests, and close one child without interrupting the other. - [Countdown: a bounded loop](https://docs.rastok.com/examples/07-countdown.md): Prove that a countdown terminates, follow its manager commands, and see the checker reject a measure that cannot prove progress. - [HTTP model adapter: typed responses and token metering](https://docs.rastok.com/examples/08-model-adapter.md): Select a typed view of an OpenAI Responses result, retain original token measurements by job and session, and distinguish absent usage from an observed zero. ## Reference - [Authoring rules](https://docs.rastok.com/reference/authoring-rules.md): Short examples of what check refuses or warns about, what to write, and where to find the rule. - [Types and schemas](https://docs.rastok.com/reference/types.md): Logical types, literal forms and the loss-checked JSON Schema, Avro, Arrow and OpenAPI projections shipped in the alpha. - [Expressions and dispatch](https://docs.rastok.com/reference/expressions.md): Operator precedence, built-in functions, narrowing, transaction dispatch and envelope writes accepted by the compiler. - [Standard contracts](https://docs.rastok.com/reference/contracts.md): Contract identities, modes, ports, terminal cases, settings and Lab support from the executable Connector catalogue. - [The Lab](https://docs.rastok.com/reference/lab.md): Executable Lab declarations, mock responses, scenario actions, observation windows and golden-trace commands. - [Diagnostics](https://docs.rastok.com/reference/diagnostics.md): Compiler error codes, their trigger, the source change to make, and message excerpts from exercised refusals. - [Standard library](https://docs.rastok.com/reference/stdlib.md): Find the types, Connector Contracts, annotations and value frontends supplied with Rastok. - [Execution and concurrency](https://docs.rastok.com/reference/execution.md): Distinguish instance ownership, concurrent external I/O and the execution model implemented by the current runtime. - [File](https://docs.rastok.com/reference/connectors/file.md): Ports, terminal outcomes, settings and qualification evidence for the File connector. - [Process](https://docs.rastok.com/reference/connectors/process.md): Ports, terminal outcomes, settings and qualification evidence for the Process connector. - [HttpClient](https://docs.rastok.com/reference/connectors/http-client.md): Ports, terminal outcomes, settings and qualification evidence for the HttpClient connector. - [HttpServer](https://docs.rastok.com/reference/connectors/http-server.md): Ports, terminal outcomes, settings and qualification evidence for the HttpServer connector. - [WebSocketClient](https://docs.rastok.com/reference/connectors/websocket-client.md): Ports, terminal outcomes, settings and qualification evidence for the WebSocketClient connector. - [WebSocketServer](https://docs.rastok.com/reference/connectors/websocket-server.md): Ports, terminal outcomes, settings and qualification evidence for the WebSocketServer connector. ## Specification - [Grammar](https://raw.githubusercontent.com/rastok-io/rastok/v0.2.0-alpha/docs/spec/grammar.md): the normative `.rkg` grammar, raw Markdown at revision v0.2.0-alpha. - [Specification index](https://raw.githubusercontent.com/rastok-io/rastok/v0.2.0-alpha/docs/spec/README.md): every specification chapter: expressions, instances, Loop, Retry, effects, simulation semantics, diagnostics, raw Markdown at revision v0.2.0-alpha. - [White paper](https://raw.githubusercontent.com/rastok-io/rastok/v0.2.0-alpha/WHITEPAPER.md): the design and its rationale, with the executable scope of the current alpha, raw Markdown at revision v0.2.0-alpha. ## Example sources Complete `.rkg` programs served as plain text, each with its Lab in the same file. Validate a copy with `rastok check ` and run its scenarios with `rastok simulate `. - [agent-chat](https://docs.rastok.com/examples/agent-chat.rkg) - [agent-dialogue](https://docs.rastok.com/examples/agent-dialogue.rkg) - [Agent gateway: keep a conversation isolated](https://docs.rastok.com/examples/agent-gateway.rkg): Connect WebSocket conversations to resident JSONL processes, simulate interleaved app-server requests, and close one child without interrupting the other. Chapter: https://docs.rastok.com/examples/06-agent-gateway.md - [HTTP model adapter: typed responses and token metering](https://docs.rastok.com/examples/agent-http.rkg): Select a typed view of an OpenAI Responses result, retain original token measurements by job and session, and distinguish absent usage from an observed zero. Chapter: https://docs.rastok.com/examples/08-model-adapter.md - [Countdown: a bounded loop](https://docs.rastok.com/examples/countdown.rkg): Prove that a countdown terminates, follow its manager commands, and see the checker reject a measure that cannot prove progress. Chapter: https://docs.rastok.com/examples/07-countdown.md - [csv-count](https://docs.rastok.com/examples/csv-count.rkg) - [Echo: one graph, two worlds](https://docs.rastok.com/examples/echo.rkg): Run one graph with a real cat process or scripted Lab responses, then inspect a recording without starting the process again. Chapter: https://docs.rastok.com/examples/01-echo.md - [File pipeline: effects with a contract](https://docs.rastok.com/examples/file-pipeline.rkg): Read a bounded file, reject an empty input, count its bytes and atomically replace a second file, then replay without disk access. Chapter: https://docs.rastok.com/examples/02-file-pipeline.md - [gauge](https://docs.rastok.com/examples/gauge.rkg) - [jsonl](https://docs.rastok.com/examples/jsonl.rkg) - [Two tenants: whose state is this?](https://docs.rastok.com/examples/keyed-retry.rkg): Watch Bob finish once while Alice alone times out, waits for backoff and retries in an isolated keyed instance. Chapter: https://docs.rastok.com/examples/03-two-tenants.md - [Sensor alarm: make time an input](https://docs.rastok.com/examples/sensor-alarm.rkg): Isolate hysteresis state by sensor, detect a missed heartbeat with a bounded join, and advance through a virtual day without waiting a day. Chapter: https://docs.rastok.com/examples/05-sensor-alarm.md - [Webhook to partner: put it together](https://docs.rastok.com/examples/webhook-to-partner.rkg): Admit a webhook, validate and deduplicate it, then exercise bounded partner retries with privacy, secret and cost evidence. Chapter: https://docs.rastok.com/examples/04-webhook-to-partner.md