midad 0.2.0

generated from midad spec --json at build time; not edited by hand

Install 0.2.0

Download the archive for your machine from this release, check it, and put the binary on your path:

$ curl -LO https://github.com/mdexec/midad/releases/download/v0.2.0/midad-x86_64-unknown-linux-gnu.tar.gz
$ curl -LO https://github.com/mdexec/midad/releases/download/v0.2.0/midad-x86_64-unknown-linux-gnu.tar.gz.sha256
$ sha256sum -c midad-x86_64-unknown-linux-gnu.tar.gz.sha256
$ tar xzf midad-x86_64-unknown-linux-gnu.tar.gz
$ install -m 0755 midad ~/.local/bin/midad

The two macOS archives are in the same release, midad-aarch64-apple-darwin.tar.gz and midad-x86_64-apple-darwin.tar.gz. With cargo, cargo install midad --locked builds the latest published crate; add --version 0.2.0 to pin this one. Every install path is on the install page.

What changed

Summary: A runaway program now stops on a time and step budget, push, set_at and sort change their first argument and answer nothing, and null is a value of its own again.

  • midad new writes a project midad check . accepts again. routes/health.md holds handlers and mounts nothing, which the layout rule refused with E0403 even though mounting from the entry is the only form that serves (a route block in an imported file is E0316). E0403 now fires only when a routes/ file mounts no route and no route in the program names one of its handlers. crates/midad-cli/tests/new_project.rs runs midad new and then midad check through the real binary, which is the path that had drifted.
  • null is a value of its own again, not an alias for the empty option. type_of(null) is null, print(null) is null, is_null(null) is true, is_none(null) is a runtime refusal, JSON null parses to it and round-trips as null. The empty option is None and only None. The C backend compiles the literal; Cranelift refuses it by name for now. Before this, null and None were the same value, type_of said option, and is_null was false for both, so is_null on a JSON null answered the opposite of its name.
  • midad ast no longer panics when its output meets a closed pipe (midad ast big.md | head). The dump goes through the same lossy writer as the other commands instead of println!, which panics on EPIPE.
  • midad run has a limit now. A program that does not serve stops after 120 seconds or 10 billion steps, whichever comes first, and the refusal names the limit and the way past it: R0001: time budget exhausted: this run stops after 120 second(s); pass --no-limit to let it run as long as it needs. Before this, fuel was u64::MAX and there was no deadline, so a runaway while loop pinned a core until someone killed it, while an HTTP request on the same program was bounded. A program that serves (routes, or a granted listen address) is exempt, because it is meant to keep running, and a request keeps its own 50M-step and 2-second budget. Every bench and eval invocation passes --no-limit, so no published number changed meaning. Tests: crates/midad-cli/tests/run_budget.rs; docs/LIMITS.md says the same thing.
  • midad spec describes the language the code has. respond printed two parameters where the runtime takes three, and the header printed "midad 0.1" while midad --version printed 0.2.0, because it was a literal. It now prints the binary version and names the frontmatter key separately as language_version, in both the JSON object and the text header. put and del are marked "mutates": true, which they are. Tests: crates/midad-cli/tests/spec.rs.

  • Breaking (0.2.0): the mutation rule. push, set_at, sort and remove_at now always change their first argument and no longer answer a new container. push(l, v), set_at(l, i, v) and sort(l) answer nothing, so using their result is a compile error with its own code, E0260; remove_at(l, i) answers the element it removed and shortens l.

    // 0.1.x xs = push(xs, 1); // xs becomes a longer list push(xs, 1); // silent no-op: the answer was discarded

    // 0.2.0 push(xs, 1); // xs is one longer xs = push(xs, 1); // E0260: push answers nothing

The old form made a bare push(l, 1); a silent no-op, which is the worst kind of failure to find. midad spec --json marks all four with "mutates": true. Every program in eval/, the examples, the benchmarks and the docs was migrated; a 0.1.x program with xs = push(xs, v) needs the assignment dropped and the statement kept. Both native backends implement it: the C backend grows the list in place and answers unit, Cranelift lowers the statement as the assignment it now means.

  • The C backend compiles a typed local that takes a map value. let s = 0; is a C long, and s = get(m, k) assigned a boxed value into it without unboxing, so cc refused the whole program ("incompatible type for argument 1 of 'mx_rel_v'"). A group-by over a map could not be compiled at all; it now unboxes into the local's declared type, and a typed return does the same. Two tests in crates/midad-native/tests/c_backend.rs compare the compiled output with the interpreter.
  • The benchmark suite has a db workload: a group-by over 200,000 generated records with two aggregates and an ordered report, the CPU side of a query. Measured here, medians of three: interpreter 269 ms, Cranelift 22 ms, C backend 13 ms, Rust 14 ms, Go 10 ms, Node 37 ms. midad loses to Go on this shape and the table in BENCHMARKS.md says so.
  • The benchmark suite can measure a server. bench/workloads/routes.* answers GET /k/:id in midad, Go and Node, and bench/suite.py starts each one, sends 2,000 requests over one keep-alive connection and times them, comparing the last response body the way it compares printed output. Measured here, medians of three: midad compiled handlers 118.3 ms, interpreter 123.5 ms, Go 120.9 ms, Node 299.2 ms. Rust and the C backend are n/a: neither has an HTTP server to measure, and a hand-rolled socket would be a different workload.
  • The benchmark suite has a Rust column. bench/rust is one binary with a workload per argument (loops, fib, strcat, splitjoin, lists, maps), built with cargo build --release and run by bench/suite.py next to Go and Node; a workload without a Rust implementation prints n/a rather than a number for different work. Every row still compares the printed output of all implementations, so a fast-but-wrong result fails the suite. Measured here, one run each: loops Rust 1 ms, C backend 8 ms, Go 6 ms, Cranelift 14 ms, interpreter 357 ms.
  • The line a server prints when it falls back to the interpreter no longer begins with --native-handlers:, a prefix from when the flag was opt-in. It reads midad: route handlers stay interpreted: ... run cc: No such file or directory, which is what happened; the flag prefix is kept only when the caller asked for the flag and it could not be honoured.

  • A program that serves compiles its route handlers by default. The native-handlers feature is now on by default, and midad run --listen uses it without being asked: the flag was opt-in while the backend was new, and a server that quietly ran the interpreter was the slow path nobody chose. A machine with no C compiler, or a handler the C backend refuses by name, falls back to the interpreter with one line on stderr instead of failing to serve; --no-native-handlers asks for the interpreter, and --native-handlers still fails loudly if it cannot be honoured. Test: the_default_serving_path_compiles_the_handlers in crates/midad-cli/tests/native_handlers.rs, which checks that the handlers library is mapped into the default server and that a request goes through it.

  • The benchmark suite can be recorded, and CI runs it. bench/suite.py takes --json PATH (per workload and per implementation: median, fastest, slowest, and the spread between them), --reps N and --only NAME, and prints the spread next to Go and Node on every line. .github/workflows/bench.yml runs it nightly on a shared runner and keeps the record as an artifact with a summary; it does not gate on the numbers, because a shared runner cannot reproduce the one-vCPU session in BENCHMARKS.md. The eval harness now runs on every push: eval/run.py --refs for the reference solutions in both languages, and eval/coverage_cranelift.py for both backends, with the coverage table written into the run summary.

  • One http_get, in midad-net, and no curl in a compiled program. The client (in-process, ureq with rustls) moved out of the interpreter into the same crate as the address rules, so the interpreter and a compiled binary now run the same request code: same 16 MiB body cap, same 30 s timeout, same refusal for a non-public address, same pin through the resolver. midad-core no longer depends on ureq itself, and midad-rt no longer shells out to curl, so a compiled program that calls http_get needs nothing installed on the host. It still does not follow a redirect, because a native build has no permission table to re-check a hop against. Cost, measured on one stripped static binary: a program that never calls http_get is 900,472 bytes, the same program with one call is 5,071,056 bytes, so the client is about 4.2 MB and only a program that fetches pays it.

  • One copy of the address rules, in a new crate. crates/midad-net holds the decision about where http_get may connect: the private-address test, the URL split, the interpreter's net exception, and the pin for the address that was checked. The interpreter asks it with the program's grants, and the runtime inside a compiled binary asks it with no grant list at all, so the SSRF guard is the same code on both paths instead of two copies that had already drifted. A native http_get now also pins the checked address with curl --resolve, so a second DNS answer cannot swap it between the check and the connection. midad-core::netguard is a re-export, and midad-net has its own tests.

  • The documentation now matches the code in the eight places where it did not, and a test keeps it that way. README.md says how a native-handlers build serves routes instead of calling HTTP interpreter-only, and lists db and ai with the other permissions; docs/READINESS.md records db.* on the C path, one interpreter for a state: program, and MIDAD_REQUEST_LOG; docs/SECURITY.md says the audit job runs but cannot fail the build; EVAL.md points at the two runs that were made; docs/REVIEW.md has the current serve.rs size and marks M1, M4 and M5 resolved. crates/midad-cli/tests/docs_claims.rs checks the permission list against Permissions in ast.rs, refuses the stale sentences by name, and fails on a relative link that goes nowhere. New: CONTRIBUTING.md, docs/RELEASING.md, and docs/README.md as the map of the 27 pages in docs/.

  • A compiled binary's http_get checks the address before it fetches. The native runtime resolves the URL's host and refuses any non-public address (loopback, private, link-local, multicast, unique-local, v4-mapped equivalents) with the interpreter's wording, runs curl with --noproxy '*' so the proxy environment is ignored, and answers a named error instead of None when the machine has no curl. It is deliberately stricter than the interpreter: a native build carries no permission table, so it cannot tell a host the program named from one it did not, and it refuses every private address rather than granting one. The rules are written twice for now; one crate for both is the next step. Test: a_compiled_binary_refuses_a_private_address in crates/midad-native/tests/four_paths.rs.

  • The server has a header read timeout and a connection ceiling. A request whose headers have not arrived within 10 s is closed (header_read_timeout on hyper's http1 builder, which also bounds an idle keep-alive connection), and a connection past MIDAD_MAX_CONNECTIONS (4096 by default) is answered 503 Service Unavailable and closed immediately instead of being queued, so a client that opens sockets one byte at a time cannot hold a task and a file descriptor each. Both limits have an environment override so the tests can drive them in a second rather than ten. Tests: a_half_sent_request_is_closed_by_the_header_timeout and past_the_connection_ceiling_the_next_one_gets_503 in crates/midad-cli/tests/serve_limits.rs. tokio gains the io-util feature for the 503 write.

  • A single file read or write is capped at 16 MiB, the ceiling http_get already puts on a body. The cap is checked with metadata().len() before the read and again on what came back, so a file that grows mid-read is still refused, and going over it is a named runtime error ("read_file refused \"...\": N bytes is over the 16 MiB (16777216 byte) limit") rather than an allocation the OS has to kill. write_file and fs.write refuse contents over the same cap before touching the file, and midad-rt's read and the C backend's mx_read_file carry the same message. Tests: reading_a_file_over_the_cap_is_a_named_error, a_file_under_the_cap_still_reads and writing_more_than_the_cap_is_a_named_error in crates/midad-core/tests/limits_memory.rs.

  • An exact fs_read/fs_write grant is decided on canonical paths now, the way a directory grant already was. The runtime compared the target as text and returned early, so replacing a granted file with a symlink made read_file return what the link pointed at. The grant now names a slot: its parent resolved, its own name kept. A symlink standing at that name is refused, a grant under a symlinked directory still works, a granted file that does not exist yet can still be written, and a granted path that does not exist answers None on read rather than "denied". Tests: a_symlink_at_the_granted_path_is_refused and an_exact_grant_writes_a_file_that_does_not_exist_yet in crates/midad-core/tests/fs_grants.rs.

  • The Cranelift backend builds eight more builtins: starts_with, contains, trim, upper, lower, replace, substr and chars, each a call into midad-rt that runs the same std method the interpreter runs. The measured count goes from 23 of 72 to 31. Byte-identical on every pinned vector in string_helpers_agree_on_every_path, including Unicode case mapping (upper("ß") is SS) and substr counted in characters rather than bytes. eval/coverage_cranelift.py takes --backend c now: the C backend builds 46 of the 72 and refuses starts_with, substr, upper and lower by name, which is the next work item. Building the archive matters: cargo build -p midad does not rebuild libmidad_rt.a, so a new runtime symbol is an undefined reference until cargo build -p midad-rt runs too.

  • The Cranelift backend's builtin coverage is a measurement now instead of a sentence. eval/coverage_cranelift.py walks every builtin midad spec --json reports, gives each three argument profiles and three call shapes, and asks the Cranelift backend to build a one-line program that calls it. Of 72 builtins, 23 build, 39 are refused by name, 9 cannot be measured from a bare program (they need a permissions: grant or an html: template) and time.now would not type. docs/NATIVE.md carries the table with the names. docs/LIMITS.md no longer claims Cranelift refuses state blocks and ai intents: it builds both, and refuses par.

  • midad spec --json describes the language from the tables the checker uses: the types, every builtin with the types it accepts and the one it returns (72 of them, from the checker match), the operators that differ from other languages (/ is a float, idiv floors, // is a comment, 1 == 1.0 is a compile error), the canonical layout, and how many diagnostic codes exist. midad spec prints the same thing as text. check::BUILTIN_NAMES is the enumerable list and crates/midad-core/tests/builtins.rs reads the match out of the source, so a builtin added to one and not the other fails the suite instead of quietly missing from the spec. Tests: crates/midad-cli/tests/spec.rs.

  • Every response midad renders now carries content-security-policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; object-src 'none'; base-uri 'self'; frame-ancestors 'none' unless the route set its own policy, so a page built from templates and user data cannot run an inline script that came from either. A file served from the static: directory is exempt: it is the site's own document, and a policy midad wrote could break a page midad did not write. It still gets nosniff, and the internal marker that tells the two apart is removed before the response leaves. Tests in crates/midad-cli/tests/serve_form.rs, including a served HTML file with an inline script that keeps its own policy.

  • midad explain CODE prints one diagnostic: the code, its severity, the message template and the fix the checker attaches. midad explain with no code prints the whole table (96 codes), and --json gives {code, severity, message, fix}. It reads docs/DIAGNOSTICS.md, embedded in the binary, so the table a model queries and the document a person reads are one table. The command does not panic when its reader goes away (midad explain | head). Tests: crates/midad-cli/tests/explain.rs.

  • The canonical project layout is enforced where it changes what the program does: E0402 a file that mounts a route: block but is not under routes/ (and is not the entry), E0403 a file under routes/ that mounts no route, E0404 two files declaring the same module:. Each carries the exact fix, naming the file to write or the file that already owns the name. A module at the project root is still a warning (W007), not a refusal: taste stays advice. The shape midad new writes passes the rules, which is a test. Tests: four cases in crates/midad-core/tests/project.rs.

  • midad build --json and midad run --json print the same object midad check --json prints, so a caller reads one shape from every command. phase says how far the command got: load, check, backend, execute or serving. build adds out (the artifact written) and backend (c, cranelift or bundle); run adds output, the program's own print output, captured into the object rather than streaming past it, and command_name when a declared command ran. A failure with no place in a file (an unknown flag, a missing toolchain, a refused --listen) becomes a diagnostic with code: null and a fix where there is one, so json mode never writes free text to stderr. A program with routes keeps streaming, because its output belongs to the requests: the object is printed when the server starts, with listen and workers, and a later fatal error can only reach stderr. --json with --watch is refused, since watch streams a program. Text output and exit codes are unchanged. Tests: crates/midad-cli/tests/cmd_json.rs; the shape is documented in docs/DIAGNOSTICS.md.

  • midad check --json prints the same diagnostics the text report prints, as one object with a stable shape: code, severity, message, file, line, column, end_line, end_column, expected, actual, fix, plus ok, files and a summary. A field that does not apply is null, never absent. expected and actual are filled where the checker knows both sides (E0230 type mismatch, E0121 unknown type, E0300 permission: the granted list and the target the call needs) and are null elsewhere. Exit codes are unchanged. New docs/DIAGNOSTICS.md lists every code with the message template and the fix the checker attaches; crates/midad-core/tests/codes.rs fails if a code is emitted and not documented, or documented and no longer emitted. Tests: crates/midad-cli/tests/check_json.rs.

  • db.* works in a C-backend build (midad build --backend c, --native-handlers): db.open, db.close, db.query, db.exec, db.begin, db.commit, db.rollback, with the interpreter's error text and its 10,000-row ceiling. The library is loaded at run time with dlopen (libsqlite3.so.0, libsqlite3.so, libsqlite3.dylib, sqlite3.dll), so nothing links a database and a machine without SQLite gets a refusal that names it; Linux builds now pass -ldl. Cranelift and midad-rt still refuse db.* by name. Differential test db_matches_the_interpreter_in_a_c_binary runs one program on both paths and compares the output line for line.

  • A SQL NULL column is now the language's null, not an empty option: it prints null, type_of answers null, is_null is true, and unwrap_or treats it as present, which is what the interpreter always did. The C runtime had one tag for both, so it printed None and reported option for a SQL null; MX_NULL is a tag of its own now, and type_of of an empty option answers option there instead of null. is_null is covered by the C backend for the first time. The value-tag numbers are a wire protocol with the host (native_routes.rs), so a new tag goes at the end of the enum; inserting one in the middle made every compiled handler answer 500 until the native_handlers test caught it.
  • A native build refuses a db: ["*"] grant, and a directory grant in db, for the same reason it refuses them for fs_read and fs_write: there is no permission table in a compiled program, so a grant that covers more than one exact file would compile into unbounded access.

  • db.begin(conn), db.commit(conn), db.rollback(conn) (issue #8, item 2): a multi-step change lands together or not at all. Interpreter only; the native backends refuse db.* by name as before. Tests in tests/db.rs.

  • Merged after review (#9, #10, #11): the VM now pushes the value of a short-circuiting and/or (the new differential case fails without the fix), W002 no longer fires on an aliased import inside the project, and request.int_field reads an integer from JSON or a form. Added tests/request_int.rs and a README line for int_field.
  • Native backends apply the interpreter's string (64 MiB) and list (4,194,304) caps on + and push, with the same error text, so doubling a string ends in a runtime error, not an OS kill (reproduced on the C backend: out of memory; on Cranelift: SIGKILL). C backend replace is capped too. Four-path tests string-cap, list-cap.
  • http_get runs in-process (ureq, rustls) instead of shelling out to curl: no curl needed, no proxy variables, no ~/.curlrc, address pinned through the resolver, manual redirects checked against net, 16 MiB cap. Release binary +2.2 MB (9.43 to 11.61 MB). New tests/http_client.rs. The native runtime still uses curl.
  • Server: query string and form body limits (8 KiB query, 128/1,024 fields, 256-byte names, 4 KiB query values) and a 400 for a malformed % or non-UTF-8 escapes, which used to stay literal. HEAD now runs a GET route and sends no body. Tests in serve_form.rs and serve::form_tests.
  • Map keys() order: the C backend already sorted (the LIMITS note was stale). Added the keys-sorted four-path test and corrected LIMITS.md and ROADMAP.md.
  • docs/ROADMAP.md now records the owner's full technical review (Arabic, Dec 5): type system, one IR for every backend including a WebAssembly one, security architecture, the AI-native layer and its evaluation design, memory, concurrency, ecosystem, reference applications, Markdown identity, phases and open questions. The language server stays paused. It is a record, not a schedule.

  • Every response now carries x-content-type-options: nosniff and referrer-policy: no-referrer unless the route set its own value for either (a header in respond(status, body, headers) wins). MIDAD_REQUEST_LOG=1 turns on one stderr line per request, midad: GET /path 200 3ms id=mid-..., and an x-request-id response header: the caller's own id when it is short and made only of letters, digits, -, _ and . (so a log line cannot be forged with a newline), otherwise a generated one. The query string is never logged. The log is off by default and read once at startup, because a write per request costs throughput on a small box. Measured on GET /big (release, same session, three interleaved rounds each, log off): 250.2 / 236.6 / 239.1 us/req before, 236.3 / 254.6 / 236.2 after, which is inside the noise of this box (about 8%), so no cost was measured for the two headers; the cost with the log on was not measured. Three server tests in crates/midad-cli/tests/serve_form.rs.

  • docs/ROADMAP.md records what is planned and not built, each item next to what exists today: typed collections, records, test blocks, closures, payload-typed results, package versioning, structured diagnostics, an OS sandbox, whole-heap limits, an in-process HTTP client, a native permission table, server hardening, a single stdlib table for parity, and a repeatable AI evaluation. It is a list, not a schedule.

  • Directory file grants: fs_read: ["data/"] and fs_write: ["data/"] (or "data/**") allow everything under a directory, decided at run time on canonical paths, so .. and symlinks that leave the directory are refused; a write to a new file is decided on its canonical parent. A computed path (read_file(p)) is now accepted by the checker under a directory grant, where before only "*" allowed it, so a program that needs a computed path no longer has to hand out the whole filesystem. Exact paths and "*" behave as before. The native backends refuse a directory grant by name, for the same reason they refuse "*". Eight tests in crates/midad-core/tests/fs_grants.rs (inside, deep, **, ../, a same-prefix sibling data2/, a symlink to a file and to a directory outside, a missing file under the grant, new-file writes inside and refused outside, checker on literals, old grants unchanged) and one native refusal test. Not covered: a swap-to-symlink race between the check and the open.

  • CI gets two advisory jobs: the test suite on macos-latest (the release workflow ships macOS builds, the Linux job never ran on one) and cargo audit. Both are continue-on-error until a first run shows what they say; neither has run yet, so this entry makes no claim about their result.

  • Three findings from an external read of 3a45e02, each reproduced before it was fixed. (1) Nesting: 16,000 (, [, {, nested calls or unary minus aborted midad check with a stack overflow; expressions deeper than 256 levels and blocks deeper than 64 are now E0100 / E0102. (2) Memory: forty s = s + s steps were killed by the OS (exit 137 under ulimit -v) because fuel and the deadline bound CPU, not memory; + on strings, replace and push now stop at 64 MiB and 4,194,304 elements with a runtime error. This is a per-operation cap, not a heap budget, and the native backends do not apply it. (3) http_get: a granted hostname that resolves to a loopback, private or link-local address (for example 169.254.169.254) was reachable. The address is now checked, "*" never allows a private one, a program that needs a local service names it in net as an IP literal or localhost, and the checked address is pinned with curl --resolve so DNS cannot change between check and connect. curl also runs with -q so ~/.curlrc is ignored (the native runtime gets -q but not the address check). If your program calls http_get on a local address through "*" or a hostname, add the literal address to net. Tests: nesting.rs on a 2 MiB stack, limits_memory.rs, netguard.rs; one existing test kept its meaning (a URL with no host answers None). LIMITS.md, REVIEW.md and SECURITY.md were corrected where they contradicted the code (one worker per core, not one mutex; error text no longer reaches the client; fuzz-lite and serve tests exist).

  • The JSON writer in the C runtime remembers the last float it formatted and copies the text when the next one has the same bits, instead of calling the formatter again. A list of records that repeats a price (500 maps with "price": 1.5) formatted the same float 500 times. Measured the same session on GET /big, three interleaved rounds, one vCPU, before then after: 248.3 / 249.8 / 248.0 us/req to 232.6 / 234.2 / 236.0, about 6%. The box ran slower than in the earlier arena measurement (136 us then), so only the pair is comparable, not the absolute figures. Output is byte-identical in the interpreter and the native handler for a list with repeated, alternating, negative, large and 0.1+0.2 floats. Both test variants pass (41 suites each) and clippy -D warnings is clean in both. It gives nothing on data whose floats all differ.

  • lib/midad-web/session.md: cookies and a signed session id, in the language. cookie(req, name) reads one value out of the Cookie header and keeps any = inside the value, set_cookie(name, value, path, max_age, secure) builds a set-cookie header with HttpOnly and SameSite=Lax always on, sign(secret, sid) answers sid.<hmac>, verify(secret, value) answers the id or none, and fresh(created, max_age) checks the age against time.now(). The signature is crypto.hmac_sha256, compared over the whole string rather than returning at the first difference, and a cookie that is malformed or signed with another secret answers none instead of failing the request. It is five tests in crates/midad-core/tests/session.rs, which reads the module file itself so a module that drifts from the test fails. What it does not do is written in the file: it does not encrypt, it does not rotate ids, and it does not keep the session on the server, so examples/signin keeps the id in SQLite for that.

  • The request arena is on by default. A shared library with no par now allocates everything a handler makes from its per-thread bump arena and gives the whole call back at the end of it, instead of one malloc and one free per object; MIDAD_ARENA=0 in the environment when the library is built keeps malloc, for measuring the two side by side. The gate was there because the arena was measured on the route that parses a large body, where it loses a little; it is worth far more on the route that builds a large answer. Measured the same session, three interleaved rounds, one vCPU, one keep-alive connection: GET /big (500 maps of five fields, a concat and a two-item list, 33,781 bytes of JSON) went from 186.0 / 188.3 / 186.0 us/req with malloc to 136.0 / 136.5 / 137.3 with the arena, about 27%, and in the four-way comparison in that session Go answers the same route in 84.9 / 85.5 / 86.7, Node in 182.3 / 211.6 / 224.5 and Rust (axum) in 325.3 / 325.4 / 328.2. The 300 KB POST route (parse 5000 objects, answer two fields) goes the other way by about 6%: 1388.6 / 1411.9 without, 1476.5 / 1495.6 with, which is still ahead of Rust (1599), Node (1644) and Go (3773) as measured before. Nothing is given back to the system inside a call, so peak memory is what one call allocates in total, and a thread keeps its blocks between calls. All 40 test suites pass in both variants (73 native tests, including the par ones, which keep malloc), clippy -D warnings clean in both.

  • crypto.pbkdf2_sha256(password, salt, iterations, length) answers the derived key as lowercase hex, and lib/midad-web/passwords.md builds password storage and session ids on it. The derivation is in sha256.rs rather than in the language because a PBKDF2 block index is four big-endian bytes and the language has no byte string to put them in; the builtin pins iterations to 1..=5,000,000 and length to 1..=1024 bytes so one request cannot turn into unbounded work by accident. Verified against the published PBKDF2-HMAC-SHA256 vectors (1, 2 and 4,096 iterations, plus the 40-byte two-block case). The module stores one string, pbkdf2-sha256$<iterations>$<salt hex>$<hash hex>, with 16 random bytes of salt per hash, 600,000 iterations by default (the OWASP figure), a comparison that does not return at the first difference, and a stored value that is not in the format answering false rather than an error. Sessions are random.hex(32) with the creation time kept beside them, and session_fresh checks expiry with time.now(). crates/midad-core/tests/passwords.rs reads the module file itself, so a module that drifts from the test fails. What this does not do is in the module's own words: it does not stop an offline attack on a stolen database, and it does not rate limit or lock accounts.

  • SQLite, behind a parameterized-only surface: db.open(path), db.query(conn, sql, params), db.exec(conn, sql, params) and db.close(conn), with a new db: permission that names the files a program may open. There is no API that takes a query with values already in it: every element of params goes through sqlite3_bind_*, so a value cannot become SQL, and a list or a map in params is an error naming the position rather than a stringified value. A connection is a number in a table the runtime owns, because the language has no structs; a handle that was never opened, or was closed, is an error naming it. A result set past 10,000 rows is an error that names the cap instead of a truncated list. The library is reached through libloading at run time (the box cannot fetch crates and has no SQLite header), so a program that never calls db.* carries no database dependency, and a machine without the library gets a refusal that names it. Verified in crates/midad-core/tests/db.rs: a hostile value (a'); drop table users; --) round trips byte for byte, the table it was written into still exists, every parameter type comes back as its own type, a collection parameter is refused, a 20,000-row query hits the cap, an ungranted path is E0300, and an unknown handle is an error. The C backend does not carry these builtins yet and refuses them by name, which docs/DATABASE.md states rather than implying parity.
  • Five builtins for accounts: crypto.sha256(s) and crypto.hmac_sha256(key, msg) (both answer lowercase hex), hex.encode(s), hex.decode(s) (an option: None when the text is not hex, has an odd length, or decodes to bytes that are not valid UTF-8), and random.hex(n) (n bytes from the kernel's generator, hex encoded, capped at 1024). SHA-256 and HMAC-SHA-256 are written out in crates/midad-core/src/sha256.rs and in c_runtime.h rather than linked, so a compiled program carries no crypto dependency and the two paths are the same short algorithm; both are pinned to the published vectors (FIPS 180-4 including the 1,000,000-'a' digest, RFC 4231 including a key longer than the block) in unit tests, and four_paths.rs holds the interpreter and the C backend to those same literal bytes so two implementations agreeing on a wrong answer cannot pass. random.hex has no fallback: a program that cannot read /dev/urandom stops with midad runtime error: random.hex cannot read /dev/urandom instead of handing out a token that looks random. Cranelift does not carry these yet and refuses them by name, which is what the C backend does for anything it has not implemented. This is the piece docs/READINESS.md named as blocking for real accounts: sessions need tokens, and passwords need a hash.
  • A route a compiled handler answers no longer has its body parsed twice. The server used to parse every body with serde before routing, and the compiled path then read the value through the FFI; now the route table records which routes a compiled handler answers (Routes::from_program takes whether a native backend is loaded, so an interpreted server is unchanged), and for those the body's bytes go to the runtime unparsed. If the compiled path declines, handle_raw parses the bytes itself before the interpreter sees the request, and a body that will not parse answers 400 exactly as before. Measured on the 300 KB POST route (5000 objects, 500 requests, three runs, one vCPU, one session): compiled 5.37 ms to 2.41 ms, and with Go and Node measured in that same session, midad compiled at 2.41 ms is now faster than Go's 3.84 ms (1.59x) and behind Node's 1.59 ms (1.52x); midad's own interpreter takes 4.68 ms on the route. Because the box was about 1.25x slower than the session before (Go read 3.06 ms there and 3.84 ms here), the like-for-like gain on the compiled path is about 2.8x. The parity suite covers it: its POST routes, including a body with floats, a null, a nested map and a form body, must answer byte for byte as the interpreter does, and they do. 459 tests (462 with native handlers) pass, clippy clean in both variants. One bug caught by that suite before anything shipped: the route table marked routes as compiled-served from the program alone, so an interpreted server also skipped the parse and a handler reading req["body"] saw none.
  • A compiled handler's request body is parsed in the C runtime from the bytes that arrived, instead of being rebuilt value by value through the FFI. The server still parses the body itself to route the request, but the compiled path now takes the raw bytes (RouteRequest::body_raw, threaded from the server) and mx_ffi_req_body_json reads them in one pass into the values the interpreter would hold: an object is a map, an array is a list, a number with no fraction and no exponent is an int and anything else a float, escapes decode including surrogate pairs, null is none, and nesting past 64 or any text it does not accept returns -1 so the old value-by-value path still answers. Measured on a 300 KB POST body (5000 objects, five fields each, a handler that reads body.items), 500 requests, three runs, one vCPU: the compiled path went from 9.24 ms to 5.37 ms per request, but the box was about 1.5x faster in the second session (the interpreter read 5.51 then and 3.50 now), so the like-for-like gain is about 9%: the FFI walk was not the dominant cost, the server's own serde parse is, and it is paid by both paths. Against the same session: Go 3.06 ms, Node 1.22 ms, midad interpreted 3.50 ms. So this is not a win over either yet, and the next step is to stop parsing the body twice. All 459 tests (462 with native handlers) pass, the parity suite's POST routes hold the compiled answer to the interpreter's byte for byte, and clippy is clean in both variants. A use-after-free was found and fixed on the way: the runtime's autorelease pool owns the first reference to every value it makes, so releasing it here freed the body tree while the request still pointed at it (a hard abort without the arena, silent corruption with it, caught by AddressSanitizer).
  • A request's objects come from one bump arena instead of one malloc and one free each. With MIDAD_ARENA=1 in the environment when the library is built, the C backend emits MX_ARENA and a shared library allocates everything a handler makes from a per-thread arena of 256 KiB blocks: the allocation is a pointer add on a block the thread already holds, and the whole call's objects go back in one step at the end of the call. Each allocation carries its size in the sixteen bytes before it, because a buffer that grows has to copy its old bytes and the arena has no other way to know how many there are; mx_free range-checks, so arena memory is left for the reset and everything else is a real free. Off by default, and only for a shared library with no par: a par program allocates on other threads, and a program built into an executable has no call to reset at. The request maps the bridge keeps between calls and the request-string block cache are never the arena's, because a reset would take them away; a flag bypasses the arena for them and the arena is switched on inside the handler call itself. Measured, compiled handler, 500 items, 4000 requests, three interleaved server restarts, one vCPU, same session: a 4-key map route 149.3, 149.1, 149.0 us/req without the arena and 117.1, 117.0, 120.1 with it (about 21%), the full route (5 keys, "item-" + str(i), a two-item list) 234.7, 234.1, 249.2 without and 174.2, 173.1, 174.6 with (about 26%). Peak memory is flat at 7.4 to 7.7 MB across eight rounds of 3000 requests, so nothing accumulates. Bodies are byte-identical to the interpreter's, and the parity suites run with the arena on: 459 tests, 462 with native handlers, clippy -D warnings clean in both. What it costs: inside a call nothing is given back to the system, so peak memory is what the call allocates in total rather than what it holds at once, and a thread's blocks are kept between calls but not freed when the thread exits.
  • A literal map's slot table is the size its entries need. map_slots now picks 8 slots for up to 5 keys and 16 for up to 11, and mx_map_tmpl takes that capacity, so the runtime allocates and zeroes only the slots the literal uses; before, every literal map started at the 16 slots mx_map_new picks even when it held one key. Measured on the probe set, compiled handler, 5000 requests, three interleaved rounds, one vCPU, same session, against the run before this change: one-key maps 68.6 to 64.2 us/req, two-key 82.3 to 77.2, three-key 104.1 to 98.8, four-key 125.3 to 120.4, and the full route (five keys, a concat, a two-item list) 192.6 to 186.3. That is 4 to 6% on every literal map route, which says the cost was the allocation and the zeroing of the unused half, not the cache lines the entries land in: the four-key map gained no more than the one-key map. Bodies are byte-identical to the interpreter's. All 459 tests (462 with native handlers) pass, clippy clean in both.
  • A map literal's slots are laid out at compile time. The keys of a literal are strings the compiler knows, so map_slots runs the runtime's own hash and probe (FNV-1a, linear probing, the 16 slots mx_map_new starts with) and emits the slot each entry goes to; mx_map_tmpl then fills those slots directly instead of hashing and probing every key at run time. Only for a literal whose keys are all distinct string literals and which fits before mx_put would have grown the map (11 entries); anything else still emits mx_map_lit and takes the put loop. The runtime's mx_hash and map_slots have to stay in step, which both say. The gain is smaller than the probe measurement suggested: on the 500-item probe set, compiled handler, 5000 requests, five interleaved rounds, one vCPU, a 4-key map route went from 109.5 to 105.7 us/req and the full route (5 keys, a concat, a two-item list) from 200.1 to 192.6, about 4%; the per-key cost I attributed to hashing is mostly the value copies and the JSON writer, not the hash. Bodies are byte-identical to the interpreter's. All 459 tests (462 with native handlers) pass, clippy clean in both.
  • str(i) no longer goes through snprintf. mx_fmt_long writes the decimal digits itself, including the sign and the smallest long, which the two's complement trip (-(v + 1) then + 1) handles without overflowing. The text is the same, which the parity suites and a byte comparison of a 500-map route hold. Measured on the probe set from the entry above, compiled handler, 5000 requests, five interleaved rounds, one vCPU: the route with "item-" + str(i) went from 175.6 to 163.0 us/req median (control 135.0), so the string-building cost per item fell from 1.32x the control to 1.21x; the route with that plus a two-item list went from 221.8 to 200.1 (1.48x the control, from 1.67x). Go measured 128 to 135 on the same routes in the same session, so midad is still about 1.5x behind Go there.
  • Two allocation cuts in the C backend's runtime. A list and its items now share one allocation, the way a string and its characters already did (a list literal was a MxList plus an items buffer, so every {... "tags": ["a", "b"] ...} in a loop paid two allocations and two frees; the items are marked inblk, which the free path already understood and mx_push already handles by copying them out before it grows). And s + str(x) is now mx_concat_of(s, x): the value is formatted into the room the result has after s, so the intermediate str(x) string is never built. Emitted only when the left side has no side effects, so the two C arguments can be evaluated in either order. The text is unchanged: on a route that builds 500 maps with "item-" + str(i), a float, a bool and a two-item list, the compiled handler's body is byte-identical to the interpreter's (same md5). Measured on that route, one vCPU, 5000 requests, five interleaved rounds, compiled handler: 221.8 us/req median after, against a control route with the same maps but no list and no concat at 133.1, so the two costs together fell from 1.93x the control to 1.67x. Go answers the same route in 128 to 135 and Node in 101 to 142 in the same session, so midad is still about 1.6x behind Go here. All 459 tests (462 with native handlers) pass and clippy is clean in both variants.
  • The C backend is six files instead of one 2,105-line file, with no change in what it emits. c_backend.rs (230 lines) keeps the value types (Cty and its helpers), the Emitter struct and the re-exports; the emitters are in c_backend/expr.rs (302: expression typing, coerce, expr, the call path), c_backend/builtin.rs (481: builtin result types and lowering, the html ops), c_backend/stmt.rs (370: blocks, scopes, returns, par workers), c_backend/analyze.rs (314: par ids, literal pooling, C name checks) and c_backend/build.rs (434: write the C, run cc, name the routes). The methods that moved to sibling modules are pub(super); the public functions are re-exported, so midad_native::c_backend::build_program_c and the rest are where they were. All 459 tests (462 with native handlers) pass, clippy is clean in both variants, and the compiled-output parity suites are untouched. unshit 0.11.1: 7 oversized-file warnings before, 6 after.
  • The parser is four files instead of one 1,527-line file, with no change in what it accepts. parse.rs (565 lines) keeps the entry points: frontmatter, fenced-block splitting, expression and signature parsing, and the native: and ai: block readers. The block parser moved to parse/block.rs (297 lines: the line walker and nested statement lists), with parse/block/stmt.rs (513: one line into a statement, including the one-line if (cond) { body } form) and parse/block/decl.rs (172: function, its signature, and type blocks). All 459 tests (462 with native handlers) pass, clippy is clean in both variants, and the parity suites are untouched. unshit 0.11.1: 99/100 with 8 oversized-file warnings before, 7 after; the parser is no longer on that list.
  • A compiled handler's list or map answer is now written to JSON by the library in one call (mx_ffi_json), instead of the server reading it back value by value through the bridge. Profile of the 500-map route before: handler call 90 us, read-back and JSON 102 us, freeing the call's objects 27 us (of about 260 total). The library's writer produces keys in byte order, integers, booleans, escapes and nesting exactly as before and asks the server to format floats (the same serde_json code), so the text is the same. Anything it does not handle exactly (a non-ASCII string or key, nesting past 64, an option inside an option) returns -1 and the server reads the value the old way. The parity test gained a /rich2 route (ASCII-only, so it takes the new writer: 40 maps with floats, escapes, control characters, booleans, nested maps and lists, an empty map and string); /rich (non-ASCII) keeps covering the fallback. Measured on the 500-map, 45 KB route, one vCPU, 3 runs of 4,000 requests, same session: compiled 254, 265, 270 us/req before, 202, 205, 212 after (about 21%), and the bodies are byte-identical (same md5) to the interpreter's. Compiled and interpreted are now level on this route (interpreted 205 to 237 in the same session); compiled does NOT beat it. Go and Node were not measured in this session. The handler call itself (building 500 maps in the library, 90 us) is the next cost.
  • Two more allocation cuts on the bytecode path. "lit" + x and "lit" + str(x) build the result in one string of the right size (the literal used to be copied, then grown, and str(n) made a string of its own that was then thrown away; a number is now written straight into the result), and push(xs, v) on a list in a slot appends directly instead of going through the call dispatch and two temporary vectors. Errors and values are unchanged (a differential shape covers str of ints, negatives, floats, bools, lists, a string and the empty prefix, and a loop that keeps an alias to a list it keeps pushing to). Measured on the 500-map, 45 KB route, interpreted, 3 to 4 interleaved runs of 3,000 requests, one vCPU: 380 to 444 us/req before, 307 to 325 after (about 15 to 20%). Same session: Go 262 to 266, Node 325 to 336. Interpreted is now ahead of Node and about 1.2x behind Go on this route. The native handler on the same route is NOT improved: 427 to 457 before, 436 to 447 after, which is now slower than the interpreter here. Its cost is building the library's handle graph and walking it back, not the interpreter.
  • A list or map literal made only of literals (["a", "b"], {"k": [1, 2]}, nested) is built once when the block is compiled and each evaluation clones the Arc, instead of allocating the strings, the vector and the tree again. Collections are copied on write, so push/put/del on a variable that holds one still copy it first and the literal stays as written (four new differential shapes: repeated in-place calls on a constant list and map, a constant inside a loop, duplicate keys and empty literals). Measured on the 500-map, 45 KB route, interpreted, 3 interleaved runs of 3,000 requests, same session (one vCPU, a faster session than earlier ones, so compare only within this row): 386, 384, 377 us/req before, 307, 298, 301 after, about 22%. Go measured 167 and Node 207 to 215 in the same session, so interpreted is now about 1.8x behind Go and 1.4x behind Node, down from about 2.3x and 1.8x. Compiled handlers are unaffected.
  • A program with no state: is answered by one interpreter per core instead of one for the whole server. Requests used to queue on a single interpreter lock however many cores the machine had. midad run now builds available_parallelism interpreters (at most 64; MIDAD_WORKERS=N overrides, 1 turns it off) when the program declares no state and does not use native handlers; a request takes the first free one. A program with state: keeps exactly one, so every request still sees the same state (a_program_with_state_still_counts_every_request_exactly_once: 8 clients, 160 increments, final count 160). Not measured for speed-up: this box has one vCPU, so the only thing measured is that the pool costs nothing (500-map route, interpreted, MIDAD_WORKERS=1 461 to 486 us/req, MIDAD_WORKERS=4 463 to 471). Native handlers still use one interpreter. Multi-core throughput against Go and Node is still unmeasured.
  • Map keys are shared, not copied. Value::Map is now BTreeMap<Key, Value> where Key wraps an Arc<str> (it derefs and borrows as str, so get(m, "k") lookups are unchanged). A map literal in the bytecode path clones the key set's Arcs instead of allocating a String per key per map. Measured on the 500-map, 45 KB route, one vCPU, 3 interleaved runs of 3,000 requests: interpreted 549 to 561 before, 462 to 464 after (about 16%); compiled handlers 424 to 437 before, 423 to 441 after (no change, their maps are built inside the library). Go is at about 255 in the same kind of session, so interpreted is now about 1.8x behind. Full tests (457 default, 460 with native handlers) and clippy in both variants are clean.
  • The native JSON write-out no longer copies each map key into a new String (it borrows the library's bytes unless they are not valid UTF-8). The 500-map route, compiled: 490 to 426 us/req, 13% (3 runs each, same session, interpreted 557 to 570 unchanged; Go 254 to 260 in the same session). Output is unchanged and held by the /rich parity route.
  • The bytecode path covers list and map literals, push/put/set_at/remove_at/sort/del on a variable, respond, function parameters, and a return inside a function body. A function that built a list of maps used to fall back to the tree walker entirely (the compiler refused push, literals, parameters and a return after a let). The in-place calls keep the tree walker's rule: with a variable as the first argument the collection is taken out of its slot, changed in place when nothing else holds it, and stored back, so let ys = push(xs, 2) still changes xs the way it always did. Map literals compile only with string-literal keys; anything else still goes to the tree walker. vm_disabled now also turns off compiled function bodies, so the differential tests really compare two engines; functions_with_collections_agree_between_paths runs 12 function shapes (maps and lists built in loops, duplicate keys, a parameter list the caller must not see changed, aliasing through push, put/del, set_at/remove_at/sort, a return from inside a loop, respond with a built body, reading a request map, nested literals with escapes, an overflow error) on both and requires the same output or the same error. Measured on the 500-map route, interpreted, same session: 619 us/req before, 560 after, about 10%; compiled handlers 480 to 490 (unchanged). Go is at 250 to 260, so the gap is still about 2x. The remaining time is allocation (a String per literal, per key and per str(i)) and the call path, not instruction dispatch.
  • A compiled handler's non-string answer is written to JSON text straight from the library's memory. The server used to copy the handler's maps and lists back into interpreter values (a String per key and per string, a tree node per entry) and then print them. NativeRoutes::write_json now walks the library's values and writes the text, with floats and strings going through serde_json and keys sorted, so the bytes are what the interpreter's answer is; Response::body_json carries the text to the server. A string body keeps its old handling. The parity test gained a /rich route (nested maps and lists, escapes, unicode, tiny and huge floats, an empty map and list, a large negative integer) that the interpreter and the compiled handler must answer identically. Measured on the 500-map, 45 KB route (one vCPU, 3 interleaved runs of 3,000 requests, a slower session than earlier ones, so compare only within this row): interpreted 619 us/req, compiled 480 to 488 (it was slower than interpreted before this), Go 250 to 255, Node 217 to 293. Compiled is now about 22% faster than interpreted there, and still about 1.9 times slower than Go.
  • A response body is written to JSON text in one pass. respond(200, value) used to build a serde_json::Value copy of the whole answer (a clone of every string and key and a heap node per element) and then print it; it now writes the text straight from the value, byte for byte what the old path produced (direct_json_text_equals_the_serde_tree_text holds the two to each other over escapes, unicode, non-finite and extreme floats, options and nesting; str(value) uses it too). Measured on a route that builds 500 small maps and answers with the 45 KB list, interpreted: 800 us/req before, 487 after (3 runs of 3,000 requests, one vCPU); the same handler compiled went from about 900 to 550. Go answers the same work in 166 and Node in 140 to 217, so a response-heavy handler is still 2.3 to 3 times slower than Go: building the maps in the interpreter costs about 424 us of the 487 (the same route that answers only the list length), and a compiled handler pays to copy its maps back into the server. BENCHMARKS.md has the table.
  • Native handlers read the request in place instead of through a request map. The server used to build a req map (method, path, params, query, headers, body) for every request and the bridge then copied it again into the library. When a route has a handler, no before block runs and a native backend is loaded, the server now passes borrowed slices straight to the library (RouteBackend::call_request), which fills five per-thread maps that are cleared and reused, copies strings into a per-request bump arena that is dropped at the end of the call, and reads the reply map back without a second JSON hop. Anything the fast path cannot answer (it returns None) falls through to the interpreter's own path unchanged. Measured, three interleaved runs of 50,000 keep-alive requests on one vCPU: native tiny handler 8.4 us/req before, 7.0 after; interpreted 8.0, Go 8.6 to 8.9, Node 10.0 to 14.1. The native server is now about 20% faster than Go and about 30% or more faster than Node on the tiny route; it is still slower than a bare hyper server (5.3) and a C blocking server (4.4), which is the HTTP stack, not the handler. The parity test now runs twelve requests, adding a prefix * route, a header-reading handler and a handler that puts into req, each required to match the interpreter byte for byte.
  • midad run --native-handlers app.md answers routes that name a handler: from compiled code, in the existing server. The handlers are built into a shared library with the C backend, loaded with libloading (already in the dependency tree through Cranelift, so no new crate is downloaded), and called through a small C bridge that builds the request map and reads the response map; the server, the before blocks and the response rules are still the interpreter's own. It is behind the native-handlers cargo feature (cargo install midad --features native-handlers), off by default, Unix only, and needs cc. Without the feature the flag says so and exits. A runtime error in a handler (integer overflow, division by zero) comes back as a 500 with the message instead of ending the server, because the library's trap jumps back to the call that entered it. A request value the library cannot hold, a Result that succeeded in ctx, is answered by the interpreter. Permissions: the library is compiled from the program that passed the checker, so a literal path or host outside permissions: never compiles, and a computed target needs a * grant, which a native build cannot enforce and now refuses by name (the C backend accepted it before and compiled unbounded access; that is fixed for every C build, not only this one). A program with a state: block is refused by name, because the cells are set up in the main a library does not run. respond(status, body, headers) and respond_html(status, body) with a string body build on the C backend, which handlers need. tests/native_handlers.rs runs nine requests through a real server twice, interpreted and compiled, and requires identical bytes, plus the survival of the server after a trapped handler, the library being mapped into the process, the wildcard refusal and a granted and an ungranted read. Measured: a tiny handler gets no faster (8.4 us/req compiled, 8.0 interpreted, Go 8.9, Node 10.2, because the HTTP stack is the request), and a 20,000-iteration handler goes from 3,551 us to 62 us (Go 41, Node 156). BENCHMARKS.md has the table. Not run on a Mac: the library is built with cc -shared and named .dylib there, which is untested.
  • A map's keys, values and occupancy bitmap come from one allocation, and a new map starts at 16 slots instead of 32. A map was three mallocs and three frees, which is most of what building a request costs a server: on 200,000 requests that each build a request map and call a route handler, 160 ms became 84 ms, with 113 ms from the single allocation and the rest from the smaller default and zeroing only the bitmap. mx_map_grow allocates the same way, so a map that outgrows 16 slots copies once and then behaves as before. No change to what a program computes.
  • A route answered by a named handler compiles to a function a server can call. midad build --native-all --backend c used to refuse any file with a route:; it now exports MxMap *mx_route_<handler>(MxMap *req) for a route written as route:GET /links/:id show, one map in and one map out, with the caller owning both maps and the runtime draining everything the call made before it returns. A route with an inline body, or a handler that is not function h(req: map): map, is refused by name. The binary still does not listen: this is the handler, not the server. a_route_handler_is_callable_through_the_c_abi builds the generated C with a driver that fills the request map the way the server does and holds the compiled handler to the interpreter's answer for the same request. Measured on 200,000 requests that each build the request and call the handler: 164 ms compiled against 304 ms interpreted, with Go at 80 ms and Node at 23 ms on the same work; BENCHMARKS.md has the table and says what dominates it.
  • get, has and keys take a map that came out of another map or a list. req["params"] is a dynamic value, so get(get(req, "params"), "id") was refused by the C backend even though the interpreter indexes it when it holds a map; the three builtins now accept that shape and check it at run time the way the interpreter does. respond(status, body) builds on the C backend too, so a handler can answer.
  • The C backend evaluates operands and call arguments left to right, as the interpreter does. C leaves that order to the compiler, and gcc goes right to left, so a program whose operands call something that reads or writes state computed a different value on the native path: return cur + swap_state() + cur; printed startstartstart+ interpreted and start+startstart compiled, and print(one() + two()) printed the two lines in the other order. An operand or an argument that contains a call is now pinned into a statement expression, the one place in C where the written order is the order that runs; && and || keep C's own sequencing, because pinning them would evaluate the right side when the left one decides the answer. No measurable cost: heavy 678 ms before, 675 ms after, on medians of five alternating runs, and the rest of the workloads are unchanged. four_paths.rs has a row for it, so the three paths are held to the interpreter's order from now on.
  • The C backend refuses push(xs, x) and put(m, k, v) as statements, with the fix in the message. Both answer a new container in the interpreter, so a bare statement throws that answer away and leaves the original unchanged; the C runtime grows the container in place, so the same statement changed what the interpreter does not. The refusal names the two meanings and says to assign the result. A program written this way was not portable before, it just did not say so.
  • The C backend's runtime counts references and frees what it allocates. Every string, list, map and option payload carries a count; a new object starts with one reference, which belongs to the statement that made it, and a variable, list slot, map slot or state cell that keeps the object takes its own and gives it back when it is overwritten, when its scope ends or when its container is freed. A statement that allocates gives its temporaries back when it ends, a return retains its value across the release of the function's scopes, and a parameter is retained by the callee. A split piece is a view into its source, so the pieces share one block that keeps the source alive, and a list of pieces is moved out of that block before it grows, which also fixes a latent bug: pushing onto a split list used to realloc an interior pointer. A program that uses par compiles the counts atomic. Peak resident memory of the template workload was 16.7 MB at 100,000 renders, 32.0 MB at 200,000 and 62.6 MB at 400,000; it is 1.6 MB at all three now, with the runtime's counter at zero live objects on exit. Time did not regress: s1 went 76.6 ms to 61.6 ms and the template row 66.3 ms to 58.5 ms, on medians of five alternating runs of the old and new runtime on one box, and the rows that do not allocate per iteration did not move. BENCHMARKS.md has both tables and docs/LIMITS.md states the model.
  • trim, contains and replace build on the C backend, and upper and lower are refused by name. The five were emitted by the backend with no definition in the runtime header, so cc failed with an undefined function on a program the interpreter runs. trim strips the Unicode space characters a character at a time, contains matches a byte substring and replace replaces every non-overlapping hit, all three matching the interpreter byte for byte. upper and lower refuse instead of mapping ASCII only, because the interpreter maps the whole of Unicode and the C runtime carries no case tables.
  • Two older divergences, found while measuring the above and not fixed by it. The C backend evaluates operands and call arguments right to left, where the interpreter and Cranelift go left to right, so f(a()) + f(b()) prints in a different order and an expression that reads and writes state can compute a different value: return cur + swap_state() + cur; gives startstartstart interpreted and start+startstart compiled. A template's holes have the same ordering caveat, already written down in docs/SPRINTS.md. And push(l, x) as a statement inside a function on a state list leaves the list unchanged when interpreted and mutates it in place when compiled. Both are in the C backend and predate this change.
On this page