Kitlark reads like Python and is checked like a proof. It is a zero trust programming language: a program holds no authority of its own, every function is pure, and the runtime owns every crossing, every piece of state and every secret. That makes it a language for modeling a whole system, from the input form to the data schema, as one closed program under one type and capability engine. What fails at run time in other stacks is refused here when the program is checked.
This page takes ten minutes. It says what is the same as Python, what differs, what Kitlark takes from Go, Rust and JavaScript, why it suits agents, and shows the checker refusing ten programs those languages accept. Every refusal on this page is the checker's own answer to the code above it.
A language for agents
An agent given a shell is fenced with allow-lists of command patterns: text matched against text, hoping no variation slips past. Kitlark gives an agent what a pattern cannot.
| A shell for an agent | Kitlark for an agent |
|---|---|
| command wildcards, matched as text | typed capabilities: each operation named, typed and granted |
| shell access to a whole machine | a Kitlark session that reaches only what the grant admits |
| any state can be written, and found in production | a closed, minimal language where a bad state cannot be represented |
| errors as free text to guess from | one diagnostic, its place and its fix |
Agents work by trying variations, and in a closed language every variation is safe to try: the
checker refuses the bad ones before anything runs. Kitlark reads like Python, so a model writes it
with ease, and where it differs the refusal says what to write. A retired form with one right
answer is rewritten for the author and answered with the rule: an f-string comes back as typed text
building, with fstring_retired and the line it changed.
Extending it: standard interfaces and hooks
Dependencies, storage and transport are open to extension, and all three extend the same way. Each is a standard interface. A provider is a program that supplies the operations of an interface, and an application reaches those operations as it reaches any other: by importing them, under its grant.
Kubernetes is extended in the same shape, which makes it a useful comparison.
| Kubernetes | Kitlark |
|---|---|
| CSI: a storage driver behind one interface | a storage provider behind the storage interface |
| CNI: a network plug-in | a transport provider |
| CRI, operators and custom resources | providers of operations and kinds |
| admission webhooks: validate or change a write on its way in | hooks: @on_write, @before, @after |
| RBAC | grants: an import is a capability request |
A hook attaches to a record or a view. It validates, refuses with a typed code or reshapes a write on its way in, and after the commit it returns effects for the runtime to perform. A hook is a pure, bounded Kitlark function, so the checker knows what it reads and writes.
The difference from Kubernetes is trust. A Kubernetes plug-in is native code the cluster trusts with wide privileges. A Kitlark provider is a checked program: its own imports are granted, it passes its interface's one conformance suite, and the application that uses it is checked against the interface, never against the provider.
Records are the built-in ORM
A Record is the whole data layer. Its fields are typed and constrained where they are declared,
and the runtime loads, validates and saves it. A program never opens a connection, starts a
transaction, flushes a session or writes a migration.
Underneath, the store is an efficient graph database kept in relational tables. A link between two records is first class, so a program follows links as fields, and the tables keep reads fast.
The runtime keeps state clean. A pure function performs no crossing and holds no transaction: it reads the records it was given and returns new ones. A turn commits once, as one changeset, so every record a move changes lands together or not at all, and no lock is held while the work runs.
| An ORM in ordinary code | Records in Kitlark |
|---|---|
| a session and a transaction, opened and closed by hand | none: a turn commits once |
| objects that change under you, lazily loaded | frozen values, given whole |
| validation in a separate layer | constraints on the field, enforced on every write |
| a query anywhere in a function | reads are declared, and the function stays pure |
Zero trust, applied to a language
A perimeter network trusts whatever is inside the wall, so everything depends on the wall and on good behaviour behind it. A zero trust network checks every request where it lands, and the result is more freedom: people work from anywhere, because order comes from construction and never from trust.
Kitlark applies the same idea to code. A Kitlark program is a set of pure functions. It cannot open a file, read a clock, hold a credential or keep state between calls. Everything that touches the world is a named crossing the runtime performs, checked against a grant. Nothing depends on the program behaving well, so a program can be loaded, edited and run by anyone the grant admits, a model included.
A language built this way describes what a system is and leaves how it runs to the runtime. Zero trust is what makes Kitlark a system modeling language.
From assembly to memory safety
Assembly moved bytes by hand. C made that portable. Decades on, garbage collection and then ownership types removed the manual free. Each step made memory safer, and each left the program where it started: holding raw authority over a machine, free to read any file and open any socket the process can.
Kitlark takes the step after memory safety. The program manipulates no memory, no handles and no machine. It states types, Processes and rules, and the runtime decides where they run.
A container guards an open program
A container runs a program that can ask the kernel for anything, and relies on the operating system to refuse what it should not have. The kernel is one of the most complicated systems ever built, with hundreds of system calls and countless combinations, so the guard is as hard to reason about as the thing it guards.
Kitlark inverts the arrangement. The language is small, and it admits pure functions only. There is no call to block, because no call exists: crossings, state and time belong to the runtime, and the author models the system and nothing else.
| A container | Kitlark | |
|---|---|---|
| The program can ask for | anything the kernel offers | only the operations it imports |
| Safety comes from | rules that block requests | a language with nothing to block |
| What is reasoned about | the kernel and its policy | the program |
One closed system, from the form to the schema
Software is usually split along its boundaries: a front end, an edge, an API aggregation layer, a back end and a database, each a separate application in its own language. The contracts between them are documents and tests. Nothing checks the front end against the back end's types when the code is written. Tests are meant to catch a break between two layers, and they do not catch every one. When they do, it is at integration, often days after the change was written. The rest are found by a person, in production.
Kitlark describes all of it as one closed system. The input form, the Process that handles it, the operations it calls and the schema it writes are declarations in one program, so one type and capability engine checks every link, and a break anywhere is a refusal when the program is checked.
A model that is the implementation
Modeling languages exist: OpenAPI and RAML describe an API, UML describes a design. Each is a description of a system, held beside the system, and at best it validates one contract point.
A description is not the implementation. Generators run one way, from the description to code, and the code is then edited by hand. When a fix starts in the schema and works its way up, the API document is the last thing to change, when it changes at all. An API that does not match its documentation is ordinary, and many API documents cannot be verified even against themselves.
A Kitlark model is the program that runs. The form, the Process, the operations and the schema are the declarations the runtime executes, so there is no second copy to drift. Documentation, examples and the playground are drawn from the running system's own recordings.
| OpenAPI, RAML, UML | Kitlark | |
|---|---|---|
| What it is | a description of the system | the system |
| What it checks | one contract point | every link, from the form to the schema |
| When code changes | the description is updated by hand, or not | there is nothing else to update |
What is the same as Python
Kitlark accepts Python's grammar, and for anything it accepts, Python's meaning applies.
| Same as Python | |
|---|---|
| Syntax | indentation, def, class, if, for, match, comprehensions |
| Values | int of any size, str, bool, None, lists and dicts in insertion order |
| Classes | fields declared by annotation, methods, inheritance, protocols |
| Types | the annotation syntax of typed Python: int, `str |
| Tooling | a Python highlighter and formatter read it unchanged |
A Python developer reads a Kitlark module on the first day.
What differs from Python
The differences all point one way: nothing implicit, nothing ambient, nothing found late.
| Python | Kitlark |
|---|---|
| Annotations are hints | Annotations are required at boundaries and enforced |
| Errors surface when a line runs | Every branch is checked before anything runs |
| Values are mutable unless frozen | Values are immutable; a change builds a new value |
| Module variables hold state | Module values are frozen at load; global does not exist |
try and except |
Failures are values: Result and match; a Process's failures are the runtime's |
f-strings and % formatting |
Typed templates: text is never built from values |
open, time, os.environ, sockets |
They do not exist; a program imports granted operations |
| Any call can do I/O | Only a stage's work names a crossing, and the runtime performs it |
What it takes from Go, Rust and JavaScript
| From | Kitlark takes |
|---|---|
| Go | explicit, predictable rules over clever inference; errors as values; small interfaces; one way to do a thing |
| Rust | Result and exhaustive match; immutability; no null that goes unchecked; safety proven before the program runs |
| JavaScript | one language in the browser and on the server: the same Kitlark module runs in the tab and on the instance |
| Phones | capabilities granted per application, the way iOS and Android grant the camera |
What it leaves behind is as deliberate: Go's zero values and droppable errors, Rust's ownership annotations (nothing is shared to own), JavaScript's implicit conversions, and every exception.
Things and Processes
Kitlark models a system with two concepts. A Thing is what the system is made of: a typed record with its fields, its parts and the laws its parts must keep. A Process is how a Thing moves: its stages, the moves between them, and one typed Event for every move. An order, a well, a deployment and a defect are Things; a checkout, a permit review, a roll and a fix are Processes.
from kitlark import Record, Field, Finding
from std.data.collections import Seq
class Line(Record):
sku: str = Field(min_length=1)
qty: int = Field(ge=1)
# A Thing is a typed record: its fields, its parts, and the laws its parts must keep.
class Order(Record):
id: str = Field(min_length=1)
total: int = Field(ge=0)
limit: int = Field(ge=1)
lines: Seq[Line] = []
def holds(self, line: Line) -> bool: # The law is one line: no line orders more than the limit.
return line.qty <= self.limit
def check(self) -> Seq[Finding]: # The Thing checks itself, and names each part that breaks its law.
out = []
for line in self.lines:
if not self.holds(line):
out = out + [Finding(code="over_limit", subject=line.sku)]
return out
The same two words describe software and the world it runs in, so one model covers the form a person fills in, the record it writes and the work that follows.
A Process: explicit state, pure moves, atomic results
A Process is a state machine written as classes. Its state is its declared fields and its stage,
and nothing else. Each move is a pure function over one frozen snapshot that returns the next item. A
stage's work names the one operation it needs; the runtime performs it, and the answer arrives as
a new turn. The next state is applied whole or not at all.
from kitlark import Record, Process
from kitsoki.story import Effect
from kitsoki.ops import bank
class Receipt(Record):
id: str
# A Process is how a Thing moves. Its state is these fields and its stage, and nothing else.
class Checkout(Process):
order: Order
card: str = ""
class Cart(Checkout.Stage):
role = "entry"
def pay(self, card: str) -> Checkout: # A move is a pure function: one frozen snapshot in, the next item out.
return self.to(Charging, card=card)
class Charging(Checkout.Stage):
def work(self) -> Effect[Receipt]: # Work names the one crossing. The runtime performs it, never this code.
return bank.charge[Receipt](amount=self.order.total, card=self.card)
def done(self, receipt: Receipt) -> Checkout: # The answer is a new turn, and the next state is applied whole.
return self.to(Paid)
class Paid(Checkout.Stage):
role = "terminal_ok"
Failure belongs to the runtime. A Process has no failure handler to write: when work fails or stalls, the runtime diagnoses it, recovers it (a retry, a variant, an escalation) or parks it for a person on a typed exception. A record is always working, recovering, parked on a decision, or finished.
The checker walks every stage before any run exists, so a Process cannot hold a state nobody specified. Misspell a stage, write a retry by hand, or strand a stage, and each is named:
from kitlark import Record, Process
from kitsoki.story import Effect, OpError
from kitsoki.ops import bank
class Receipt(Record):
id: str
class Checkout(Process):
total: int
card: str = ""
class Cart(Checkout.Stage):
role = "entry"
def pay(self, card: str) -> Checkout:
return self.to(Charging, card=card)
class Charging(Checkout.Stage):
def work(self) -> Effect[Receipt]:
return bank.charge[Receipt](amount=self.total, card=self.card)
# A misspelt stage is a state nobody specified, so it is refused.
def done(self, receipt: Receipt) -> Checkout:
return self.to(Payed)
# A hand-written retry is refused too. Failure belongs to the runtime, which diagnoses, recovers or parks.
def failed(self, error: OpError) -> Checkout:
return self.to(Cart)
# And a stage no move can reach is named before anything runs.
class Paid(Checkout.Stage):
role = "terminal_ok"
No data races, by construction
A data race needs memory that two writers can change at once. A Kitlark program has none: values are immutable, a module holds no state, and a function keeps nothing between calls. There is no thread to start, no lock to take and no mutex to forget.
State changes in one place. Every Thing has one Process that owns its writes, and the turns of one record run one at a time, each over a frozen snapshot. A turn commits as a single compare-and-swap on the record's revision, so a writer that read an older revision is refused and tried again against the new one. It can never overwrite. Work on unrelated records does not wait, because nothing is held while a turn does its work.
| Ordinary concurrency | Kitlark |
|---|---|
| shared mutable memory, guarded by locks | immutable values, nothing shared to guard |
| a race found by a detector, or in production | no way to write one |
| a lost update when two writers collide | one compare-and-swap per turn; the stale writer is refused |
Five failures Python finds at run time
None of these is a typing mistake. Python accepts each file, and Go's compiler accepts the same shape, because each is about state and effects that neither language tracks: what a module holds, what an import does, who else sees a value. Kitlark refuses each file when it is checked, names the line, and says the fix.
Hidden module state
# A counter at module level is hidden state, shared by every importer. A Go package variable behaves the same.
counter = 0
# Kitlark has no global. Module values are frozen at load, so every module is pure and safe to reload.
def next_id() -> int:
global counter
counter = counter + 1
return counter
A shared module cache
# A cache at module level looks harmless. Every module that imports this one shares it, and in Go it is a data race.
CACHE = {}
# Module values are frozen at load, so the write is refused.
def remember(key: str, value: int) -> int:
CACHE[key] = value
return value
Work at import time
from kitlark import Record
from kitsoki.ops import bank
class Receipt(Record):
id: str
# This line runs when the module is imported: Python's top-level code, Go's init. Here, importing a module does nothing.
warmup = bank.charge[Receipt](amount=0)
A caller's value changed under it
from kitlark import Record
from std.data.collections import Seq
class Cart(Record):
items: Seq[int] = []
# Python and Go both hand over the caller's own cart, so this changes it for everyone holding it. Inputs are immutable here.
def add(cart: Cart, item: int) -> Cart:
cart.items = cart.items + [item]
return cart
A result thrown away
from kitlark import Record
class Order(Record):
total: int
def with_tax(o: Order) -> Order:
return Order(total=o.total + 5)
# The taxed order is computed and thrown away. Python and Go both run this. Kitlark names a dropped value as a bug.
def checkout(o: Order) -> Order:
with_tax(o)
return o
Three failures Go compiles
Go's compiler catches type errors, and still accepts each of these: a zero value nobody chose, a nil pointer, and an error dropped on the floor.
A zero value
from kitlark import Record
class Order(Record):
sku: str
qty: int
# Go fills the missing field with zero and carries on. Kitlark has no zero values: every field is given, or the default is written down.
order = Order(sku="a1")
A nil dereference
from kitlark import Record
from std.data.collections import Seq
class User(Record):
name: str
# The return type says this can answer nothing.
def find(users: Seq[User], name: str) -> User | None:
for u in users:
if u.name == name:
return u
return None
# Go compiles this and panics on a nil pointer. A value that may be None is tested before it is used.
def greet(users: Seq[User]) -> str:
return "hi " + find(users, "ada").name
A dropped error
from kitlark import Record, Result, Ok, Err
class ParseError(Record):
message: str
# A function that can fail says so in its return type.
def parse_qty(text: str) -> Result[int, ParseError]:
if text == "":
return Err(error=ParseError(message="empty"))
return Ok(value=len(text))
# In Go the error is a second value you can drop with an underscore. A Result is read by a match that handles every case.
def qty(text: str) -> int:
match parse_qty(text):
case Ok(value=n):
return n
return 0
Two failures Rust compiles
Rust proves memory safety, and still compiles both of these. Neither needs a contract between systems: they are properties of one function.
An unwrap that panics
from kitlark import Record, Result, Ok, Err
class ParseError(Record):
message: str
def parse_qty(text: str) -> Result[int, ParseError]:
if text == "":
return Err(error=ParseError(message="empty"))
return Ok(value=len(text))
# Rust compiles unwrap, and it panics in production. Kitlark has no unwrap: a Result is read by a match, never opened.
def qty(text: str) -> int:
return parse_qty(text).value
A loop that never ends
# Rust compiles a loop that never ends, and the service hangs. In Kitlark every step terminates: there is no while.
def settle(n: int) -> int:
while n != 1:
n = n - 2
return n
A backend change fails the UI build
A form's fields take their types from the schema. In Ontolo's new-domain wizard the Kitlark form
declares title: Domain.title, and the Vue component binds <KlField form="DomainDraft" name="title">. One contract chain runs from the schema's column, through the form's field and its
messages in every locale, to the line of the component that shows it.
In most stacks a renamed schema field is found by an integration test days after it was written, or
by a customer. Here, rename title in the schema and nothing ships. The form is refused first, at its own line, and
the component that still binds the old name is refused at its line:
| Link broken | Refusal |
|---|---|
| The schema drops or renames a field the form is typed by | data_field_unknown: Domain has no field title in the pinned data model |
| The component binds a field the form does not have | contract_field_unknown: DomainDraft has no field title |
| The component offers a move no stage has | contract_intent_unknown |
| A message is missing in one locale | text_missing |
The chain runs on every draft, so a back end change that breaks a screen is refused when it is drafted, naming the file and the line.
Capabilities are granted, like a phone's permissions
A phone application reaches the camera only after the person grants it. A Kitlark program reaches an operation only by importing it, and the import is checked against the application's grant before anything runs. The import header is the complete list of what a program can touch. When one thing calls another, the effective grant is the intersection of every link, so nothing gains authority by being called through something else.
Granted or not, a plain function performs no crossing:
from kitlark import Record
# The import is the request for the capability, checked against the application's grant.
from kitsoki.ops import bank
class Receipt(Record):
id: str
# Even granted, a plain function may not reach the bank. Only a stage's work names a crossing, and the runtime performs it.
def charge_now(amount: int) -> Receipt:
return bank.charge[Receipt](amount=amount)
And nothing ambient exists to import:
# There is no clock, no file system, no environment and no socket to import. A program touches what it was granted.
from time import time
Secrets and personal data stay behind a typed reference
Credentials and personal data are handled beside the application, by a sidecar the runtime owns.
The application sees a typed reference and never the value. A Secret is a handle: Kitlark writes
the protocol over it, and the host evaluates the expression at the moment a request is sent.
Sensitive fields are sealed once, in the data model, and a program that reads, formats or branches
on a sealed value is refused when it is checked.
The value is protected by policy, held as data, and never by the care of whoever wrote the code. Logs, journals, recordings and prompts hold references, so a leak has nothing to carry.
The schema is the domain; the planner lays out the data
The people who know the domain define its schema, as kinds and their fields. Views query that schema directly: a view is a definition the checker proves in both directions, and a screen, an importer and an agent all read and write through it.
Nobody designs tables, indexes or caches. The planner chooses the layout, what to materialize and where it lives (a cell's hot store, the lake, a browser replica) from measured use, within the policy each fact carries.
Four concerns, kept apart
A Kitlark system keeps four concerns apart that ordinary code mixes in one function.
| Concern | Where it lives |
|---|---|
| Domain logic | pure functions and Processes, written by the author |
| Dependency interaction | named operations, bound by the application, performed by the runtime |
| Storage | the typestore, laid out by the planner |
| Transport between processes | the log every cell reads and writes |
The author writes the first row. A dependency is swapped by its binding, storage by its layout and transport by its placement, with no change to the domain logic.
Dependency injection is enforced
In most languages dependency injection is a convention a team agrees to keep. In Kitlark it is the only way to reach anything. A program names an operation behind a standard interface; the application's binding says which implementation answers. There is no default client, clock or logger to fall back on, and no way to construct one.
That makes the world swappable. The same checked program runs against a mock, a simulation, a cassette, a disposable instance and production, and only the binding differs. A cassette is the recording of a real provider's answers, replayed exactly, so a test is hermetic and still tells the truth. Every implementation of an interface passes that interface's one conformance suite, the local fake included, so a test double is held to the same contract as the real provider.
Cells: one application, every place it runs
Kitsoki is cellular. A browser tab, an edge worker and a cloud host are cells of one machine, each running the same checked closure. A developer writes one application. The same module validates a form as the person types in the tab and again where the write is admitted, with the same typed refusals, and a cell answers the same in the tab and on the instance.
Front end and back end are one platform, and the boundary between them stops being something the author reasons about.
Streaming both ways, one turn at a time
Data streams in both directions, and neither direction is a request waiting on a reply.
Down, every subscriber holds one stream. Each committed change reaches it as it commits, in commit order: rows, schema changes and new code alike. Nothing polls. A dropped connection reconnects with its cursor and the stream answers from there. The progress and the result of long work, a job or a model reply, arrive as entries on the same stream.
Up, a page writes only by appending a command to its outbox. Commands go out one at a time, in the order they were made, and the authority applies each exactly once, so a reload or a retry makes no second write.
The turn is where the two meet. Each command is worked as one turn: the stage's pure method reads one snapshot and returns the next item, and the turn commits once. That commit is the next entry on the stream, so what a person sees is always something that was committed, in the order it was committed.
One stack trace across the whole system
Every crossing carries its trace. A gesture on the page starts one, and the session turn that answers it, the operations the program calls, the Process events it commits, the jobs it launches and the model turns those jobs run all carry the same id. The trace is one tree across the tab, the instance, the queue and the models.
A failure opens at the Kitlark frame that failed: the line, the expression, each operand's value and the typed refusal. Spans from OpenTelemetry sit on the same timeline, so Kitlark frames and foreign spans read as one coherent stack trace.
Zero trust Go underneath
The runtime under Kitlark is Go held to the same rules. Each dangerous primitive (the network, the file system, the clock, the process environment) has exactly one seam, and only that seam imports it. Modules run in a safe subset with immutable inputs and atomic state. The language and its implementation make the same promise, so there is no trusted layer beneath the program for a mistake to hide in.
Fail early, typed end to end, safe by construction
Three ideas carry the whole language.
- Fail at the earliest possible moment. Whatever can be known before a program runs is checked before it runs, in every branch.
- Typed end to end. One type and capability engine covers the form, the Process, the operations and the schema, so the contracts between layers are checked and never assumed.
- Safe by construction. Pure functions, immutable inputs, explicit state and granted capabilities leave no place for the unsafe program to be written.