zttp agent-compiler

Your AI writes the code. The compiler proves it.

zttp is an agent-compiler: the compiler works as a second agent in your coding session. It checks every draft before it reaches disk, and it fixes the mistakes it knows without another model call.

zttp is experimental software. It is not a supported product or a production-ready runtime/compiler. Expect bugs and breaking changes.

$ curl -fsSL https://raw.githubusercontent.com/srdjan/zttp/main/install.sh | sh

Apple Silicon macOS, and Linux on x86-64 or ARM64. Inspect the install script before you run it.

zttp expertone session
$ zttp expert "count retries in the webhook"

[agent]    draft 1: simulating before write
[veto]     draft adds a violation
  error[ZTS613]: compound assignment is not part of canonical ZigTS
    --> handler.ts:12:5

[compiler] typed repair: attempts += 1 -> attempts = attempts + 1
[compiler] applied with no model call
[compiler] compiler-authored repair passed aggregate proof
The compiler rejects the draft, repairs it with no model call, then proves it.

Real analyzer output

Break one guarantee. The compiler names it.

This handler declares three guarantees and returns an environment secret in its response. zts check refuses it and names the guarantee that broke.

handler.ts
import { env } from "zttp:env";

structural Guardrails<T> = Proof<T,
  | "deterministic"
  | "no_secret_leakage"
  | "injection_safe"
>;

function handler(req: Request): Guardrails<Response> {
  const key = env("API_KEY") ?? "";
  return Response.json({ ok: true, key: key });
}
zts check handler.ts
check: handler.ts

  Security:
    no_secret_leakage ... ---
    no_credential_leak .. PROVEN
    input_validated ..... PROVEN

  Spec diagnostics:
    ZTS500 (error) handler.ts:9:17  declared Proof capsule was not discharged by handler proof (failing spec: no_secret_leakage)
zts check --json handler.ts
{
  "code": "ZTS400",
  "severity": "error",
  "message": "secret data flows into response body",
  "file": "handler.ts",
  "line": 11,
  "column": 23,
  "suggestion": "env vars with sensitive names (SECRET, PASSWORD, KEY, TOKEN) must not appear in responses"
}
Output of zts check from zttp 0.22 at commit 20caa237. --- means not proven. The excerpt omits the parse, verification, and property sections (all OK or PROVEN), the path statistics, and the footer.

One write path

Every edit has two authors.

  1. 01 Draft

    The agent proposes a handler.

  2. 02 Prove

    The compiler checks it before it is saved.

  3. 03 Repair

    The compiler fixes known failures itself, with no model call.

  4. 04 Write

    Only proven code is written.

zttp records who wrote each edit: the model or the compiler. For five safety properties, the compiler plans, applies, and checks the fix on its own, and undoes it if the fix breaks something else.

Why zts restricts TypeScript

zts removes the features the compiler cannot fully check, such as classes, async, try/catch, and while loops. Each removal makes one guarantee provable and gives the agent fewer wrong ways to write code.

Read the restriction map
Compare zttp with bolt-on checkers

Agent plus checker: the code is written first and checked afterwards, in full TypeScript.

Compiler plus agent: the compiler only returns error text, and the model retries with no limit.

zttp: the compiler is an agent too. It shares the only write path with the model and writes its own repairs.

Current evidence

What is proven today, and what is not.

zttp grades its own claims the same way it grades code, and the grades live in the repository beside the code they describe.

Holds by construction

A rejected draft never reaches disk. The analyzer gives a verdict for every zts program.

Measured

On a fixed set of 13 coding tasks, 9 first drafts from DeepSeek V4 Flash pass the compiler unchanged. 10 reach a proven handler, and 10 pass their intent tests. zttp 0.24.0 closes the 20 known false security proofs of 0.22.3, and 0.25.0 closes two more: secret env names and the mask bound. Each one has a permanent regression test.

Not measured yet

Whether a small model on your own machine does as well. That test is planned and has not run.

Attested runtime

Ship the proof with the handler.

zttp deploy builds one signed binary. Before it serves a request, the binary checks the proof again with its own independent checker, and it refuses to start if anything inside was changed. Anyone can run zttp verify <url> to check the signature. Pinning a key with --trust-key authenticates the signer.

  • One self-contained binary
  • Proof checked at startup
  • Signed claims that anyone can check
Open the full claim ledger

The roadmap names each claim, its evidence grade, and the file that owns the measurement.

Recount the claims
Runtime details

What changed in 0.27.0

The v0.27.0 download carries these changes. The details below separate new checks, upgrade steps, and evidence limits. The changelog gives each migration.

Handlers with file imports

zttp compile, zttp build, and zttp deploy build handlers with file imports into one binary with one certificate. Each dependency passes the applicable checks. Ambiguous bindings, untyped file imports, and failed capsule properties stop the build.

zttp check reports module refusals with a code and the file at fault. ZTS063 names a module graph refusal. ZTS064 names an import without a type that can cross modules. GraphResultsNotProved remains a build-only refusal.

The producer states that the proof covers every file. The independent checker binds dependency bytes through digests; it does not confirm that coverage. A dependency edit makes the built binary refuse to start.

Module checks and certificate limits
Stronger type checks

The checker refuses function values in incompatible typed positions and type guards whose tests do not prove their claims. Arithmetic requires a number type. A builtin result receives its runtime type when the argument types support that result. A missing request header therefore needs a check or fallback.

Array callbacks must accept the values that the method passes. Result combinators carry value and error types, and module errors follow their runtime payloads. Even after a successful Result check, its value can still admit undefined. A schema failure can fill errors and leave error absent.

Member calls must name runtime members. String index reads are refused; charAt and slice provide supported alternatives. Typed Dict operations preserve key and value types, including callback parameters. A missing Dict key still reads undefined.

Builtin, Result, member, and Dict types
Arrays, tuples, and writes

Array inference and checks retain elements beyond the previous fixed limit. Loops over array literals give their variables element types. An unresolved element contributes unknown without removing checks on known elements. Fixed tuple spreads retain positions and correlated alternatives. A variable array spread cannot claim a fixed tuple length.

Writes must fit each relevant container member, including members of wide unions. Inferred numeric containers accept compatible numeric writes after literal widening. Explicit literal annotations remain restrictive. Tuple length changes are refused.

A value with no type is refused in arithmetic and member calls. Some gaps remain: a write with no inferred value type can pass. Response.json refuses known non-string Dict keys, but unknown keys can still pass. Allocation failures stop analysis; they do not establish a runtime guarantee.

Container rules and remaining gaps
State, determinism, and Response init

A write to module state now removes pure, stateless, read_only, retry_safe, deterministic, and idempotent, as well as state_isolated. A push onto a module array counts as a write.

A branch on a value that can differ between runs, such as Date.now(), now removes deterministic when the response follows it. Arrow helpers and helpers in imported files are held to their declared capsules.

A Response init accepts only a number status. Other members, such as headers, are refused, because the runtime ignores them.

State isolation rules
Proof headers and incidents

The Zttp-Proofs header and the startup log now grade each property by the verdict of the proof checker, in the groups checked=, accepted=, and claimed=. A compiler claim no longer reads as a proof.

Zttp-Attest now carries the SHA-256 digest of the signed attestation. The attestation stays at /.well-known/zttp-attest.

A deployed binary accepts --incident-log. A type fault on a path that the compiler claims safe records a soundness incident, also in zttp dev.

How to read the header
Upgrade guidance

Earlier artifacts need a rebuild and redeployment because semanticsHash changed. Existing self-extracting binaries keep running. Source that fails admission now stops at load, including imported files and inline source.

zttp verify refuses an artifact with the old Zttp-Attest header; rebuild it. A client that reads Zttp-Proofs reads the graded groups. The incident-log key proven is now claimed.

Contract consumers read responses instead of the removed scalar response fields. Changes to status, content type, or response count can now stop a proof-aware hot swap. Scripts must remove --no-sign from zttp proofs gate.

zttp auth claude and zttp auth openai are removed. Their auth revoke commands still delete stored keys. The current installer no longer accepts zigttp-* release assets. It requires v0.19.0 or later.

Source migrations include missing-value checks, compatible callback types, and supported member operations. Internal code moves, dead-code removal, and test migrations simplify maintenance. They establish no performance improvement. The changelog also lists Zig embedding changes and renamed repair intents.

Complete migration record
Evidence and limits

The 2026-11-09 recording uses DeepSeek V4 Flash and corpus 91c9e8aaf5e4. Across 13 tasks, 9 first drafts pass unchanged, 10 reach proven handlers, and 10 pass intent tests. The median is 5 round trips.

The recording replays offline at the v0.27.0 source. The recorded corpus trips 2 of 59 advertised rules. That count does not describe total regression coverage or measure the quality of future model drafts.

Proof properties have specific limits. A structural return proof does not prevent a trap inside a called function. The optional runtime cost fuse requires cost_ceilings; shipped commands do not configure it.

Recorded model results Recorded rule coverage Runtime cost limits

On main, not released

These changes are in the zttp repository on main. No release carries them yet. The v0.27.0 download does not include them.

Result card before approval

In zttp expert, each verified change set now shows a result card before the question to apply it. The card names the verdict, failing tests, lost and gained proof properties, and contract changes. The diffs follow the card.

The host runs zttp test on tests/handler.test.jsonl against a temporary copy of the project that holds the proposed files. A failing or unrunnable suite never refuses the change set. The host stops a run after 30 seconds. The developer decides.

The tests run only in an interactive session that asks for approval. The flags --yes, --no-edit, --print, and --goal run no tests. Contract route lines cover routes registered through zttp:router.

A suite is only as strong as its rows. The command zttp gen-tests writes rows that check the status code of each proven path.

Required properties in zttp.json

A project can list proof properties in requiredProperties in zttp.json. zttp expert applies no change set whose candidate does not prove every listed property. The rule holds with --yes too.

In the interactive session, the command /contract prints the entry, routes, proven properties, env reads, and egress hosts. It then asks whether to require the proven properties. The command /contract drop removes one name.

Only zttp expert reads the list. The commands zttp check, zttp dev, zttp build, and zttp deploy ignore it.

First proof

Prove your first handler.

Install zttp and scaffold an API. Then add a line zts does not allow, such as try/catch, and watch the compiler name the rule and the line.

$ curl -fsSL https://raw.githubusercontent.com/srdjan/zttp/main/install.sh | sh

Apple Silicon macOS, and Linux on x86-64 or ARM64. Inspect the install script before you run it.

zttp init api --template api
cd api
zttp dev

zttp expert needs a DeepSeek key, or --provider local and a local MLX server. The compiler and CLI do not.