Skip to content

v0.27.0

Latest

Choose a tag to compare

@srdjan srdjan released this 13 Nov 19:10
· 37 commits to main since this release
Immutable release. Only release title and notes can be modified.

zttp v0.27.0

Highlights

zttp build, zttp compile, and zttp deploy now build a handler with file
imports into one binary with one certificate. The type checker closes many
false proofs. A handler that passed zttp check and then faulted at runtime
now gets a diagnostic code and a fix. The Zttp-Proofs header grades each
property by the proof-checker verdict, and a deployed binary records a
soundness incident when a claimed-safe path faults.

Breaking changes

  • Rebuild and redeploy earlier artifacts. semanticsHash moved, so the new runtime refuses an artifact from an earlier binary with SemanticsHashMismatch. A self-extracting binary keeps running.
  • The runtime now refuses a contract with no capability matrix or no policy hash. A contract with no route arrays no longer gets them from the scalar route keys. Rebuild such an artifact with the current zttp.
  • Handlers that 0.26.0 accepted can now fail zttp check. Each entry under Fixed names the diagnostic code and the change to make. A handler can also lose deterministic or a property of the read-only family; see Changed.
  • The Zttp-Proofs response header and the startup log now grade each property by the proof-checker verdict, in the groups checked=, accepted=, and claimed=. Before, both listed the compiler's claims as proven. The startup line Proven: is replaced by Checked:, Accepted:, and Claimed:. The signed property_summary does not change.
  • The Zttp-Attest response header now holds sha256=<hex>, the SHA-256 of the signed attestation, not the attestation itself. The attestation stays in /.well-known/zttp-attest, which a cache must now revalidate (Cache-Control: no-cache). The attestation version is zttp-attest-v5. zttp verify refuses an artifact with the old header and asks for a rebuild.
  • The 500 body, the SOUNDNESS INCIDENT log line, and the incident-log JSON now say "claimed" instead of "proven". The JSON key proven is now claimed. The runtime judges a fault against the compiler's claims, which the Zttp-Proofs header grades as claimed=.
  • Source builds and release verification now require Zig 0.17.1 exactly.
  • A .ts import or an -e source that admission refuses now fails at start with the admission message. Some forms used to run, or to report a second and less exact message.
  • HandlerSource.inline_code now passes admission, so inline source that admission refuses fails at load. Type annotations in inline source load unchecked. Use a .ts file for the type check.
  • A handler with a second parameter now reads undefined there, not an empty object. Remove the parameter.
  • The Zig API no longer has zts.Parser.init, Parser.parse, Parser.parseWithCodegenAllocator, parser.parse, ParseResult, ParseOptions, zts.pathsMatch, or HandlerInstance.loadHandler, and Runtime.destroy takes no allocator. Use JsParser.initAdmission, routePatternsMatch, and loadCode.
  • zts canonicalize --json now prints the repair intent names. Update a check that matches an old name: canonicalize_arrow_helper is replace_arrow_with_function, canonicalize_export_function is replace_export_arrow_with_function, canonicalize_let_const is replace_let_with_const, canonicalize_compound_assign is replace_compound_assign_with_explicit, and canonicalize_redundant_bool_compare is drop_redundant_bool_compare.
  • Contract JSON no longer holds the route keys responseStatus, responseContentType, responseSchemaRef, responseSchema, and responseSchemaDynamic, or their version 2 forms. Read responses. A contract that holds these keys still parses.
  • A static route with two or more responses now compares each response. A changed status, content type, or response count reports breaking, where it used to report unchanged, so a dev --prove hot-swap can stop for that route. Review the reported change.
  • A session journal no longer stores body in a tool result. Read llm_text. An older journal still loads.
  • The expert journal reader refuses a record that predates llm_text: a part_index record, a body-only record, or a string display record. Each reports CorruptEventsLog. Start a new session.
  • zttp proofs gate no longer accepts --no-sign. Remove the flag from scripts. Old kind=perf and kind=equivalence ledger rows still load, and the reader does not read their payloads.
  • zttp auth claude and zttp auth openai now report an unknown subcommand. zttp auth revoke claude and zttp auth revoke openai still delete a stored key.
  • install.sh no longer installs releases with zigttp-* assets, so ZTTP_VERSION=v0.18.0 or older stops installing. Select v0.19.0 or later.
  • In zttp, a flag token in a value position no longer sets that flag. zttp serve handler.ts --sqlite --watch reads --watch as the value of --sqlite and does not start watch mode. Give --sqlite its path, as in --sqlite app.db --watch.
  • The debug environment variables ZTS_PIC_DISABLE_RECOVERY and ZTS_TRACE_FUN_DECL are removed and have no effect. Remove them from scripts.

Added

  • zttp compile, zttp build, and zttp deploy now build a handler with file imports into one binary with one certificate. Before, these commands refused such a handler. A build exits 1 and writes no binary when a module binds an ambiguous top-level name, when a check fails in any module, or when a dependency breaks a capsule property. zttp serve also refuses an ambiguous top-level binding. See Verification.
  • zttp check and zts check now run the checks of the build on every module of a handler with file imports. A refusal carries a code and the file at fault. ZTS063 reports a missing, unparsable, or cyclic dependency. ZTS064 reports a file import that has no type that can cross modules. Before, such a handler could pass check and fail in build. GraphResultsNotProved stays a build-only refusal.
  • The producer states that the proof covers every file of the graph. The independent checker binds the dependency bytes through digests, but it does not confirm that coverage. A dependency edit makes the built binary refuse to start.
  • A self-contained binary accepts --incident-log <FILE>. A type fault on a path that the compiler claims optional_safe and result_safe now records a soundness incident in a deployed binary and in zttp dev. Before, the 500 body reported a possible incident, and nothing was recorded.

Changed

  • When the verifier finds a write to module state, pure, stateless, read_only, retry_safe, deterministic, and idempotent are no longer proven, in addition to state_isolated. Before, a handler that wrote module state kept the other six, and the ZTS500 help suggested a capsule that claimed them.
  • The flow evaluator now follows each request through the handler, its helpers, and the imported modules, and it records each write to module state. A write that the verifier did not name is a ZTS310 warning at the write, in the file that holds it. The ZTS500 and ZTS606 hints name the line of the write and the remedy: copy the value into a local, or move the state to zttp:cache.
  • A control decision on a value that can differ between runs now removes deterministic when the response follows it. This covers if, a ternary, a match arm, assert, &&, ||, ??, an optional chain, a loop count, a selected call target, and a route choice. Before, if (Date.now() % 2 === 0) { return Response.text("even"); } kept deterministic. The ZTS500 hint names the branch.
  • A helper written as an arrow function, such as const stamp = (): Proof<number, "pure"> => Date.now(), is now held to its declared capsule. A Proof<...> or Effects<...> on a helper in an imported module is now discharged too. Before, both passed zts check and zttp build with no diagnostic.
  • Under the default profile, a helper with no capsule that breaks pure, read_only, or deterministic now gets a ZTS606 row marked as caused by the default profile, with a remedy. The suggested capsule of the ZTS500 row leaves out a property that a helper breaks.
  • The expert approval prompt now approves a change set only on the whole answer y or yes, in any letter case. Before, any answer that began with y approved, so typed-ahead text could write the change set before the user saw the diff.
  • An unannotated array literal binding now widens its elements. const ys = [4, 5] is number[], const t = ["a", 1] is [string, number], and const out = [] is unknown[]. The loop variable of for...of over a tuple is the union of the widened element types. Before, the variable had no type, and s.toUpperCase() in for (const s of [1, 2]) passed CHECK and answered 500.
  • Object.values(o) is now unknown[], Object.entries(o) is [string, unknown][], and u.length with u: string | string[] is a number.
  • The zttp:collections exports now accept a typed Dict and give typed results. const d: Dict<string, number> = dictSet(dictEmpty(), "a", 1); got ZTS200, and dictFold(d, f, 0) with that d got ZTS203. Both are now accepted. dictGet is V | undefined, so a read on its result needs a check for undefined. An unannotated let d = dictEmpty(); is Dict<unknown, unknown>; annotate it.
  • An unannotated callback of dictFold, dictMapValues, or dictFilter over a typed Dict takes the key and value types, so dictFold(d, (acc, value, key) => acc + value, 0) is a number. An annotated or named callback that refuses those types gets ZTS203. Over a Dict<unknown, unknown>, a callback annotated (acc: number, v: number, k: string) also gets ZTS203; annotate the Dict. A named dictFilter predicate such as function big(v: number, k: string): boolean is now accepted.
  • The error of a Result from a virtual module now has the type that the runtime stores. Only jwtVerify and the zttp:validate and zttp:decode exports store a string message; every other export has an unknown error. A validate or decode schema failure fills errors and leaves error absent, so their error is string | undefined. Before, every Result declared error?: string, so shout(r.error) with shout(s: string) passed and could fault. Check for undefined, or use r.error ?? "fallback". zts check --types prints the same error types.
  • The zttp:result exports now have value and error types: ok(21) has a number value, err("x") a string error, and unwrapOr, mapResult, mapError, andThen, orElse, and collectAll derive theirs. An unannotated combinator callback takes the value or error type, and an annotated one must accept it (ZTS203).
  • A builtin call now has the type of the value that the runtime returns, when its arguments have the types that the runtime reads. This covers .length, the Math, Number, Date, String, JSON, Object, and Array builtins, the string and array methods, and req.headers.get. Before, such a value had no type and passed at every typed position, so const token: string = req.headers.get("x"); passed and the handler could fault at runtime. These forms are now refused, because the value can be undefined: s.split(",")[0], xs.pop(), req.headers.get("x"), and s.repeat(n) where a string or number is required, and xs.map(f)[0] returned from a number function. Add ?? fallback, or check for undefined in an if. String(a) + String(b) now gets ZTS105; write [String(a), String(b)].join("").
  • An unannotated parameter of an inline array callback now has the type of the value in its position: the element, the index (number), and the array. A reduce callback whose return type differs from its seed type now gets ZTS200, such as xs.reduce((acc, v) => String(v), 0). Annotate the accumulator with a type that holds both.
  • A discriminant test such as v.kind === "a" now keeps every union member that can hold "a", and it narrows a union of structural records. Before, it took the first member that matched, and a union of named records did not narrow.
  • An erased type prefix now reports ZTS002, such as const x = <T>(1); and const x = <T> { id: 1 };. Remove the prefix.
  • A generic arrow after return or after a line comment now reads like the same arrow in an assignment. return <T>(value: T): T => value; is accepted. Update a check that expects ZTS002 there.
  • An empty type predicate now reports ZTS003 at the first token after is. Write the narrowed type after is.
  • A call on a value with no callable payload now stops with NotCallable. No tracked program reaches this call. Report a program that stops with this error.

Fixed

  • zttp proofs verify now checks semantics against the same binary that it hashed. Before, it hashed the file at binary.path of the manifest and then read a file named binary. A manifest that listed another file next to a valid binary printed Integrity: verified.
  • zts check now refuses a Response init that the runtime ignores (ZTS203). This covers an init member other than status, such as headers, an init that is not a record, a status that is not a number, and a record passed to Response.redirect. Before, these passed, and the runtime sent status 200 or 302 and no header. Write { status: 201 }, or Response.redirect(url, 301).
  • The checker now reads Response?.json(...) and Response["json"](...) as the constructor call, so the ZTS213 payload check and the return type check run for them. zts check --types now declares Response.rawJson, and ResponseInit declares status only.
  • A call to push, pop, shift, unshift, or splice on a module-scope array now raises ZTS310. Before, only an assignment raised ZTS310, so seen.push(1) kept state_isolated proven while the handler returned 2, 3, 4 for identical requests. Copy the array into a local, or move the state to zttp:cache.
  • A push of a request value onto a module array now fails the request with ArenaObjectEscape. Before, the module array kept a dangling pointer, and the next request read the wrong string.
  • padStart and padEnd now throw RangeError: Invalid string length for a target length above 1 MiB, before any allocation. Before, "a".padStart(2000000000, "xy") allocated about 2 GB per request, ignored -m, and panicked.
  • A pooled runtime now frees request overflow memory at each request reset. Before, that memory stayed until the runtime was recycled.
  • The server now sends the standard reason phrase for 34 more status codes. Before, a handler that returned 409 sent HTTP/1.1 409 Unknown.
  • The proof trace of check --json and the live-reload Counterexample and Why rows now name the dependency file of a branch cause, a guard, and a sink. Before, a line in an imported file printed as a line of the checked file.
  • zts check --json now writes the verifier's unreachable_code into the contract. Before, CHECK wrote false.
  • The expert proof read set now holds the schema of the SQLite database that zttp.json names, not its bytes, and it ignores a database that zttp.json does not name. Before, a row write during the approval wait failed the commit with ProofReadSetChanged, and a database above 32 MiB failed capture with FileTooBig.
  • The expert loop moves a change-set record to .zttp/change-sets-archive/ when the user acknowledges its receipt, so the same change can commit again after a revert. Before, the repeat commit failed with TransactionAlreadyExists, and one damaged receipted record blocked every later acquire.
  • Expert change sets are safer. A target inside .zttp is refused. A target that the user edited between prepare and capture fails with ProofReadSetChanged instead of being overwritten. A .DS_Store file no longer blocks every acquire, and a leftover stage file no longer blocks the same change.
  • The expert providers now put a time bound on the TLS handshake, the request body write, and the response head read. Before, a peer that never answered could block a turn past its deadline. A response body shorter than its Content-Length is a transport failure (BodyTruncated). The local MLX client refuses an abnormal finish_reason, as the DeepSeek client already did.
  • The expert REPL refuses an over-long input line whole, and quit, exit, and help act only on the whole line. A failed /resume, /new, or /fork prints its error and keeps the current session.
  • zttp ledger export and crash recovery now keep cost_bounded and post_only of a verified change set. Before, both were written as false.
  • After if (r.ok), a read on a Result value whose type admits undefined, such as r.value.length with r = ok(req.headers.get("x")), now gets ZTS309. Check the value for undefined first.
  • An arithmetic operand with no type now gets ZTS104, or ZTS106 in +, and a member call on a value with no type gets ZTS201. Before, [1, 2].reduce((acc, v) => acc.toFixed(2), "") and range(3).map(f) passed CHECK and answered 500. Annotate the value or its source, or narrow it with typeof or isDict. Write for (const i of range(n)) instead of range(n).map(f).
  • Response.json now refuses a Dict whose key type admits a value that is not a string (ZTS213). Response.json(dictSet(dictSet(dictEmpty(), 2, "x"), "k", 1)) passed CHECK and answered 500.
  • A write into a record field, an array element, or a tuple element must now fit the slot type (ZTS200), and each element that push, unshift, or splice adds must fit the element type (ZTS203). A tuple refuses push, pop, shift, unshift, splice, and a write to length. Before, p.name = 5 with p: { name: string } passed CHECK, and p.name.toUpperCase() answered 500. An unannotated object or array literal binding widens its literal slots, so const o = { n: 0 }; o.n = 1; stays accepted.
  • A member read or call on a number, boolean, string, array, or tuple must name a member that the runtime holds. n.toFixed(2) and n.toString() now get ZTS201. Before, such a handler passed and faulted at runtime with NotCallable. Use String(n). A call of a member on unknown, and a call through a member that one union member lacks, also get ZTS201. Narrow the value first.
  • An index read on a string now gets ZTS201, because the runtime gives undefined. Use s.charAt(i) or s.slice(i, i + 1). In a union such as string | string[], the string member adds undefined to an index read. A member that one union member lacks does the same, such as x.age with x: P | string. An unchecked read on such a value gets ZTS309.
  • After if (!r.ok), a read on the error of a zttp:validate or zttp:decode Result, such as r.error.length, now gets ZTS309. A schema failure fills errors and leaves error absent. Check r.error for undefined first.
  • An annotated or named callback of an array method must accept the value that the method passes. [1, 2].map((s: string) => s.toUpperCase()), [1, 2].map(sha256), and a reduce accumulator that refuses the seed or the callback result now get ZTS203. Before, such a handler passed and could fault at runtime with NotCallable. Correct the annotation, or remove it. A named predicate with parameters, such as [1, 2].filter(isBig), is now accepted.
  • A Result argument must be a Result that ok, err, or a module export returns. mapResult({ ok: true, value: 21 }, f), collectAll([1, 2]), and an andThen or orElse callback that does not return a Result now get ZTS203. Before, the runtime returned the value unchanged or undefined, and a handler could fault. Return ok(...) or err(...).
  • An arithmetic operand must have a number type. zts check now refuses x + 1 with x: number | undefined or number | null, b.n - 1 with an optional field n, xs[5] * 2, v * 2 with v: unknown, and -x or -b with b: boolean (ZTS104, ZTS106 for +). Before, such a handler passed, proved optionals_safe, and could fault at runtime. Compare with undefined or null in an if and compute inside the branch. For a value that may be undefined but not null, (x ?? 0) + 1 also works. A ternary that selects a guarded value and a guarded value captured in a closure are also refused; write x ?? 0 there.
  • A function value now has a function type. zts check refuses a function where the type admits no function: ZTS204 for a return, ZTS200 for an annotation, an assignment, a record field, or an array or tuple element, ZTS203 for an argument, and ZTS213 for a JSON payload. Before, such a handler passed and could fault at runtime. Call the function, or correct the type.
  • A function value is checked against a declared function type by its parameters. (x: number, y: number) => number and (x: string) => number are refused where (x: number) => number is declared (ZTS200).
  • A type guard narrows only when its test proves the type after is. function isStr(x: unknown): x is string { return typeof x === "number"; } now reports ZTS211, and so does typeof x === "object" for x is object. Change the test, or claim the type the test proves.
  • A type guard on an arrow function, on a function declared inside another function, or on a callback now reports ZTS211. So does a guard whose name before is is not an annotated parameter. Declare the guard as a function at module level.

Install

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

Or download a tarball below and extract it manually.

Documentation

Full Changelog: v0.26.0...v0.27.0