Repository navigation
·
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.
semanticsHashmoved, so the new runtime refuses an artifact from an earlier binary withSemanticsHashMismatch. 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 losedeterministicor a property of the read-only family; see Changed. - The
Zttp-Proofsresponse header and the startup log now grade each property by the proof-checker verdict, in the groupschecked=,accepted=, andclaimed=. Before, both listed the compiler's claims as proven. The startup lineProven:is replaced byChecked:,Accepted:, andClaimed:. The signedproperty_summarydoes not change. - The
Zttp-Attestresponse header now holdssha256=<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 iszttp-attest-v5.zttp verifyrefuses an artifact with the old header and asks for a rebuild. - The 500 body, the
SOUNDNESS INCIDENTlog line, and the incident-log JSON now say "claimed" instead of "proven". The JSON keyprovenis nowclaimed. The runtime judges a fault against the compiler's claims, which theZttp-Proofsheader grades asclaimed=. - Source builds and release verification now require Zig 0.17.1 exactly.
- A
.tsimport or an-esource 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_codenow passes admission, so inline source that admission refuses fails at load. Type annotations in inline source load unchecked. Use a.tsfile for the type check.- A handler with a second parameter now reads
undefinedthere, 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, orHandlerInstance.loadHandler, andRuntime.destroytakes no allocator. UseJsParser.initAdmission,routePatternsMatch, andloadCode. zts canonicalize --jsonnow prints the repair intent names. Update a check that matches an old name:canonicalize_arrow_helperisreplace_arrow_with_function,canonicalize_export_functionisreplace_export_arrow_with_function,canonicalize_let_constisreplace_let_with_const,canonicalize_compound_assignisreplace_compound_assign_with_explicit, andcanonicalize_redundant_bool_compareisdrop_redundant_bool_compare.- Contract JSON no longer holds the route keys
responseStatus,responseContentType,responseSchemaRef,responseSchema, andresponseSchemaDynamic, or their version 2 forms. Readresponses. 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 reportunchanged, so adev --provehot-swap can stop for that route. Review the reported change. - A session journal no longer stores
bodyin a tool result. Readllm_text. An older journal still loads. - The expert journal reader refuses a record that predates
llm_text: apart_indexrecord, abody-only record, or a string display record. Each reportsCorruptEventsLog. Start a new session. zttp proofs gateno longer accepts--no-sign. Remove the flag from scripts. Oldkind=perfandkind=equivalenceledger rows still load, and the reader does not read their payloads.zttp auth claudeandzttp auth openainow report an unknown subcommand.zttp auth revoke claudeandzttp auth revoke openaistill delete a stored key.install.shno longer installs releases withzigttp-*assets, soZTTP_VERSION=v0.18.0or older stops installing. Selectv0.19.0or later.- In
zttp, a flag token in a value position no longer sets that flag.zttp serve handler.ts --sqlite --watchreads--watchas the value of--sqliteand does not start watch mode. Give--sqliteits path, as in--sqlite app.db --watch. - The debug environment variables
ZTS_PIC_DISABLE_RECOVERYandZTS_TRACE_FUN_DECLare removed and have no effect. Remove them from scripts.
Added
zttp compile,zttp build, andzttp deploynow 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 servealso refuses an ambiguous top-level binding. See Verification.zttp checkandzts checknow 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 passcheckand fail inbuild.GraphResultsNotProvedstays 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 claimsoptional_safeandresult_safenow records a soundness incident in a deployed binary and inzttp 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, andidempotentare no longer proven, in addition tostate_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
deterministicwhen the response follows it. This coversif, a ternary, amatcharm,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"); }keptdeterministic. 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. AProof<...>orEffects<...>on a helper in an imported module is now discharged too. Before, both passedzts checkandzttp buildwith no diagnostic. - Under the default profile, a helper with no capsule that breaks
pure,read_only, ordeterministicnow 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
yoryes, in any letter case. Before, any answer that began withyapproved, 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]isnumber[],const t = ["a", 1]is[string, number], andconst out = []isunknown[]. The loop variable offor...ofover a tuple is the union of the widened element types. Before, the variable had no type, ands.toUpperCase()infor (const s of [1, 2])passed CHECK and answered 500. Object.values(o)is nowunknown[],Object.entries(o)is[string, unknown][], andu.lengthwithu: string | string[]is anumber.- The
zttp:collectionsexports now accept a typed Dict and give typed results.const d: Dict<string, number> = dictSet(dictEmpty(), "a", 1);got ZTS200, anddictFold(d, f, 0)with thatdgot ZTS203. Both are now accepted.dictGetisV | undefined, so a read on its result needs a check forundefined. An unannotatedlet d = dictEmpty();isDict<unknown, unknown>; annotate it. - An unannotated callback of
dictFold,dictMapValues, ordictFilterover a typed Dict takes the key and value types, sodictFold(d, (acc, value, key) => acc + value, 0)is anumber. An annotated or named callback that refuses those types gets ZTS203. Over aDict<unknown, unknown>, a callback annotated(acc: number, v: number, k: string)also gets ZTS203; annotate the Dict. A nameddictFilterpredicate such asfunction big(v: number, k: string): booleanis now accepted. - The
errorof a Result from a virtual module now has the type that the runtime stores. OnlyjwtVerifyand thezttp:validateandzttp:decodeexports store a string message; every other export has anunknownerror. A validate or decode schema failure fillserrorsand leaveserrorabsent, so theirerrorisstring | undefined. Before, every Result declarederror?: string, soshout(r.error)withshout(s: string)passed and could fault. Check forundefined, or user.error ?? "fallback".zts check --typesprints the same error types. - The
zttp:resultexports now have value and error types:ok(21)has anumbervalue,err("x")astringerror, andunwrapOr,mapResult,mapError,andThen,orElse, andcollectAllderive 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, theMath,Number,Date,String,JSON,Object, andArraybuiltins, the string and array methods, andreq.headers.get. Before, such a value had no type and passed at every typed position, soconst token: string = req.headers.get("x");passed and the handler could fault at runtime. These forms are now refused, because the value can beundefined:s.split(",")[0],xs.pop(),req.headers.get("x"), ands.repeat(n)where astringornumberis required, andxs.map(f)[0]returned from anumberfunction. Add?? fallback, or check forundefinedin anif.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. Areducecallback whose return type differs from its seed type now gets ZTS200, such asxs.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 ofstructuralrecords. 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);andconst x = <T> { id: 1 };. Remove the prefix. - A generic arrow after
returnor 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 afteris. - 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 verifynow checks semantics against the same binary that it hashed. Before, it hashed the file atbinary.pathof the manifest and then read a file namedbinary. A manifest that listed another file next to a validbinaryprintedIntegrity: verified.zts checknow refuses a Response init that the runtime ignores (ZTS203). This covers an init member other thanstatus, such asheaders, an init that is not a record, astatusthat is not a number, and a record passed toResponse.redirect. Before, these passed, and the runtime sent status 200 or 302 and no header. Write{ status: 201 }, orResponse.redirect(url, 301).- The checker now reads
Response?.json(...)andResponse["json"](...)as the constructor call, so the ZTS213 payload check and the return type check run for them.zts check --typesnow declaresResponse.rawJson, andResponseInitdeclaresstatusonly. - A call to
push,pop,shift,unshift, orspliceon a module-scope array now raises ZTS310. Before, only an assignment raised ZTS310, soseen.push(1)keptstate_isolatedproven while the handler returned 2, 3, 4 for identical requests. Copy the array into a local, or move the state tozttp:cache. - A
pushof a request value onto a module array now fails the request withArenaObjectEscape. Before, the module array kept a dangling pointer, and the next request read the wrong string. padStartandpadEndnow throwRangeError: Invalid string lengthfor 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 --jsonand 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 --jsonnow writes the verifier'sunreachable_codeinto the contract. Before, CHECK wrotefalse.- The expert proof read set now holds the schema of the SQLite database that
zttp.jsonnames, not its bytes, and it ignores a database thatzttp.jsondoes not name. Before, a row write during the approval wait failed the commit withProofReadSetChanged, and a database above 32 MiB failed capture withFileTooBig. - 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 withTransactionAlreadyExists, and one damaged receipted record blocked every later acquire. - Expert change sets are safer. A target inside
.zttpis refused. A target that the user edited between prepare and capture fails withProofReadSetChangedinstead of being overwritten. A.DS_Storefile 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-Lengthis a transport failure (BodyTruncated). The local MLX client refuses an abnormalfinish_reason, as the DeepSeek client already did. - The expert REPL refuses an over-long input line whole, and
quit,exit, andhelpact only on the whole line. A failed/resume,/new, or/forkprints its error and keeps the current session. zttp ledger exportand crash recovery now keepcost_boundedandpost_onlyof a verified change set. Before, both were written asfalse.- After
if (r.ok), a read on a Resultvaluewhose type admitsundefined, such asr.value.lengthwithr = ok(req.headers.get("x")), now gets ZTS309. Check the value forundefinedfirst. - 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), "")andrange(3).map(f)passed CHECK and answered 500. Annotate the value or its source, or narrow it withtypeoforisDict. Writefor (const i of range(n))instead ofrange(n).map(f). Response.jsonnow 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, orspliceadds must fit the element type (ZTS203). A tuple refusespush,pop,shift,unshift,splice, and a write tolength. Before,p.name = 5withp: { name: string }passed CHECK, andp.name.toUpperCase()answered 500. An unannotated object or array literal binding widens its literal slots, soconst 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)andn.toString()now get ZTS201. Before, such a handler passed and faulted at runtime withNotCallable. UseString(n). A call of a member onunknown, 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. Uses.charAt(i)ors.slice(i, i + 1). In a union such asstring | string[], the string member addsundefinedto an index read. A member that one union member lacks does the same, such asx.agewithx: P | string. An unchecked read on such a value gets ZTS309. - After
if (!r.ok), a read on theerrorof azttp:validateorzttp:decodeResult, such asr.error.length, now gets ZTS309. A schema failure fillserrorsand leaveserrorabsent. Checkr.errorforundefinedfirst. - 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 areduceaccumulator that refuses the seed or the callback result now get ZTS203. Before, such a handler passed and could fault at runtime withNotCallable. 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 anandThenororElsecallback that does not return a Result now get ZTS203. Before, the runtime returned the value unchanged orundefined, and a handler could fault. Returnok(...)orerr(...). - An arithmetic operand must have a number type.
zts checknow refusesx + 1withx: number | undefinedornumber | null,b.n - 1with an optional fieldn,xs[5] * 2,v * 2withv: unknown, and-xor-bwithb: boolean(ZTS104, ZTS106 for+). Before, such a handler passed, provedoptionals_safe, and could fault at runtime. Compare withundefinedornullin anifand compute inside the branch. For a value that may beundefinedbut notnull,(x ?? 0) + 1also works. A ternary that selects a guarded value and a guarded value captured in a closure are also refused; writex ?? 0there. - A function value now has a function type.
zts checkrefuses a function where the type admits no function: ZTS204 for areturn, 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) => numberand(x: string) => numberare refused where(x: number) => numberis 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 doestypeof x === "object"forx 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
isis 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