Correctness infrastructure for the agentic era.
Formal methods, type theory, Nix.
The verification layer is missing. Agents generate code faster than any human process can check it. The bottleneck is not skill. It is architecture. Kleisli.IO builds the missing layers.
Pos = refined "Pos" Int (x: x > 0);
Network = Record {
hostName = String;
port = Pos;
interfaces = ListOf (Record { name = String; mtu = Pos; });
};
badConfig = {
hostName = "kleisli.io";
port = (-1);
interfaces = [
{ name = "eth0"; mtu = (-50); }
{ name = 42; mtu = 1500; }
{ name = "eth2"; mtu = "big"; }
];
};
comp = Network.validate badConfig;
runWith = handlers: state: fx.handle { inherit handlers state; } comp;error: Type error at interfaces.[0].mtu: expected Pos, got int
4 error(s): interfaces.[0].mtu :: expected Pos, got int interfaces.[1].name :: expected String, got int interfaces.[2].mtu :: expected Pos, got string port :: expected Pos, got int
pass hostName : String fail interfaces.[0].mtu : Pos pass interfaces.[0].name : String pass interfaces.[1].mtu : Pos fail interfaces.[1].name : String fail interfaces.[2].mtu : Pos pass interfaces.[2].name : String fail port : Pos
$ nix eval --raw -f examples/handler-swap-validation.nix {strict|collecting|logging}examples/handler-swap-validation.nixOne computation. Three handlers. Three semantics. The specification defines what to check; the handler decides how to respond. evalModules bakes halt-on-first into the module system (nixpkgs#367882); swapping it requires forking nixpkgs.
kli is the coordination layer. An append-only event log is the specification; a projection is the handler. Privacy redaction, CRDT merges, retention windows — all are handlers over the same log. No central coordinator, because the log doesn't need to know who's reading.
Built on the Kleisli stack. Operated from Tromsø.
nix-effects embeds a Martin-Löf Type Theory proof checker in pure Nix. Dependent functions, dependent pairs, identity types with J, cumulative universes, verified extraction of plain Nix functions from proof terms. The whole system runs at nix eval time.
Nix has no loops and no tail-call optimization. builtins.genericClosure, the package dependency primitive, doubles as a general-purpose trampoline once you break the thunk chain.
AI agent sessions are distributed processes: private state, independent failure, concurrent access to shared resources. Event sourcing gives sessions durable history; CRDTs give them convergent merge, with correctness guarantees that are purely algebraic, requiring no network model.