From d1e9f19392eae2115ef95408543ed70ee9670615 Mon Sep 17 00:00:00 2001 From: renerocksai Date: Sun, 4 Oct 2026 18:07:22 +0200 Subject: [PATCH 1/3] Port Baz and its pinned dependencies to Zig 0.17.0 --- .github/workflows/ci.yml | 13 ++- .github/workflows/pages.yml | 7 +- .github/workflows/windows-build.yml | 11 +- .github/zig-release.json | 32 +++++ .zig-version | 2 +- AGENTS.md | 2 +- HANDOFF.md | 17 ++- README.md | 23 ++-- build.zig | 50 ++++---- build.zig.zon | 14 +-- docs/APP-API-ROADMAP.md | 10 +- docs/APP-API.md | 4 +- docs/APPLICATION-RECIPES.md | 10 +- docs/CONNECTION-LIMIT-WALKTHROUGH.md | 8 +- docs/CONTINUATIONS.md | 2 +- docs/COOKIES.md | 2 +- docs/DEPENDENCY.md | 4 +- docs/INTERFACES.md | 2 +- docs/JOBS.md | 2 +- docs/MUSTACHE.md | 6 +- docs/REPOSITORY.md | 2 +- docs/STREAMING.md | 2 +- docs/WEBSITE.md | 6 +- docs/api-packages.template.html | 2 +- docs/examples.template.html | 4 +- docs/get-started.template.html | 6 +- docs/highlight-zig.js | 2 +- docs/index.template.html | 2 +- docs/page.template.html | 2 +- docs/read.html | 2 +- docs/vendor/manifest.json | 24 ++-- examples/README.md | 18 +-- examples/cookie_fixture.zig | 2 +- examples/embedding/build.zig | 4 +- examples/embedding/build.zig.zon | 2 +- examples/embedding/src/main.zig | 4 +- examples/endpoint/continuation_fixture.zig | 4 +- examples/endpoint/session_store.zig | 2 +- examples/jobs.zig | 2 +- examples/middleware_fixture.zig | 6 +- examples/support.zig | 2 +- src/App.zig | 130 ++++++++++++++++++++- src/app_demo.zig | 4 +- src/borrow_demo.zig | 5 +- src/cookies.zig | 8 +- src/mustache.zig | 4 +- src/request.zig | 2 +- src/response.zig | 48 ++++---- src/static_bytes.zig | 32 +++++ src/streaming_demo.zig | 8 +- tests/borrow_integration.py | 4 +- tests/cli_integration.py | 4 +- tests/continuations_integration.py | 2 +- tests/cookies_integration.py | 2 +- tests/jobs_integration.py | 2 +- tests/middleware_integration.py | 2 +- tests/mustache_integration.py | 2 +- tests/streaming_integration.py | 6 +- tools/build_pages.py | 12 +- tools/prepare_api_docs.py | 4 +- tools/verify_linux_ssh.sh | 6 +- 61 files changed, 416 insertions(+), 192 deletions(-) create mode 100644 .github/zig-release.json create mode 100644 src/static_bytes.zig diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5669a93..1fc655e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,11 +32,12 @@ jobs: python3 - <<'PYTHON' import hashlib, json, os, pathlib, platform, tarfile, urllib.request version = pathlib.Path('.zig-version').read_text().strip() - assert version == '0.16.0', 'Expected exact Zig 0.16.0' + assert version == '0.17.0', 'Expected exact Zig 0.17.0' architecture = {'x86_64': 'x86_64', 'arm64': 'aarch64', 'aarch64': 'aarch64'}[platform.machine()] system = {'Linux': 'linux', 'Darwin': 'macos'}[platform.system()] - with urllib.request.urlopen('https://ziglang.org/download/index.json', timeout=30) as response: - artifact = json.load(response)[version][f'{architecture}-{system}'] + metadata = json.loads(pathlib.Path('.github/zig-release.json').read_text()) + assert metadata['version'] == version + artifact = metadata['artifacts'][f'{architecture}-{system}'] assert artifact['tarball'].startswith('https://ziglang.org/') directory = pathlib.Path(os.environ['RUNNER_TEMP']) / 'baz-zig' directory.mkdir() @@ -58,9 +59,9 @@ jobs: packet="$RUNNER_TEMP/baz-ci" mkdir -p "$packet" { git rev-parse HEAD; uname -a; zig version; python3 --version; } > "$packet/environment.log" - zig build verify -Doptimize=Debug -j2 --summary all 2>&1 | tee "$packet/debug.log" - zig build verify -Doptimize=ReleaseSafe -j2 --summary all 2>&1 | tee "$packet/release-safe.log" - zig build install examples -Doptimize=ReleaseSafe -j2 2>&1 | tee "$packet/install.log" + zig build verify -Doptimize=debug -j2 --summary all 2>&1 | tee "$packet/debug.log" + zig build verify -Doptimize=safe -j2 --summary all 2>&1 | tee "$packet/release-safe.log" + zig build install examples -Doptimize=safe -j2 2>&1 | tee "$packet/install.log" python3 tests/cli_integration.py --json "$packet/cli.json" 2>&1 | tee "$packet/cli.log" python3 tests/app_integration.py 2>&1 | tee "$packet/app.log" python3 tests/examples_integration.py 2>&1 | tee "$packet/examples.log" diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 57862ac..3f4a303 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -27,11 +27,12 @@ jobs: python3 - <<'PYTHON' import hashlib, json, os, pathlib, platform, tarfile, urllib.request version = pathlib.Path('.zig-version').read_text().strip() - assert version == '0.16.0', 'Expected exact Zig 0.16.0' + assert version == '0.17.0', 'Expected exact Zig 0.17.0' architecture = {'x86_64': 'x86_64', 'arm64': 'aarch64', 'aarch64': 'aarch64'}[platform.machine()] system = {'Linux': 'linux', 'Darwin': 'macos'}[platform.system()] - with urllib.request.urlopen('https://ziglang.org/download/index.json', timeout=30) as response: - artifact = json.load(response)[version][f'{architecture}-{system}'] + metadata = json.loads(pathlib.Path('.github/zig-release.json').read_text()) + assert metadata['version'] == version + artifact = metadata['artifacts'][f'{architecture}-{system}'] assert artifact['tarball'].startswith('https://ziglang.org/') directory = pathlib.Path(os.environ['RUNNER_TEMP']) / 'baz-zig' directory.mkdir() diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 56aea59..d406228 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -26,9 +26,10 @@ jobs: run: | $ErrorActionPreference = "Stop" $version = (Get-Content -Raw .zig-version).Trim() - if ($version -cne "0.16.0") { throw "Expected the exact Zig 0.16.0 baseline" } - $index = Invoke-RestMethod https://ziglang.org/download/index.json -TimeoutSec 30 - $artifact = $index.PSObject.Properties[$version].Value.PSObject.Properties["x86_64-windows"].Value + if ($version -cne "0.17.0") { throw "Expected the exact Zig 0.17.0 baseline" } + $metadata = Get-Content -Raw .github/zig-release.json | ConvertFrom-Json + if ($metadata.version -cne $version) { throw 'Compiler metadata version mismatch' } + $artifact = $metadata.artifacts.PSObject.Properties["x86_64-windows"].Value $url = [string] $artifact.tarball $expected = ([string] $artifact.shasum).ToLowerInvariant() if ($url -notmatch '^https://ziglang\.org/' -or $expected -notmatch '^[0-9a-f]{64}$') { @@ -61,7 +62,7 @@ jobs: Set-Content "$env:RUNNER_TEMP/baz-windows-logs/environment.txt" Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber, OSArchitecture | ConvertTo-Json | Add-Content "$env:RUNNER_TEMP/baz-windows-logs/environment.txt" - foreach ($mode in @("Debug", "ReleaseSafe")) { + foreach ($mode in @("debug", "safe")) { & zig build verify "-Doptimize=$mode" -j2 --summary all 2>&1 | Tee-Object "$env:RUNNER_TEMP/baz-windows-logs/$mode.log" if ($LASTEXITCODE -ne 0) { throw "$mode verification failed" } @@ -71,7 +72,7 @@ jobs: shell: pwsh run: | $ErrorActionPreference = "Stop" - & zig build install examples -Doptimize=ReleaseSafe -j2 --summary all 2>&1 | + & zig build install examples -Doptimize=safe -j2 --summary all 2>&1 | Tee-Object "$env:RUNNER_TEMP/baz-windows-logs/install.log" if ($LASTEXITCODE -ne 0) { throw "ReleaseSafe example installation failed" } foreach ($suite in @("cli_integration", "app_integration", "examples_integration", "streaming_integration", "borrow_integration", "mustache_integration", "cookies_integration", "middleware_integration", "session_integration", "continuations_integration", "jobs_integration", "windows_smoke")) { diff --git a/.github/zig-release.json b/.github/zig-release.json new file mode 100644 index 0000000..917433a --- /dev/null +++ b/.github/zig-release.json @@ -0,0 +1,32 @@ +{ + "artifacts": { + "aarch64-linux": { + "shasum": "9e8d11661d4ae3bd57702a3832781e23ad151dde5798e16a5ccd503f65234ff8", + "size": "52877280", + "tarball": "https://ziglang.org/download/0.17.0/zig-aarch64-linux-0.17.0.tar.xz" + }, + "aarch64-macos": { + "shasum": "b607e9b9234790a008116ae5bdb71c6243b84b9fb42a53a9e70fde41c06c536a", + "size": "53985220", + "tarball": "https://ziglang.org/download/0.17.0/zig-aarch64-macos-0.17.0.tar.xz" + }, + "x86_64-linux": { + "shasum": "1cbe9df9f27e6b78d14ccbca43b6703a404ef79ef1c463de901d7f088d4e2026", + "size": "57332648", + "tarball": "https://ziglang.org/download/0.17.0/zig-x86_64-linux-0.17.0.tar.xz" + }, + "x86_64-macos": { + "shasum": "4f9a1c5269aa17ebda5e6d3c2b89d6cbf36f7d2b22a0306e9ab98f25f95529c6", + "size": "59317572", + "tarball": "https://ziglang.org/download/0.17.0/zig-x86_64-macos-0.17.0.tar.xz" + }, + "x86_64-windows": { + "shasum": "b5663f69581dcf391293fbf16c06cb80d81d806545ce618b4d0bab7f0eb8c428", + "size": "100268137", + "tarball": "https://ziglang.org/download/0.17.0/zig-x86_64-windows-0.17.0.zip" + } + }, + "signature_verification": "Ed25519 prehashed minisign archive and trusted-comment signatures verified against the official download-page public key", + "signing_key": "RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U", + "version": "0.17.0" +} diff --git a/.zig-version b/.zig-version index 04a373e..c5523bd 100644 --- a/.zig-version +++ b/.zig-version @@ -1 +1 @@ -0.16.0 +0.17.0 diff --git a/AGENTS.md b/AGENTS.md index 614b2ec..aef2eb7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # Baz — Bounded Async Zap -Use exact Zig 0.16.0 from `.zig-version`. Baz consumes the separate [bounded/http](https://technologylab-ai.github.io/bounded-http/) +Use exact Zig 0.17.0 from `.zig-version`. Baz consumes the separate [bounded/http](https://technologylab-ai.github.io/bounded-http/) engine through its exported `bounded_http` module. Keep engine parser, transport and scheduler changes in that dependency and submit an upstream PR. This repository owns App, routing, request/form views, responses, examples and their tests. The [Zig wiki](https://github.com/technologylab-ai/zigllmwiki) diff --git a/HANDOFF.md b/HANDOFF.md index e536dd3..6d69866 100644 --- a/HANDOFF.md +++ b/HANDOFF.md @@ -23,7 +23,22 @@ before Baz #6 once their final checks pass. The user explicitly deferred the custom `std.Io` prototype on 2026-09-07. Standard caller `std.Io` and the engine's existing native backends remain in use. -# Baz handoff — 2026-09-06 +# Baz handoff — Zig 0.17 migration, 2026-10-04 + +The `feat/zig-0.17` branch now requires exact Zig 0.17.0. +Its manifest pins matching engine, Mustache, and zli ports to immutable URL hashes. +Engine parser and transport changes are upstream in the separate engine branch. +The migration preserves preallocation, borrowing, cancellation, and assertion requirements. +Public endpoint and state-cleanup hooks are explicit under the new `@hasDecl` visibility rule. + +Local macOS and native `omarx1` gates passed Debug/Safe verification and all maintained Python wire suites. +The final URL graph has separate package-consumer checks. +Hosted native CI records the published branch's Linux, Mac, and Windows results. +Earlier receipts in this file retain their original compiler, revision, and platform scope. +No performance measurement was performed for this migration. +The separate Zig wiki remains on 0.16.0 and receives the agent migration guide after these ports. + +## Earlier baseline — 2026-09-06 Work from the independent `baz` repository, primary branch `main`. Public repository: . diff --git a/README.md b/README.md index 0666562..bed287c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [Website & documentation](https://technologylab-ai.github.io/baz/) · [API reference](https://technologylab-ai.github.io/baz/api/) · [All guides](docs/GUIDES.md) · [API guide](docs/APP-API.md) · [26 examples](examples/README.md) -A **pure Zig** successor to [Zap](https://github.com/zigzap/zap), built in **Zig 0.16.0** +A **pure Zig** successor to [Zap](https://github.com/zigzap/zap), built in **Zig 0.17.0** on [bounded/http](https://technologylab-ai.github.io/bounded-http/). It keeps Zap's typed App and endpoint ergonomics, with explicit memory ownership and simpler request data. @@ -41,7 +41,7 @@ The first implementation provides: - **Mustache templates:** parse once at startup, render typed data directly into reserved HTML response storage. See the [guide](docs/MUSTACHE.md) and [greeting form and user-card example](examples/mustache.zig). - [Verified natively on Linux, macOS, and Windows](reports/2026-09-06-mustache.md). + [Earlier Zig 0.16 native evidence](reports/2026-09-06-mustache.md). - **SSE and producer notifications:** encode events into a standard writer, wake retained callbacks, and choose explicit queue and replay limits. [SSE guide](docs/SSE.md) · [complete job application](docs/JOBS.md) · @@ -73,6 +73,11 @@ See the [repository record](docs/REPOSITORY.md) for branches, history, CI, and p ## Platform support +The Zig 0.17 migration pins the engine, Mustache, and zli to their matching ports. +Local macOS and native `omarx1` checks cover Debug/Safe verification and the Python wire suites. +The earlier feature receipts below retain their original Zig 0.16 compiler scope. +Use this branch's native CI results for the current compiler and dependency graph. + **Linux, macOS, and native Windows x64 are supported.** Baz adds native Windows support beyond [Zap’s facil.io-based platform support](https://github.com/zigzap/zap/blob/master/README.md). Both the framework and its [bounded/http](https://technologylab-ai.github.io/bounded-http/) engine are written in Zig. @@ -83,7 +88,7 @@ Both the framework and its [bounded/http](https://technologylab-ai.github.io/bou | macOS | **kqueue** | | Windows x64 | **IOCP** | -All three platforms passed Debug and ReleaseSafe verification, the independent +The earlier Zig 0.16 baseline passed Debug and ReleaseSafe verification on all three platforms, the independent package consumer, all 14 App groups, all 20 ported-example groups, and all 14 streaming groups—including the runnable example—plus nine large-borrow groups. Windows also passed three @@ -97,7 +102,7 @@ experimental status; this is correctness coverage, not production qualification. Watch a response arrive incrementally: ```sh -zig build run-streaming -Doptimize=ReleaseSafe -- --port 8080 +zig build run-streaming -Doptimize=safe -- --port 8080 # In another terminal; use curl.exe on Windows: curl -N http://127.0.0.1:8080/ ``` @@ -113,10 +118,10 @@ retained memory, bounded by the total response limit rather than staging capacit It selects the whole body; inserting a borrowed image between streaming writes is [currently unsupported](docs/STREAMING.md#current-limit-borrowed-bodies-cannot-be-inserted-into-a-stream). -Use exact Zig 0.16.0 from [.zig-version](.zig-version), with Python 3 installed: +Use exact Zig 0.17.0 from [.zig-version](.zig-version), with Python 3 installed: ```sh -zig build run-app -Doptimize=ReleaseSafe -- --port 8080 +zig build run-app -Doptimize=safe -- --port 8080 ``` In another terminal (use `curl.exe` on Windows): @@ -132,12 +137,12 @@ There are [21 ports of Zap's examples](examples/README.md), including endpoints, authentication, middleware, sessions, Mustache, JSON, query/form data and uploads: ```sh -zig build examples -Doptimize=ReleaseSafe +zig build examples -Doptimize=safe ./zig-out/bin/hello --port 8080 -zig build run-http_params -Doptimize=ReleaseSafe -- --port 8080 +zig build run-http_params -Doptimize=safe -- --port 8080 ``` -All examples use [zli](https://github.com/renerocksai/zli) with Zig 0.16 +All examples use [zli](https://github.com/renerocksai/zli) with Zig 0.17 `std.process.Init` for typed startup options and `--help`. Both `--port 8080` and `--port=8080` work. See the [CLI guide](examples/README.md#typed-cli-options-with-process-initialization). diff --git a/build.zig b/build.zig index c42144d..e97fe30 100644 --- a/build.zig +++ b/build.zig @@ -5,7 +5,7 @@ pub fn build(b: *std.Build) void { @panic("Use exactly the Zig release in .zig-version"); const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - if (optimize == .ReleaseFast or optimize == .ReleaseSmall) { + if (optimize == .fast or optimize == .small) { @panic("This MVP requires Debug or ReleaseSafe so its invariants remain enabled"); } const engine = b.dependency("bounded_http", .{ @@ -29,15 +29,15 @@ pub fn build(b: *std.Build) void { docs_module.addImport("zli", zli); const docs_object = b.addObject(.{ .name = "baz", .root_module = docs_module }); const prepare_docs = b.addSystemCommand(&.{"python3"}); - prepare_docs.addFileArg(b.path("tools/prepare_api_docs.py")); - prepare_docs.addDirectoryArg(docs_object.getEmittedDocs()); - const prepared_docs = prepare_docs.addOutputDirectoryArg("api"); + prepare_docs.addFileArg2(b.path("tools/prepare_api_docs.py"), .{}); + prepare_docs.addDirectoryArg2(docs_object.getEmittedDocs(), .{}); + const prepared_docs = prepare_docs.addOutputDirectoryArg2("api", .{}); prepare_docs.addArgs(&.{ - b.fmt("baz/{s}", .{std.fs.path.basename(module.root_source_file.?.getPath(b))}), + "baz/baz.zig", "std/std.zig", - b.fmt("bounded_http/{s}", .{std.fs.path.basename(engine.root_source_file.?.getPath(b))}), - b.fmt("mustache_engine/{s}", .{std.fs.path.basename(mustache.root_source_file.?.getPath(b))}), - b.fmt("zli/{s}", .{std.fs.path.basename(zli.root_source_file.?.getPath(b))}), + "bounded_http/server.zig", + "mustache_engine/mustache.zig", + "zli/zli.zig", }); const install_docs = b.addInstallDirectory(.{ .source_dir = prepared_docs, @@ -52,8 +52,8 @@ pub fn build(b: *std.Build) void { // for Linux Debug only. ReleaseSafe uses its default toolchain selection. const app_exe = b.addExecutable(.{ .name = "baz", - .use_llvm = if (target.result.os.tag == .linux and optimize == .Debug) true else null, - .use_lld = if (target.result.os.tag == .linux and optimize == .Debug) true else null, + .use_llvm = if (target.result.os.tag == .linux and optimize == .debug) true else null, + .use_lld = if (target.result.os.tag == .linux and optimize == .debug) true else null, .root_module = b.createModule(.{ .root_source_file = b.path("src/app_demo.zig"), .target = target, @@ -64,15 +64,15 @@ pub fn build(b: *std.Build) void { }); b.installArtifact(app_exe); const app_run = b.addRunArtifact(app_exe); - if (b.args) |args| app_run.addArgs(args); + app_run.addPassthruArgs(); b.step("run-app", "Run the application API example").dependOn(&app_run.step); b.step("run", "Run the application API example").dependOn(&app_run.step); const verify = b.step("verify", "Compile and test the exact-version MVP"); const check = b.step("check", "Compile all framework tests and examples without executing target binaries"); const stream_fixture = b.addExecutable(.{ .name = "baz-streaming", - .use_llvm = if (target.result.os.tag == .linux and optimize == .Debug) true else null, - .use_lld = if (target.result.os.tag == .linux and optimize == .Debug) true else null, + .use_llvm = if (target.result.os.tag == .linux and optimize == .debug) true else null, + .use_lld = if (target.result.os.tag == .linux and optimize == .debug) true else null, .root_module = b.createModule(.{ .root_source_file = b.path("src/streaming_demo.zig"), .target = target, @@ -94,8 +94,8 @@ pub fn build(b: *std.Build) void { }); const borrow_fixture = b.addExecutable(.{ .name = "baz-borrow", - .use_llvm = if (target.result.os.tag == .linux and optimize == .Debug) true else null, - .use_lld = if (target.result.os.tag == .linux and optimize == .Debug) true else null, + .use_llvm = if (target.result.os.tag == .linux and optimize == .debug) true else null, + .use_lld = if (target.result.os.tag == .linux and optimize == .debug) true else null, .root_module = b.createModule(.{ .root_source_file = b.path("src/borrow_demo.zig"), .target = target, @@ -109,8 +109,8 @@ pub fn build(b: *std.Build) void { verify.dependOn(&borrow_fixture.step); const cookie_fixture = b.addExecutable(.{ .name = "baz-cookies", - .use_llvm = if (target.result.os.tag == .linux and optimize == .Debug) true else null, - .use_lld = if (target.result.os.tag == .linux and optimize == .Debug) true else null, + .use_llvm = if (target.result.os.tag == .linux and optimize == .debug) true else null, + .use_lld = if (target.result.os.tag == .linux and optimize == .debug) true else null, .root_module = b.createModule(.{ .root_source_file = b.path("examples/cookie_fixture.zig"), .target = target, @@ -124,8 +124,8 @@ pub fn build(b: *std.Build) void { verify.dependOn(&cookie_fixture.step); const middleware_fixture = b.addExecutable(.{ .name = "baz-middleware", - .use_llvm = if (target.result.os.tag == .linux and optimize == .Debug) true else null, - .use_lld = if (target.result.os.tag == .linux and optimize == .Debug) true else null, + .use_llvm = if (target.result.os.tag == .linux and optimize == .debug) true else null, + .use_lld = if (target.result.os.tag == .linux and optimize == .debug) true else null, .root_module = b.createModule(.{ .root_source_file = b.path("examples/middleware_fixture.zig"), .target = target, @@ -141,8 +141,8 @@ pub fn build(b: *std.Build) void { for ([_][]const u8{ "hello", "hello2", "hello_json", "simple_router", "routes", "serve", "sendfile", "senderror", "accept", "app_basic", "app_auth", "app_errors", "endpoint", "endpoint_auth", "middleware", "middleware_with_endpoint", "userpass_session", "cookies", "http_params", "bindataformpost", "streaming", "mustache", "continuations", "jobs", "runtime_file", "decoded_forms" }) |name| { const example = b.addExecutable(.{ .name = name, - .use_llvm = if (target.result.os.tag == .linux and optimize == .Debug) true else null, - .use_lld = if (target.result.os.tag == .linux and optimize == .Debug) true else null, + .use_llvm = if (target.result.os.tag == .linux and optimize == .debug) true else null, + .use_lld = if (target.result.os.tag == .linux and optimize == .debug) true else null, .root_module = b.createModule(.{ .root_source_file = b.path(b.fmt("examples/{s}.zig", .{name})), .target = target, @@ -155,12 +155,12 @@ pub fn build(b: *std.Build) void { examples.dependOn(&install_example.step); b.step(name, b.fmt("Build and install {s}", .{name})).dependOn(&install_example.step); const run_example = b.addRunArtifact(example); - if (b.args) |args| run_example.addArgs(args); + run_example.addPassthruArgs(); b.step(b.fmt("run-{s}", .{name}), b.fmt("Run {s}", .{name})).dependOn(&run_example.step); verify.dependOn(&example.step); check.dependOn(&example.step); } - const format = b.addFmt(.{ .paths = &.{ "build.zig", "build.zig.zon", "src", "examples" }, .check = true }); + const format = b.addFmt(.{ .paths = b.pathList(&.{ "build.zig", "build.zig.zon", "src", "examples" }), .check = true }); verify.dependOn(&format.step); check.dependOn(&format.step); const version = b.addSystemCommand(&.{ "python3", "tools/check_version.py" }); @@ -174,8 +174,8 @@ pub fn build(b: *std.Build) void { if (std.mem.eql(u8, step, "test")) verify.dependOn(&consumer.step) else check.dependOn(&consumer.step); } const test_step = b.step("test", "Run framework unit tests"); - for ([_][]const u8{ "examples/endpoint/session_store.zig", "examples/endpoint/session_options.zig", "src/continuation.zig", "src/mailbox.zig", "src/sse.zig", "examples/endpoint/job_store.zig", "examples/jobs.zig", "src/params.zig", "src/form.zig", "src/cookies.zig", "src/request.zig", "src/multipart.zig", "src/response.zig", "src/router.zig", "src/mustache.zig", "src/App.zig", "src/baz.zig" }) |path| { - const tests = b.addTest(.{ .use_llvm = if (target.result.os.tag == .linux and optimize == .Debug) true else null, .use_lld = if (target.result.os.tag == .linux and optimize == .Debug) true else null, .root_module = b.createModule(.{ + for ([_][]const u8{ "examples/endpoint/session_store.zig", "examples/endpoint/session_options.zig", "src/static_bytes.zig", "src/continuation.zig", "src/mailbox.zig", "src/sse.zig", "examples/endpoint/job_store.zig", "examples/jobs.zig", "src/params.zig", "src/form.zig", "src/cookies.zig", "src/request.zig", "src/multipart.zig", "src/response.zig", "src/router.zig", "src/mustache.zig", "src/App.zig", "src/baz.zig" }) |path| { + const tests = b.addTest(.{ .use_llvm = if (target.result.os.tag == .linux and optimize == .debug) true else null, .use_lld = if (target.result.os.tag == .linux and optimize == .debug) true else null, .root_module = b.createModule(.{ .root_source_file = b.path(path), .target = target, .optimize = optimize, diff --git a/build.zig.zon b/build.zig.zon index f63e7dc..332cfa9 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -2,19 +2,19 @@ .name = .baz, .version = "0.1.0", .fingerprint = 0x78240498d30be4ab, - .minimum_zig_version = "0.16.0", + .minimum_zig_version = "0.17.0", .dependencies = .{ .mustache = .{ - .url = "https://github.com/technologylab-ai/mustache-zig/archive/22487e4082537aa5b707dd902def866d990fdea1.tar.gz", - .hash = "mustache-0.0.1-bbBABwAsCgDDzOEicjx4peKWHmhxxwbzAzhf-UC7wJp1", + .url = "https://github.com/technologylab-ai/mustache-zig/archive/f46006f04a6bb4374a34250fb01fe72daf6a39c1.tar.gz", + .hash = "mustache-0.0.1-bbBABzcvCgC4WuanXnXQ_2MQniNbAeM3FDOWUwntUJgF", }, .zli = .{ - .url = "https://github.com/renerocksai/zli/archive/4f17b1f1eacda7b87c49461e34b1520c392788b2.tar.gz", - .hash = "zli-0.1.1-pechgr4WAQBsw7p7JPU-GHHZ5xsBpEdfCRNpNtnQYnBz", + .url = "https://github.com/renerocksai/zli/archive/36dfe7c506117af0e52533feb549282362b77e2a.tar.gz", + .hash = "zli-0.1.1-pechguIfAQBpzPujkkvs6_TK5FtWmXb3t0TUsswftHvP", }, .bounded_http = .{ - .url = "https://github.com/technologylab-ai/bounded-http/archive/3f0ef4644ddb51092a0580c207fc5e0f2c5de9a0.tar.gz", - .hash = "bounded_http-0.1.0-N3A1uHM2EgBKoC7YKDOd0v0zue5SYOuYGFlD_rIMSPu_", + .url = "https://github.com/technologylab-ai/bounded-http/archive/65d584bf1a00451577235281a290303b10d0ae3b.tar.gz", + .hash = "bounded_http-0.1.0-N3A1uK6sEgBOVsAkQaEi3SYqOUfcF6SDDli1N6ELCyhL", }, }, .paths = .{ "build.zig", "build.zig.zon", ".zig-version", "src", "tests", "tools", "examples", "docs", "reports", ".github", "LICENSE", "README.md", "ROADMAP.md", "HANDOFF.md", "AGENTS.md" }, diff --git a/docs/APP-API-ROADMAP.md b/docs/APP-API-ROADMAP.md index ba8c69c..163c2be 100644 --- a/docs/APP-API-ROADMAP.md +++ b/docs/APP-API-ROADMAP.md @@ -2,7 +2,7 @@ Status: composition MVP merged and natively qualified; bounded notifications, SSE and a complete application are natively qualified candidates, 2026-09-07. -Exact target: Zig 0.16.0. See the [implemented API](APP-API.md), +Exact target: Zig 0.17.0. See the [implemented API](APP-API.md), [21 example ports](../examples/README.md), and [composition native receipt](../reports/2026-09-07-composition.md) for exact evidence and limits. @@ -56,7 +56,7 @@ Inspect Git state before editing; do not overwrite another session's work. | Topic | Working decision | | --- | --- | | Product | Baz (Bounded Async Zap), package/import `baz`, external dependency/import `bounded_http`. Repository: [technologylab-ai/baz](https://github.com/technologylab-ai/baz), with its [Pages documentation](https://technologylab-ai.github.io/baz/). [bounded/http](https://technologylab-ai.github.io/bounded-http/) stays independently usable. No Zap source-compatibility layer. | -| Platform/version | Exact Zig 0.16.0; plain HTTP/1.1 on Linux, macOS, and native Windows x64. Public bind addresses need later qualification. TLS is out of scope. | +| Platform/version | Exact Zig 0.17.0; plain HTTP/1.1 on Linux, macOS, and native Windows x64. Public bind addresses need later qualification. TLS is out of scope. | | Windows | Supported natively on x64 with CI: Debug/ReleaseSafe verification, 14 App groups, 20 ported-example groups, 14 streaming groups, and three shard/shutdown cases. Windows performance remains deferred; Baz remains experimental. | | App | Real instances; typed Shared; borrowed endpoint instances; startup-only registration; one routing/context model. | | Input | Raw immutable slices, ordered duplicates, no coercion, no bracket-array syntax, no merged query/body/JSON bag. | @@ -385,9 +385,9 @@ Baseline commands once the host is reserved and exact compiler is selected: ```sh zig version -zig build verify -Doptimize=Debug -zig build verify -Doptimize=ReleaseSafe -zig build install examples -Doptimize=ReleaseSafe +zig build verify -Doptimize=debug +zig build verify -Doptimize=safe +zig build install examples -Doptimize=safe python3 tests/app_integration.py python3 tests/examples_integration.py python3 tests/streaming_integration.py diff --git a/docs/APP-API.md b/docs/APP-API.md index 9083dab..f1e8d7e 100644 --- a/docs/APP-API.md +++ b/docs/APP-API.md @@ -8,14 +8,14 @@ The engine's [GitHub Pages documentation](https://technologylab-ai.github.io/bou covers architecture, embedding, and ownership. Baz consumes a pinned external engine package; it does not contain engine sources. See the [dependency boundary](DEPENDENCY.md) and [extraction plan](APP-API-ROADMAP.md#api-08--migration-examples-and-successor-mvp-qualification). -This experimental API uses exact Zig **0.16.0**, the Linux io_uring / +This experimental API uses exact Zig **0.17.0**, the Linux io_uring / macOS kqueue / Windows IOCP HTTP engine, caller-supplied `std.Io`, and bounded standard memory readers/writers. An owned `std.Io` provider is deferred until after the API MVP. Run the maintained, compiled [example](../src/app_demo.zig): ```sh -zig build -Doptimize=ReleaseSafe +zig build -Doptimize=safe ./zig-out/bin/baz --port 8080 curl 'http://127.0.0.1:8080/hello?name=Hello%20Zig' curl 'http://127.0.0.1:8080/users/a%2Fb' diff --git a/docs/APPLICATION-RECIPES.md b/docs/APPLICATION-RECIPES.md index 185739a..473e485 100644 --- a/docs/APPLICATION-RECIPES.md +++ b/docs/APPLICATION-RECIPES.md @@ -2,7 +2,7 @@ Serve LAN clients, download runtime files, decode ordered form fields, and keep Baz's error classifications in a custom hook. These conveniences keep resource -ownership explicit. Use exact Zig 0.16.0. +ownership explicit. Use exact Zig 0.17.0. ## Reach your application from the LAN @@ -25,7 +25,7 @@ is involved. Connection limits and [backpressure](LIMITS.md) still apply. Try the hello example: ```sh -zig build hello -Doptimize=ReleaseSafe +zig build hello -Doptimize=safe ./zig-out/bin/hello --bind-address 0.0.0.0 --port 8080 --connections 16 ``` @@ -39,7 +39,7 @@ An embedded asset is useful when the file is known at compilation. For a file created later, run the [runtime download example](../examples/runtime_file.zig): ```sh -zig build runtime_file -Doptimize=ReleaseSafe +zig build runtime_file -Doptimize=safe ./zig-out/bin/runtime_file --file ./export.zip --port 8080 curl --output downloaded.zip http://127.0.0.1:8080/download curl --head http://127.0.0.1:8080/download @@ -67,7 +67,7 @@ staging buffer waits for transport progress. This is not an OS zero-copy operati The raw stream writer has no writable destination buffer. Consequently, `file_reader.interface.streamRemaining(stream.writer())` can fail with -`WriterBufferUnavailable` in Zig 0.16.0's file-reader fallback. Use `copyFrom` for +`WriterBufferUnavailable` in Zig 0.17.0's file-reader fallback. Use `copyFrom` for that transfer. Standard writer `writeAll`, `print`, and `flush` remain available. Source and sink failures are sticky: [`stream.failure()`](https://technologylab-ai.github.io/baz/api/#baz.Stream.failure) retains the error, and @@ -127,7 +127,7 @@ matching the original encoded names. Try the [decoded form example](../examples/decoded_forms.zig): ```sh -zig build decoded_forms -Doptimize=ReleaseSafe +zig build decoded_forms -Doptimize=safe ./zig-out/bin/decoded_forms --port 8080 curl --data 'name=Alice+Smith&%6eame=Bob%2BJones&flag&empty=' http://127.0.0.1:8080/ ``` diff --git a/docs/CONNECTION-LIMIT-WALKTHROUGH.md b/docs/CONNECTION-LIMIT-WALKTHROUGH.md index 2ed11e7..f46fc2c 100644 --- a/docs/CONNECTION-LIMIT-WALKTHROUGH.md +++ b/docs/CONNECTION-LIMIT-WALKTHROUGH.md @@ -3,7 +3,7 @@ See Baz's connection limit for yourself. Open two connections, try a third, then release a slot and try again. You control each step from your terminal. -**Allow about five minutes.** You need two terminals, exact Zig 0.16.0, Python 3, +**Allow about five minutes.** You need two terminals, exact Zig 0.17.0, Python 3, and a checkout of Baz. The client uses Python's standard library; there are no Python packages to install. The website is your guide; the server and clients run locally on your machine. @@ -22,12 +22,12 @@ cd baz ``` If you already have a checkout, open it in your terminal and run `git pull --ff-only` -to get this walkthrough. Check `zig version`: it must print `0.16.0`. +to get this walkthrough. Check `zig version`: it must print `0.17.0`. In **terminal 1**, from the Baz directory, run: ```sh -zig build run-app -Doptimize=ReleaseSafe -- --port 8080 --connections 2 --shards 1 --timeout-ms 300000 +zig build run-app -Doptimize=safe -- --port 8080 --connections 2 --shards 1 --timeout-ms 300000 ``` Wait for a line beginning `READY port=8080`. Leave this terminal running. @@ -38,7 +38,7 @@ The first build may take longer while Zig fetches dependencies and compiles. | `--connections 2` | Reserve two admitted connection slots. | | `--shards 1` | Use one I/O owner for this small exercise. | | `--timeout-ms 300000` | Give yourself five minutes between actions before idle connections expire. This is a walkthrough setting, not a deployment recommendation. | -| `-Doptimize=ReleaseSafe` | Keep runtime safety checks enabled. This exercise measures no performance. | +| `-Doptimize=safe` | Keep runtime safety checks enabled. This exercise measures no performance. | Use only the walkthrough client against this port during the exercise. Browser tabs can open their own connections, which would also count toward the two slots. diff --git a/docs/CONTINUATIONS.md b/docs/CONTINUATIONS.md index fe6158c..cfe504d 100644 --- a/docs/CONTINUATIONS.md +++ b/docs/CONTINUATIONS.md @@ -34,7 +34,7 @@ try app.routeContinuation("GET", "/stream", State, start, advance, .{}); Run [the complete example](../examples/continuations.zig): ```sh -zig build run-continuations -Doptimize=ReleaseSafe -- --port 8080 --execution workers --workers 1 +zig build run-continuations -Doptimize=safe -- --port 8080 --execution workers --workers 1 curl -N http://localhost:8080/stream ``` diff --git a/docs/COOKIES.md b/docs/COOKIES.md index 037cba3..3ac5010 100644 --- a/docs/COOKIES.md +++ b/docs/COOKIES.md @@ -154,7 +154,7 @@ cookie value, just like an opaque token. Baz does not verify signatures or inter claims; JWT verification and expiry policy belong to the application or a separately chosen library. Merely reading a cookie never authenticates it. -Run `zig build run-userpass_session -Doptimize=ReleaseSafe -- --port 8080`, then open +Run `zig build run-userpass_session -Doptimize=safe -- --port 8080`, then open `http://localhost:8080/login`. The public demo credentials are `zap` / `awesome`. The styled [login](../examples/assets/session_login.html) and [protected page](../examples/assets/session_home.html) are separate embedded assets. diff --git a/docs/DEPENDENCY.md b/docs/DEPENDENCY.md index cec6b62..8cb8ce7 100644 --- a/docs/DEPENDENCY.md +++ b/docs/DEPENDENCY.md @@ -87,7 +87,7 @@ No throughput comparison is rerun solely for package naming or documentation. The [zli fork](https://github.com/renerocksai/zli), pinned to `4f17b1f1eacda7b87c49461e34b1520c392788b2` from its [Init adapter PR](https://github.com/renerocksai/zli/pull/1), supplies typed command-line parsing for all public examples and the App/streaming/borrow fixture executables. -Its [`parseInit(init, Options)`](https://technologylab-ai.github.io/baz/api/#zli.parseInit) entry point consumes Zig 0.16 `std.process.Init`, +Its [`parseInit(init, Options)`](https://technologylab-ai.github.io/baz/api/#zli.parseInit) entry point consumes Zig 0.17 `std.process.Init`, using the supplied I/O and process arena. The [example guide](../examples/README.md#typed-cli-options-with-process-initialization) records syntax, ownership, and startup behavior. @@ -103,7 +103,7 @@ Baz build graph. No zli code runs on the request I/O loop. Baz's public [`web.mustache`](https://technologylab-ai.github.io/baz/api/#baz.mustache) adapter consumes the immutable URL/hash-pinned [pure Zig Mustache fork](https://github.com/technologylab-ai/mustache-zig). The module is imported internally as `mustache_engine`; consumers use Baz's wrapper. -The library is MIT licensed and requires exact Zig 0.16.0. We maintain this fork +The library is MIT licensed and requires exact Zig 0.17.0. We maintain this fork for Baz's requirements; upstream is not required to adopt those constraints. No upstream PR is planned for these changes. Its parser/runtime changes and core-spec tests belong in that separate repository. Baz owns startup diff --git a/docs/INTERFACES.md b/docs/INTERFACES.md index 8d5f328..d216460 100644 --- a/docs/INTERFACES.md +++ b/docs/INTERFACES.md @@ -1,6 +1,6 @@ # Baz module contracts -Use exact Zig 0.16.0. +Use exact Zig 0.17.0. The public `baz` module exports App, Request, Response, response limits, and parsing helpers. The [API guide](APP-API.md) describes those contracts. The [ownership guide](OWNERSHIP.md) describes their lifetimes. diff --git a/docs/JOBS.md b/docs/JOBS.md index f730105..7ba7ee8 100644 --- a/docs/JOBS.md +++ b/docs/JOBS.md @@ -4,7 +4,7 @@ Run a small application that combines Baz's Mustache templates, cookie sessions, and notification-driven server-sent events: ```sh -zig build run-jobs -Doptimize=ReleaseSafe -- --port 8080 --execution workers --workers 1 +zig build run-jobs -Doptimize=safe -- --port 8080 --execution workers --workers 1 ``` Open `http://localhost:8080`. Sign in as **zap / awesome** or **baz / awesome**, diff --git a/docs/MUSTACHE.md b/docs/MUSTACHE.md index 0c8c9bf..c40f4e5 100644 --- a/docs/MUSTACHE.md +++ b/docs/MUSTACHE.md @@ -1,7 +1,7 @@ # Mustache templates Baz renders Mustache with a [pure Zig, MIT-licensed library](https://github.com/technologylab-ai/mustache-zig), -ported to exact Zig 0.16.0 and extended with explicit rendering limits. +ported to exact Zig 0.17.0 and extended with explicit rendering limits. Parse templates once at startup. Pass ordinary typed Zig data to a handler; render directly into its reserved response storage. @@ -13,7 +13,7 @@ This is a preview of the rendered page. Run the [complete example](../examples/m locally to use the greeting form: ```sh -zig build run-mustache -Doptimize=ReleaseSafe -- --port 8080 +zig build run-mustache -Doptimize=safe -- --port 8080 # Open http://127.0.0.1:8080/ in your browser. ``` @@ -123,7 +123,7 @@ are excluded explicitly. Those compatibility checks are independent of the framework's HTTP ownership tests. `zig build verify` checks Baz and its independent package consumer in Debug or -ReleaseSafe. After `zig build install examples -Doptimize=ReleaseSafe`, run +ReleaseSafe. After `zig build install examples -Doptimize=safe`, run `python3 tests/mustache_integration.py` for 12 HTTP groups: inline and fixed workers, HTML/HEAD, explicit decoding and escaping, partials, malformed raw targets with connection close, application input errors with keep-alive recovery, diff --git a/docs/REPOSITORY.md b/docs/REPOSITORY.md index a121686..f4d0037 100644 --- a/docs/REPOSITORY.md +++ b/docs/REPOSITORY.md @@ -36,7 +36,7 @@ sharding revision. Read [HANDOFF.md](../HANDOFF.md) for the next API work. ## CI and publication -[CI](../.github/workflows/ci.yml) installs exact Zig 0.16.0 from the official download index and verifies the archive checksum. +[CI](../.github/workflows/ci.yml) installs exact Zig 0.17.0 using signature-verified archive checksums in `.github/zig-release.json`. It runs Debug and ReleaseSafe verification on GitHub-hosted Linux and macOS runners. It also builds and exercises all supported examples with ReleaseSafe binaries. Hosted logs are retained for 14 days; preserve material runtime evidence in dated reports. diff --git a/docs/STREAMING.md b/docs/STREAMING.md index 2ac186f..f537234 100644 --- a/docs/STREAMING.md +++ b/docs/STREAMING.md @@ -9,7 +9,7 @@ standard `std.Io.Writer`, flush, do finite work or sleep, then write again. The [runnable example](../examples/streaming.zig) sends three updates: ```sh -zig build run-streaming -Doptimize=ReleaseSafe -- --port 8080 +zig build run-streaming -Doptimize=safe -- --port 8080 curl -N http://127.0.0.1:8080/ ``` diff --git a/docs/WEBSITE.md b/docs/WEBSITE.md index 4c57c17..48fd8be 100644 --- a/docs/WEBSITE.md +++ b/docs/WEBSITE.md @@ -8,7 +8,7 @@ The overview, guides, diagrams, examples, and measurements are specific to Baz. ## Build and preview -Use Python 3 and exact Zig 0.16.0 from `.zig-version`. The first build fetches +Use Python 3 and exact Zig 0.17.0 from `.zig-version`. The first build fetches checksum-pinned Zig dependencies; no Node package installation is needed: ```sh @@ -146,14 +146,14 @@ runtime or performance evidence. Windows platform claims are backed by [Baz’s ## Generated API reference -`zig build docs -Doptimize=ReleaseSafe` installs standalone Zig Autodoc at +`zig build docs -Doptimize=safe` installs standalone Zig Autodoc at `zig-out/docs/api/`. The website builder runs this step before publishing the viewer at `api/index.html`, including its JavaScript, WebAssembly, and source archive. The documentation module shares the public module’s source and build options, with an additional docs-only zli import for the example CLI reference. `src/baz.zig` is the documented package entry point; `@import("baz")` is unchanged. -Zig 0.16.0's `std.Build.Step.Compile.getEmittedDocs()` emits the viewer. Autodoc +Zig 0.17.0's `std.Build.Step.Compile.getEmittedDocs()` emits the viewer. Autodoc recognizes `root.zig` or a file matching the module name; otherwise it uses the first source archive member for that module (`lib/docs/wasm/main.zig`, `unpack`). Baz now follows the name convention. The imported engine and Mustache modules diff --git a/docs/api-packages.template.html b/docs/api-packages.template.html index c328e42..2240d9d 100644 --- a/docs/api-packages.template.html +++ b/docs/api-packages.template.html @@ -1,6 +1,6 @@
Related package APIs -

These references use the versions in Baz’s dependency pins and Zig 0.16.0.

+

These references use the versions in Baz’s dependency pins and Zig 0.17.0.

  • HTTP engine — configuration, budgets, connections, and notifications from bounded/http.
  • Mustache library — values and rendering limits used by Baz’s template adapter.
  • diff --git a/docs/examples.template.html b/docs/examples.template.html index c278554..160ef09 100644 --- a/docs/examples.template.html +++ b/docs/examples.template.html @@ -6,7 +6,7 @@

    26 of 26 examples

    @@EXAMPLES@@
    -
    Build all examples, or run one
    zig build examples -Doptimize=ReleaseSafe
    -zig build run-http_params -Doptimize=ReleaseSafe -- --port 8080
    +
    Build all examples, or run one
    zig build examples -Doptimize=safe
    +zig build run-http_params -Doptimize=safe -- --port 8080

    Cookies and redirects are public APIs, with explicit expiry and a local login/logout example. Middleware, authentication policy and session storage remain explicit application code. Read the complete catalog and its deliberate adaptations →

    diff --git a/docs/get-started.template.html b/docs/get-started.template.html index 9a40bf6..6d545de 100644 --- a/docs/get-started.template.html +++ b/docs/get-started.template.html @@ -1,9 +1,9 @@

    Get started

    A working App in one command.

    -

    Use exact Zig 0.16.0 and Python 3. Clone Baz, then start the demo. The pinned HTTP engine is fetched automatically.

    +

    Use exact Zig 0.17.0 and Python 3. Clone Baz, then start the demo. The pinned HTTP engine is fetched automatically.

    01 · Start the App
    git clone https://github.com/technologylab-ai/baz.git
     cd baz
    -zig build run-app -Doptimize=ReleaseSafe -- --port 8080
    +zig build run-app -Doptimize=safe -- --port 8080
    02 · In another terminal, from the Baz directory
    curl 'http://127.0.0.1:8080/hello?name=Hello%20Zig'
     curl --data 'value=x+y%2Bz' http://127.0.0.1:8080/form
     curl -F 'files[]=@.zig-version' http://127.0.0.1:8080/upload
    @@ -38,7 +38,7 @@

    Send a file. Skip the body copy.

    Already have a large image or file in memory? borrowBody() lets Baz send those existing bytes directly, avoiding a copy into its response buffer. A 5 MiB file stays in its original storage instead of being copied into another 5 MiB framework buffer.

    This complete handler shows the API with an embedded HTML file: GET / returns the file’s contents as the entire response body. Use the same call with your image bytes and content type. Small bodies below the default 256-byte threshold—including this tiny HTML file—may still be copied.

    -

    Here web = @import("baz"). The complete example registers try app.route("GET", "/", index). @embedFile includes the file at compile time, so this handler performs no filesystem I/O. Run it with zig build run-serve -Doptimize=ReleaseSafe -- --port 8080.

    +

    Here web = @import("baz"). The complete example registers try app.route("GET", "/", index). @embedFile includes the file at compile time, so this handler performs no filesystem I/O. Run it with zig build run-serve -Doptimize=safe -- --port 8080.

    FEWER COPIESresponse.bytes() copies your body into bounded staging. borrowBody() avoids that payload copy for large retained bodies; a large file can use a small output arena. Headers and normal kernel transfers still have copying costs. See exactly where copies happen →

    borrowBody() prepares one complete body. When this handler returns successfully, App publishes status 200, HTTP headers, and the file bytes. There is no body prefix or suffix. The embedded bytes stay alive for transmission.

    Headers and handler work still fit.

    Authenticate, choose an asset, and add response headers in your handler. Headers can be added before or after borrowBody() while the response is unpublished. A large immutable file can use a small output arena; the total response limit still applies.

    Streaming + borrowing: not yet.

    Writing and flushing a prefix, calling borrowBody() with an image, then continuing the stream is currently unsupported. Borrowing the whole body and starting a stream are separate choices—even before the first flush. Use the stream writer’s writeAll(image) to put image bytes between other streamed chunks; that path copies through bounded staging.

    diff --git a/docs/highlight-zig.js b/docs/highlight-zig.js index 084c9b4..38b6e7f 100644 --- a/docs/highlight-zig.js +++ b/docs/highlight-zig.js @@ -1,4 +1,4 @@ -/* Zig keywords match lib/std/zig/tokenizer.zig in the exact 0.16.0 release. */ +/* Zig keywords match lib/std/zig/tokenizer.zig in the exact 0.17.0 release. */ hljs.registerLanguage('zig', h => ({ name: 'Zig', keywords: { keyword: 'addrspace align allowzero and anyframe anytype asm break callconv catch comptime const continue defer else enum errdefer error export extern fn for if inline noalias noinline nosuspend opaque or orelse packed pub resume return linksection struct suspend switch test threadlocal try union unreachable var volatile while', diff --git a/docs/index.template.html b/docs/index.template.html index 38e3986..d64e1cd 100644 --- a/docs/index.template.html +++ b/docs/index.template.html @@ -5,7 +5,7 @@

    Familiar to write.
    Explicit by design.

    Linux
    io_uring
    macOS
    kqueue
    Windows x64
    IOCP

    Native HTTP I/O powered by bounded/http.

    -
    PURE ZIG · EXACT 0.16.0CALLER-SUPPLIED std.IoMIT LICENSE
    +
    PURE ZIG · EXACT 0.17.0CALLER-SUPPLIED std.IoMIT LICENSE

    Build with Baz

    An App with room to grow.

    diff --git a/docs/page.template.html b/docs/page.template.html index c0f9aa5..963ddbb 100644 --- a/docs/page.template.html +++ b/docs/page.template.html @@ -25,7 +25,7 @@ baz.BOUNDED ASYNC ZAP -
    ZIG 0.16.0 · MIT
    LINUX · MACOS
    WINDOWS x64
    EXPERIMENTAL FRAMEWORK
    API guide ↗
    View on GitHub ↗
    +
    ZIG 0.17.0 · MIT
    LINUX · MACOS
    WINDOWS x64
    EXPERIMENTAL FRAMEWORK
    API guide ↗
    View on GitHub ↗
    TECHNOLOGY LAB · SYSTEMS ENGINEERING
    diff --git a/docs/read.html b/docs/read.html index c4ce093..86e5b74 100644 --- a/docs/read.html +++ b/docs/read.html @@ -14,7 +14,7 @@ +
    ZIG 0.17.0 · MIT
    Baz on GitHub ↗
    DOCUMENTATION

    Loading the document…

    diff --git a/docs/vendor/manifest.json b/docs/vendor/manifest.json index aa00303..1823f87 100644 --- a/docs/vendor/manifest.json +++ b/docs/vendor/manifest.json @@ -8,7 +8,9 @@ "files_sha256": { "marked.js": "69451c8541c9c1e7a4bf3ffc6f73c4d89633de92bfbe3e484dfe182ef8091f88", "marked-LICENSE": "8e3a3f82f59a60958f56ca08f445647c32a4733dc7ca6c2c46f6eb898471ab9c" - } + }, + "revision": "f92422d83d524138cfb5ab9e7b7e4952a9445c8d", + "source": "https://github.com/technologylab-ai/bounded-http/tree/f92422d83d524138cfb5ab9e7b7e4952a9445c8d" }, { "package": "@highlightjs/cdn-assets", @@ -19,7 +21,9 @@ "files_sha256": { "highlight.js": "8ab71eb09c51f501e5e25157d9cff100e46cc29bcbfc744d0b746d451fca7f53", "highlight-LICENSE": "6c081431591d9df696c82dc598fe1423765b8a299b200ed00b281afd0f64c490" - } + }, + "revision": "f92422d83d524138cfb5ab9e7b7e4952a9445c8d", + "source": "https://github.com/technologylab-ai/bounded-http/tree/f92422d83d524138cfb5ab9e7b7e4952a9445c8d" }, { "package": "dompurify", @@ -31,28 +35,30 @@ "purify.js": "f263b05369e050fa175d4ecb9c9358eb4253602d510297adfb31df48b2f1c4d5", "purify-LICENSE": "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30", "purify-LICENSE-MPL": "fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85" - } + }, + "revision": "f92422d83d524138cfb5ab9e7b7e4952a9445c8d", + "source": "https://github.com/technologylab-ai/bounded-http/tree/f92422d83d524138cfb5ab9e7b7e4952a9445c8d" }, { "name": "Zig Autodoc and standard library", - "version": "0.16.0", - "source": "https://ziglang.org/download/0.16.0/", + "version": "0.17.0", + "source": "https://ziglang.org/download/0.17.0/", "files_sha256": { "zig-LICENSE": "5c537d6853e005298a285d508cff9ac7192cea23576c840d485b2b586a7ff177" } }, { "name": "Mustache source archive notice", - "revision": "22487e4082537aa5b707dd902def866d990fdea1", - "source": "https://github.com/technologylab-ai/mustache-zig/tree/22487e4082537aa5b707dd902def866d990fdea1", + "revision": "f46006f04a6bb4374a34250fb01fe72daf6a39c1", + "source": "https://github.com/technologylab-ai/mustache-zig/tree/f46006f04a6bb4374a34250fb01fe72daf6a39c1", "files_sha256": { "mustache-LICENSE": "33f9d4e30896bb820c52d1565f6f38638ea891b0ba95d89c6de1ad7c051984c1" } }, { "name": "zli source archive notice", - "revision": "4f17b1f1eacda7b87c49461e34b1520c392788b2", - "source": "https://github.com/renerocksai/zli/tree/4f17b1f1eacda7b87c49461e34b1520c392788b2", + "revision": "36dfe7c506117af0e52533feb549282362b77e2a", + "source": "https://github.com/renerocksai/zli/tree/36dfe7c506117af0e52533feb549282362b77e2a", "files_sha256": { "zli-LICENSE": "0d542e0c8804e39aa7f37eb00da5a762149dc682d7829451287e11b938e94594" } diff --git a/examples/README.md b/examples/README.md index d66b148..1e9eba6 100644 --- a/examples/README.md +++ b/examples/README.md @@ -7,7 +7,7 @@ after releasing a slot. The walkthrough explains each action and expected result [streaming.zig](streaming.zig) demonstrates Baz's incremental response writer. It writes, flushes, sleeps, and writes again before the handler returns. -Run `zig build run-streaming -Doptimize=ReleaseSafe -- --port 8080`, then use +Run `zig build run-streaming -Doptimize=safe -- --port 8080`, then use `curl -N http://127.0.0.1:8080/` in another terminal. See the [streaming guide](../docs/STREAMING.md) for its worker and lifetime bounds. [continuations.zig](continuations.zig) adds typed callbacks that release the executor @@ -28,9 +28,9 @@ framework import and [shared executable support](support.zig); there is no facil.io dependency. Names retain the original build targets for easy comparison. ```sh -zig build examples -Doptimize=ReleaseSafe +zig build examples -Doptimize=safe ./zig-out/bin/hello --port 8080 -zig build run-http_params -Doptimize=ReleaseSafe -- --port 8080 +zig build run-http_params -Doptimize=safe -- --port 8080 python3 tests/examples_integration.py ``` @@ -50,7 +50,7 @@ before delivery; only terminal shutdown establishes released storage. All 24 public examples use [zli](https://github.com/renerocksai/zli) through [shared executable support](support.zig). The main App demonstration and all five wire fixtures use the same parser with their own typed option structs. Each -entry point receives Zig 0.16's `std.process.Init`: +entry point receives Zig 0.17's `std.process.Init`: ```zig pub fn main(init: std.process.Init) !void { @@ -66,7 +66,7 @@ server flags and [app_demo.zig](../src/app_demo.zig) for a complete direct use. and enum fields reject unknown values. Both `--port 8080` and `--port=8080` work. Public examples also accept `-p 8080`. -Use `zig build run-hello -Doptimize=ReleaseSafe -- --help` to see the options +Use `zig build run-hello -Doptimize=safe -- --help` to see the options without starting a server. Help is handwritten in the struct, not generated. Unknown, missing, and repeated options are errors. Explicit `--workers N` is independent of its position relative to `--execution workers`; when omitted, @@ -80,7 +80,7 @@ The framework module itself does not import zli. The dependency uses Apache-2.0; Baz's own code remains MIT. The finite CLI regression suite is `python3 tests/cli_integration.py` after -`zig build install examples -Doptimize=ReleaseSafe`. It checks help and invalid +`zig build install examples -Doptimize=safe`. It checks help and invalid arguments before startup, both option spellings, worker defaults, and shutdown. | Original target | Port | Preserved purpose and deliberate adaptation | @@ -131,7 +131,7 @@ The renderer writes directly into the reserved response draft, with no allocated rendered string. See the [guide](../docs/MUSTACHE.md) for limits, escaping, and copying. ```sh -zig build run-mustache -Doptimize=ReleaseSafe -- --port 8080 +zig build run-mustache -Doptimize=safe -- --port 8080 python3 tests/mustache_integration.py ``` @@ -154,8 +154,8 @@ remaining qualification. The engine remains a standalone case study. ## Application recipes -- `zig build runtime_file -Doptimize=ReleaseSafe`: runtime downloads at `/download`, selected with `--file PATH`. -- `zig build decoded_forms -Doptimize=ReleaseSafe`: ordered decoded form fields using a caller-owned arena on workers. +- `zig build runtime_file -Doptimize=safe`: runtime downloads at `/download`, selected with `--file PATH`. +- `zig build decoded_forms -Doptimize=safe`: ordered decoded form fields using a caller-owned arena on workers. - `hello --bind-address 0.0.0.0`: explicit IPv4 LAN binding with the usual connection limits. - `app_errors`: custom error presentation using `web.defaultErrorStatus` for other failures. diff --git a/examples/cookie_fixture.zig b/examples/cookie_fixture.zig index 73691d0..a2db1a3 100644 --- a/examples/cookie_fixture.zig +++ b/examples/cookie_fixture.zig @@ -85,7 +85,7 @@ fn rejectedCookie(ctx: *Context) !void { .insecure => ctx.response.setCookie("bad", "x", .{ .same_site = .none }), .secure_prefix => ctx.response.setCookie("__Secure-token", "x", .{}), .host_prefix => ctx.response.setCookie("__Host-token", "x", .{ .secure = true, .path = "/elsewhere" }), - .header_limit => ctx.response.setCookie("huge", "x" ** 1024, .{}), + .header_limit => ctx.response.setCookie("huge", &@as([1024]u8, @splat('x')), .{}), }; if (attempted) |_| { return error.ExpectedCookieFailure; diff --git a/examples/embedding/build.zig b/examples/embedding/build.zig index 0404649..d87c84d 100644 --- a/examples/embedding/build.zig +++ b/examples/embedding/build.zig @@ -5,8 +5,8 @@ pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const framework = b.dependency("baz", .{ .target = target, .optimize = optimize }); const tests = b.addTest(.{ - .use_llvm = if (target.result.os.tag == .linux and optimize == .Debug) true else null, - .use_lld = if (target.result.os.tag == .linux and optimize == .Debug) true else null, + .use_llvm = if (target.result.os.tag == .linux and optimize == .debug) true else null, + .use_lld = if (target.result.os.tag == .linux and optimize == .debug) true else null, .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, diff --git a/examples/embedding/build.zig.zon b/examples/embedding/build.zig.zon index 48fee20..07ed3b5 100644 --- a/examples/embedding/build.zig.zon +++ b/examples/embedding/build.zig.zon @@ -2,7 +2,7 @@ .name = .baz_embedding, .version = "0.0.1", .fingerprint = 0x28ec9f429de74fd6, - .minimum_zig_version = "0.16.0", + .minimum_zig_version = "0.17.0", .dependencies = .{ .baz = .{ .path = "../.." } }, .paths = .{ "build.zig", "build.zig.zon", "src" }, } diff --git a/examples/embedding/src/main.zig b/examples/embedding/src/main.zig index 3fcedb4..e25d80b 100644 --- a/examples/embedding/src/main.zig +++ b/examples/embedding/src/main.zig @@ -43,7 +43,7 @@ test "consumer parses Mustache partials and publishes an escaped HTML response" try std.testing.expect(!writer.began); try std.testing.expectEqual(engine.api.Action.finish, try response.finish()); try std.testing.expectEqualStrings("

    <Hello>

    Rene / Baz

    Caro / Baz

    ", writer.committed()); - try std.testing.expect(std.mem.indexOf(u8, arena[0..writer.body_start], "Content-Type: text/html; charset=utf-8\r\n") != null); + try std.testing.expect(std.mem.find(u8, arena[0..writer.body_start], "Content-Type: text/html; charset=utf-8\r\n") != null); } test "consumer can borrow cookie tokens and publish cookies with an empty redirect" { @@ -64,7 +64,7 @@ test "consumer can borrow cookie tokens and publish cookies with an empty redire _ = try response.finish(); try std.testing.expectEqual(@as(u16, 303), writer.status); try std.testing.expectEqualStrings("", writer.committed()); - try std.testing.expect(std.mem.indexOf(u8, arena[0..writer.body_start], "Max-Age=3600") != null); + try std.testing.expect(std.mem.find(u8, arena[0..writer.body_start], "Max-Age=3600") != null); } test "consumer registers typed locals and copied route middleware" { diff --git a/examples/endpoint/continuation_fixture.zig b/examples/endpoint/continuation_fixture.zig index cd335d3..c8cf2b7 100644 --- a/examples/endpoint/continuation_fixture.zig +++ b/examples/endpoint/continuation_fixture.zig @@ -38,7 +38,7 @@ const Record = struct { fn snapshot(self: *const Record) Snapshot { var result: Snapshot = undefined; - inline for (std.meta.fields(Snapshot)) |field| @field(result, field.name) = @field(self, field.name).load(.acquire); + inline for (@typeInfo(Snapshot).@"struct".field_names) |field_name| @field(result, field_name) = @field(self, field_name).load(.acquire); return result; } }; @@ -213,7 +213,7 @@ pub fn report(shared: *const Shared) void { var totals: Snapshot = std.mem.zeroes(Snapshot); for (&shared.records) |*record| { const current = record.snapshot(); - inline for (std.meta.fields(Snapshot)) |field| @field(totals, field.name) += @field(current, field.name); + inline for (@typeInfo(Snapshot).@"struct".field_names) |field_name| @field(totals, field_name) += @field(current, field_name); } std.debug.print("CONTINUATIONS {f}\n", .{std.json.fmt(totals, .{})}); } diff --git a/examples/endpoint/session_store.zig b/examples/endpoint/session_store.zig index d2db31d..4262228 100644 --- a/examples/endpoint/session_store.zig +++ b/examples/endpoint/session_store.zig @@ -231,7 +231,7 @@ test "tokens reject malformed and noncanonical text without clearing a session" var store = Store(1).init(@splat(5)); defer store.deinit(); const token = try store.create(std.math.maxInt(Identity), 0, 100); - for ([_][]const u8{ "", token[0..63], &([_]u8{'g'} ** 64), &([_]u8{'A'} ** 64) }) |invalid| { + for ([_][]const u8{ "", token[0..63], &@as([64]u8, @splat('g')), &@as([64]u8, @splat('A')) }) |invalid| { try std.testing.expectError(error.InvalidToken, store.authenticate(invalid, 0)); try std.testing.expectError(error.InvalidToken, store.revoke(invalid)); } diff --git a/examples/jobs.zig b/examples/jobs.zig index 6b74c71..81044c4 100644 --- a/examples/jobs.zig +++ b/examples/jobs.zig @@ -180,7 +180,7 @@ fn decimal(comptime T: type, raw: []const u8) !T { } fn jobHandle(raw: []const u8) !jobs.Handle { - const separator = std.mem.indexOfScalar(u8, raw, '-') orelse return error.InvalidId; + const separator = std.mem.findScalar(u8, raw, '-') orelse return error.InvalidId; const generation = try decimal(u64, raw[separator + 1 ..]); if (generation == 0) return error.InvalidId; return .{ .slot = try decimal(u16, raw[0..separator]), .generation = generation }; diff --git a/examples/middleware_fixture.zig b/examples/middleware_fixture.zig index c7f9f66..141799f 100644 --- a/examples/middleware_fixture.zig +++ b/examples/middleware_fixture.zig @@ -30,7 +30,7 @@ const Record = struct { fn snapshot(self: *const Record) Snapshot { var result: Snapshot = undefined; - inline for (std.meta.fields(Snapshot)) |field| @field(result, field.name) = @field(self, field.name).load(.acquire); + inline for (@typeInfo(Snapshot).@"struct".field_names) |field_name| @field(result, field_name) = @field(self, field_name).load(.acquire); return result; } }; @@ -273,8 +273,8 @@ pub fn main(init: std.process.Init) !void { var total: Snapshot = .{ .trace = 0, .initialized = 0, .handlers = 0, .afters = 0, .cleanups = 0, .locals_cleaned = 0, .cancelled = 0, .errors = 0, .sleeping = 0, .bad_address = 0 }; for (&shared.records) |*item| { const snapshot = item.snapshot(); - inline for (std.meta.fields(Snapshot)) |field| { - if (comptime !std.mem.eql(u8, field.name, "trace")) @field(total, field.name) += @field(snapshot, field.name); + inline for (@typeInfo(Snapshot).@"struct".field_names) |field_name| { + if (comptime !std.mem.eql(u8, field_name, "trace")) @field(total, field_name) += @field(snapshot, field_name); } } const receipt = try std.json.Stringify.valueAlloc(init.gpa, total, .{}); diff --git a/examples/support.zig b/examples/support.zig index 334ee35..b8f8a22 100644 --- a/examples/support.zig +++ b/examples/support.zig @@ -29,7 +29,7 @@ pub fn Options(comptime workers_required: bool) type { shards: u8 = 1, pub const help = - \\Baz example — Zig 0.16.0 + \\Baz example — Zig 0.17.0 \\Usage: EXAMPLE [options] \\ \\ -h, --help Show this help and exit diff --git a/src/App.zig b/src/App.zig index 32f6bc2..8790c4a 100644 --- a/src/App.zig +++ b/src/App.zig @@ -243,7 +243,7 @@ pub fn AppWithLocals(comptime Shared: type, comptime Locals: type) type { } /// Typed callbacks return between flushes and timed waits. State defaults - /// are initialized once, before middleware; optional State.deinit(*State, + /// are initialized once, before middleware. Optional public State.deinit(*State, /// *Context) runs once before locals cleanup, including failed startup. /// State and Locals cannot back borrowed output or retain Context/writers. pub fn routeContinuation(self: *Self, method: []const u8, path: []const u8, comptime State: type, comptime start_handler: *const fn (*Context, *State) anyerror!continuation.Step, comptime resume_handler: *const fn (*Context, *State, continuation.Event) anyerror!continuation.Step, options: RouteOptions) !void { @@ -288,7 +288,7 @@ pub fn AppWithLocals(comptime Shared: type, comptime Locals: type) type { pub fn bindWith(self: *Self, method: []const u8, path: []const u8, instance: anytype, comptime handler: anytype, options: RouteOptions) !void { const Pointer = @TypeOf(instance); const info = @typeInfo(Pointer); - if (info != .pointer or info.pointer.size != .one or info.pointer.is_const) + if (info != .pointer or info.pointer.size != .one or info.pointer.attrs.@"const") @compileError("a bound endpoint must be a mutable single-item pointer"); const Adapter = struct { fn call(opaque_instance: ?*anyopaque, context: *Context) anyerror!void { @@ -301,6 +301,7 @@ pub fn AppWithLocals(comptime Shared: type, comptime Locals: type) type { /// Register conventional endpoint methods atomically. No base struct, /// path field or per-endpoint error-policy field is required. + /// Discovery requires public get, post, put, delete, patch, head or options methods. pub fn endpoint(self: *Self, path: []const u8, instance: anytype) !void { return self.endpointWith(path, instance, .{}); } @@ -727,8 +728,8 @@ test "App registration is instance-owned, copies paths and rolls back endpoints" const Shared = struct { count: usize = 0 }; const Application = App(Shared); const Endpoint = struct { - fn get(_: *@This(), _: *Application.Context) !void {} - fn post(_: *@This(), _: *Application.Context) !void {} + pub fn get(_: *@This(), _: *Application.Context) !void {} + pub fn post(_: *@This(), _: *Application.Context) !void {} }; var shared: Shared = .{}; const app = try Application.init(.{ .allocator = std.testing.allocator, .io = std.testing.io, .shared = &shared, .server = .{ .connections = 1, .shards = 1 }, .max_routes = 2 }); @@ -943,6 +944,127 @@ test "typed locals, middleware unwinding, early responses and error cleanup run } } +test "endpoint discovery requires public conventional methods" { + const Shared = struct {}; + const Application = App(Shared); + const PrivateEndpoint = struct { + fn get(_: *@This(), _: *Application.Context) !void {} + }; + var shared: Shared = .{}; + const app = try Application.init(.{ .allocator = std.testing.allocator, .io = std.testing.io, .shared = &shared, .server = .{ .connections = 1, .shards = 1 } }); + defer app.deinit(); + var endpoint: PrivateEndpoint = .{}; + try std.testing.expectError(error.NoEndpointMethods, app.endpoint("/private", &endpoint)); + try std.testing.expectEqual(@as(usize, 0), app.routes_len); +} + +test "public continuation deinit runs once before locals on finish failures and cancellation" { + const Shared = struct { + mode: usize = 0, + starts: usize = 0, + resumes: usize = 0, + initialized: usize = 0, + state_cleanups: usize = 0, + locals_cleanups: usize = 0, + }; + const Locals = struct { state_cleaned: bool = false }; + const Application = AppWithLocals(Shared, Locals); + const State = struct { + marker: u8 = 61, + pub fn deinit(self: *@This(), ctx: *Application.Context) void { + std.debug.assert(self.marker == (if (ctx.shared.mode >= 4) @as(u8, 61) else @as(u8, 62))); + std.debug.assert(!ctx.locals.state_cleaned); + ctx.locals.state_cleaned = true; + ctx.shared.state_cleanups += 1; + } + }; + const H = struct { + fn initialize(ctx: *Application.Context) !void { + ctx.shared.initialized += 1; + if (ctx.shared.mode == 4) return error.InitFailure; + } + fn cleanupLocals(ctx: *Application.Context) void { + std.debug.assert(ctx.locals.state_cleaned); + ctx.shared.locals_cleanups += 1; + } + fn start(ctx: *Application.Context, state: *State) !continuation.Step { + std.debug.assert(state.marker == 61); + state.marker = 62; + ctx.shared.starts += 1; + if (ctx.shared.mode == 1) return error.StartFailure; + if (ctx.shared.mode == 0) { + try ctx.response.text(200, "done"); + return .finish; + } + return .{ .wait = 1 }; + } + fn callResume(ctx: *Application.Context, state: *State, event: continuation.Event) !continuation.Step { + std.debug.assert(state.marker == 62 and event == .timer); + ctx.shared.resumes += 1; + return error.ResumeFailure; + } + }; + var shared: Shared = .{}; + const app = try Application.init(.{ + .allocator = std.testing.allocator, + .io = std.testing.io, + .shared = &shared, + .server = .{ .connections = 1, .shards = 1 }, + .response = .{ .header_bytes = 0, .body_bytes = 32 }, + .max_continuations = 1, + .max_continuation_state_bytes = 64, + .init_locals = H.initialize, + .cleanup_locals = H.cleanupLocals, + }); + defer app.deinit(); + try app.routeContinuation("GET", "/", State, H.start, H.callResume, .{}); + var parser = engine.api.http.Parser.init(.{}); + var request = (try parser.parse("GET / HTTP/1.1\r\nHost: localhost\r\n\r\n")).?; + var arena: [2048]u8 = undefined; + var cache: engine.api.HeaderCache = .{}; + cache.refresh("Sun, 06 Sep 2026 12:00:00 GMT"); + var writer = engine.api.Writer.init(&arena, &cache, 0); + var state: [8]usize = @splat(0); + var cancelled: std.atomic.Value(bool) = .init(false); + for (0..6) |mode| { + shared.mode = mode; + shared.starts = 0; + shared.resumes = 0; + shared.initialized = 0; + cancelled.store(mode == 5, .release); + writer.open(0, true, false); + var ctx: engine.api.Context = .{ .request = &request, .writer = &writer, .event = .request, .state = &state, .application = app, .cancelled = &cancelled }; + const action = Application.dispatch(&ctx); + if (mode == 2 or mode == 3) { + try std.testing.expectEqual(engine.api.Action.wait, action); + try std.testing.expectEqual(@as(usize, 1), app.continuations.live()); + try std.testing.expectEqual(mode, shared.state_cleanups); + if (mode == 3) cancelled.store(true, .release); + ctx.event = if (mode == 3) .cancelled else .timer; + try std.testing.expectEqual(if (mode == 3) engine.api.Action.close else .finish, Application.dispatch(&ctx)); + } else { + try std.testing.expectEqual(engine.api.Action.finish, action); + } + try std.testing.expectEqual(@as(usize, @intFromBool(mode < 4)), shared.starts); + try std.testing.expectEqual(@as(usize, @intFromBool(mode == 2)), shared.resumes); + try std.testing.expectEqual(@as(usize, @intFromBool(mode != 5)), shared.initialized); + try std.testing.expectEqual(mode + 1, shared.state_cleanups); + try std.testing.expectEqual(mode + 1, shared.locals_cleanups); + try std.testing.expectEqual(@as(usize, 0), app.continuations.live()); + try std.testing.expectEqual(@as(usize, 0), state[0]); + try std.testing.expectEqual(@as(usize, 0), state[1]); + if (mode == 3) { + // Closing a cancelled wait publishes no output snapshot to release. + try std.testing.expect(!writer.frozen); + try std.testing.expectEqual(@as(usize, 0), writer.reserved); + try std.testing.expect(writer.borrowed == null); + } else { + try std.testing.expect(writer.frozen); + writer.release(); + } + } +} + test "default error classification is reusable without mapping application errors" { try std.testing.expectEqual(@as(u16, 400), defaultErrorStatus(error.MissingBoundary)); try std.testing.expectEqual(@as(u16, 413), defaultErrorStatus(error.TooManyParams)); diff --git a/src/app_demo.zig b/src/app_demo.zig index f7b19b3..f5dce62 100644 --- a/src/app_demo.zig +++ b/src/app_demo.zig @@ -165,8 +165,8 @@ fn invalidHeader(ctx: *Context) !void { } fn tooLarge(ctx: *Context) !void { - const bytes = "x" ** 9000; - return ctx.response.text(200, bytes); + const bytes: [9000]u8 = @splat('x'); + return ctx.response.text(200, &bytes); } fn noResponse(_: *Context) !void {} diff --git a/src/borrow_demo.zig b/src/borrow_demo.zig index adabbce..581cc40 100644 --- a/src/borrow_demo.zig +++ b/src/borrow_demo.zig @@ -4,7 +4,10 @@ const zli = @import("zli"); const baz = @import("baz"); const support = @import("example_support"); -const asset = "\x00\x01\x7f\x80\xffBAZ\r\nasset!" ** (5 * 1024 * 1024 / 16); +// Arrays of u8 have no padding, so these immutable blocks expose the exact +// repeated byte payload without importing a framework-owned source file. +const asset_blocks: [5 * 1024 * 1024 / 16][16]u8 = @splat("\x00\x01\x7f\x80\xffBAZ\r\nasset!".*); +const asset: []const u8 = std.mem.asBytes(&asset_blocks); const Shared = struct { asset_bytes: []const u8 = asset, asset_requests: std.atomic.Value(u32) = .init(0), diff --git a/src/cookies.zig b/src/cookies.zig index 7af6818..5d32aca 100644 --- a/src/cookies.zig +++ b/src/cookies.zig @@ -431,8 +431,10 @@ test "cookie parser rejects malformed pairs and checks exact bounds before publi } test "iterator respects accepted custom limits above the defaults" { - const raw = "a" ** 257 ++ "=" ++ "x" ** 4097; - const view = try parse(raw, .{ .max_name_bytes = 257, .max_value_bytes = 4097 }); + const name: [257]u8 = @splat('a'); + const value: [4097]u8 = @splat('x'); + const raw = name ++ [_]u8{'='} ++ value; + const view = try parse(&raw, .{ .max_name_bytes = 257, .max_value_bytes = 4097 }); var it = view.iterator(); const item = it.next().?; try std.testing.expectEqual(@as(usize, 257), item.name_raw.len); @@ -492,7 +494,7 @@ test "all Set-Cookie errors preserve destination including overlapping option st .{ .options = .{ .domain = "example..test" }, .expected = error.InvalidCookieDomain }, .{ .options = .{ .domain = "example.test:80" }, .expected = error.InvalidCookieDomain }, .{ .options = .{ .domain = "ex\xffmple.test" }, .expected = error.InvalidCookieDomain }, - .{ .options = .{ .domain = "a" ** 64 ++ ".test" }, .expected = error.InvalidCookieDomain }, + .{ .options = .{ .domain = &(@as([64]u8, @splat('a')) ++ ".test".*) }, .expected = error.InvalidCookieDomain }, .{ .options = .{ .expires = max_expiry + 1 }, .expected = error.InvalidCookieExpiry }, .{ .options = .{ .same_site = .none }, .expected = error.InsecureCookie }, .{ .name = "__Host-id", .expected = error.InvalidCookiePrefix }, diff --git a/src/mustache.zig b/src/mustache.zig index 24644ae..778003b 100644 --- a/src/mustache.zig +++ b/src/mustache.zig @@ -172,8 +172,8 @@ test "empty template fits empty output and immutable template can be reused afte } test "parser rejects excessive dotted recursion before post-parse validation" { - const source = "{{" ++ "a." ** 1000 ++ "a}}"; - try std.testing.expectError(error.DepthLimitExceeded, Template.init(std.testing.allocator, source, .{})); + const source = comptime "{{".* ++ @import("static_bytes.zig").repeat("a.", 1000) ++ "a}}".*; + try std.testing.expectError(error.DepthLimitExceeded, Template.init(std.testing.allocator, &source, .{})); } test "empty delimiter declarations return an ordinary parse error" { diff --git a/src/request.zig b/src/request.zig index d2660b9..cd5ed20 100644 --- a/src/request.zig +++ b/src/request.zig @@ -345,7 +345,7 @@ test "request cookie helpers validate every field and borrow exact raw token byt try std.testing.expectError(error.DuplicateCookie, request.cookie("sid")); try std.testing.expectEqualStrings("false", (try request.cookie("flag")).?); try std.testing.expectEqual(null, try request.cookie("missing")); - const offset = std.mem.indexOf(u8, wire, "001%20+==").?; + const offset = std.mem.find(u8, wire, "001%20+==").?; try std.testing.expectEqual(wire[offset..].ptr, view.firstRaw("sid").?.value_raw.ptr); try std.testing.expectEqualStrings("raw", view.firstRaw("q").?.value_raw); try std.testing.expectError(error.TooManyCookies, request.cookiesWithLimits(.{ .max_pairs = 3 })); diff --git a/src/response.zig b/src/response.zig index f2c4e14..208e074 100644 --- a/src/response.zig +++ b/src/response.zig @@ -170,7 +170,7 @@ pub const Response = struct { } if (location.len == 0) return error.InvalidRedirect; for (location, 0..) |byte, index| { - if (byte <= 0x20 or byte >= 0x7f or std.mem.indexOfScalar(u8, "\\\"<>^`{|}", byte) != null) return error.InvalidRedirect; + if (byte <= 0x20 or byte >= 0x7f or std.mem.findScalar(u8, "\\\"<>^`{|}", byte) != null) return error.InvalidRedirect; if (byte == '%' and (location.len - index < 3 or !std.ascii.isHex(location[index + 1]) or !std.ascii.isHex(location[index + 2]))) return error.InvalidRedirect; @@ -567,9 +567,13 @@ pub const Stream = struct { /// arbitrary source operation already in progress. Runtime file I/O belongs /// on an application worker. Existing response limits and flush waits apply. pub fn copyFrom(self: *Stream, reader: *std.Io.Reader, scratch: []u8) !usize { - errdefer |err| { + return self.copyFromInner(reader, scratch) catch |err| { if (self.response.stream_error == null) self.response.stream_error = err; - } + return err; + }; + } + + fn copyFromInner(self: *Stream, reader: *std.Io.Reader, scratch: []u8) !usize { try self.response.checkStream(); if (scratch.len == 0) return error.EmptyScratchBuffer; if (overlap(scratch, reader.buffer) or overlap(scratch, self.response.storage)) @@ -713,7 +717,7 @@ test "continuation snapshots retain detached metadata and publish only on return try testing.expectError(error.InvalidState, response.continuationWait()); try testing.expectEqual(api.Action.flush, try response.continuationFlush()); try testing.expectEqualStrings("abcbc", fixture.writer.committed()); - try testing.expect(std.mem.indexOf(u8, fixture.arena[0..fixture.writer.body_start], "X-Retained: yes\r\n") != null); + try testing.expect(std.mem.find(u8, fixture.arena[0..fixture.writer.body_start], "X-Retained: yes\r\n") != null); try testing.expectError(error.InvalidState, response.resumeSnapshot()); try testing.expectError(error.InvalidState, response.header("X-Late", "no")); fixture.drained(); @@ -1068,8 +1072,8 @@ test "draft copies stack metadata and body and preserves earlier frozen bytes" { try testing.expectEqualStrings(prefix, arena[0..prefix.len]); try testing.expectEqualStrings("Hello", writer.committed()); const head = arena[writer.base..writer.body_start]; - try testing.expect(std.mem.indexOf(u8, head, "Content-Type: text/plain\r\n") != null); - try testing.expect(std.mem.indexOf(u8, head, "X-Note: original\r\nSet-Cookie: a=1\r\nSet-Cookie: b=2\r\n\r\n") != null); + try testing.expect(std.mem.find(u8, head, "Content-Type: text/plain\r\n") != null); + try testing.expect(std.mem.find(u8, head, "X-Note: original\r\nSet-Cookie: a=1\r\nSet-Cookie: b=2\r\n\r\n") != null); try testing.expectEqual(@as(usize, 5), writer.draft_copy_bytes); try testing.expectError(error.InvalidState, response.finish()); try testing.expectError(error.InvalidState, response.errorResponse(500)); @@ -1090,7 +1094,7 @@ test "header bounds and injection failures leave the unpublished draft usable" { try testing.expectError(error.ResponseLimit, response.header("Y", "b")); try response.text(200, "ok"); _ = try response.finish(); - try testing.expect(std.mem.indexOf(u8, arena[0..writer.body_start], "X: a\r\n\r\n") != null); + try testing.expect(std.mem.find(u8, arena[0..writer.body_start], "X: a\r\n\r\n") != null); try testing.expectEqualStrings("ok", writer.committed()); } @@ -1111,7 +1115,7 @@ test "JSON exact fit and overflow never publish an incomplete success" { _ = try response.errorResponse(500); try testing.expectEqual(@as(u16, 500), writer.status); try testing.expectEqualStrings("", writer.committed()); - try testing.expect(std.mem.indexOf(u8, arena[0..writer.buffered], "\"ab") == null); + try testing.expect(std.mem.find(u8, arena[0..writer.buffered], "\"ab") == null); } test "failed custom serializer executes once and custom mapper discards all draft fields" { @@ -1137,8 +1141,8 @@ test "failed custom serializer executes once and custom mapper discards all draf try response.text(409, "conflict"); _ = try response.finish(); const wire = arena[0..writer.buffered]; - try testing.expect(std.mem.indexOf(u8, wire, "private") == null); - try testing.expect(std.mem.indexOf(u8, wire, "X-Error: mapped\r\n") != null); + try testing.expect(std.mem.find(u8, wire, "private") == null); + try testing.expect(std.mem.find(u8, wire, "X-Error: mapped\r\n") != null); try testing.expectEqualStrings("conflict", writer.committed()); } @@ -1167,11 +1171,11 @@ test "response states bodyless statuses HEAD and explicit borrowing retain contr try response.text(304, ""); _ = try response.finish(); try testing.expectEqual(@as(usize, 0), writer.bodyBytes()); - try testing.expect(std.mem.indexOf(u8, arena[0..writer.buffered], "Content-Length") == null); + try testing.expect(std.mem.find(u8, arena[0..writer.buffered], "Content-Length") == null); } test "large immutable borrows retain their pointer without body staging or arena copies" { - const asset = "0123456789abcdef" ** (5 * 1024 * 1024 / 16); + const asset: [:0]const u8 = &(comptime @import("static_bytes.zig").repeat("0123456789abcdef", 5 * 1024 * 1024 / 16)); const prefix = "older frozen response"; const cache = testCache(); for ([_]bool{ false, true }) |head_only| { @@ -1195,14 +1199,14 @@ test "large immutable borrows retain their pointer without body staging or arena try testing.expect(!writer.copied_borrow); try testing.expectEqualStrings(prefix, arena[0..prefix.len]); const head = arena[writer.base..writer.body_start]; - try testing.expect(std.mem.indexOf(u8, head, "Content-Length: 5242880\r\n") != null); - try testing.expect(std.mem.indexOf(u8, head, "X-Asset: retained\r\nX-After: prepared\r\n") != null); + try testing.expect(std.mem.find(u8, head, "Content-Length: 5242880\r\n") != null); + try testing.expect(std.mem.find(u8, head, "X-Asset: retained\r\nX-After: prepared\r\n") != null); try testing.expectError(error.InvalidState, response.errorResponse(500)); } } test "borrow totals reject one excess byte before publication and preserve fallback" { - const asset = "retained" ** 1024; + const asset: [:0]const u8 = &(comptime @import("static_bytes.zig").repeat("retained", 1024)); var arena: [1024]u8 = undefined; const cache = testCache(); var writer = api.Writer.init(&arena, &cache, 0); @@ -1216,7 +1220,7 @@ test "borrow totals reject one excess byte before publication and preserve fallb try testing.expect(!response.prepared and response.borrowed == null and !writer.began and !writer.frozen); try testing.expectEqual(api.Action.finish, try response.errorResponse(500)); try testing.expectEqualStrings("Internal Server Error", writer.committed()); - try testing.expect(std.mem.indexOf(u8, arena[0..writer.buffered], "X-Private") == null); + try testing.expect(std.mem.find(u8, arena[0..writer.buffered], "X-Private") == null); writer.release(); writer.open(0, true, false); response = try Response.initWithLimit(&writer, .{ .header_bytes = 0, .body_bytes = 0 }, asset.len); @@ -1284,7 +1288,7 @@ test "Mustache writes directly to unpublished storage and selects the whole HTML _ = try response.finish(); try testing.expectEqualStrings("Hello <>", writer.committed()); try testing.expectEqual(@as(usize, 14), writer.draft_copy_bytes); - try testing.expect(std.mem.indexOf(u8, arena[0..writer.body_start], "Content-Type: text/html; charset=utf-8\r\n") != null); + try testing.expect(std.mem.find(u8, arena[0..writer.body_start], "Content-Type: text/html; charset=utf-8\r\n") != null); } test "Mustache overflow work exhaustion and bodyless status keep prefixes private" { @@ -1300,7 +1304,7 @@ test "Mustache overflow work exhaustion and bodyless status keep prefixes privat var response = try Response.init(&writer, .{ .header_bytes = 0, .body_bytes = 16 }); switch (failure) { 0 => try testing.expectError(error.WriteFailed, response.mustache(200, &template, .{ .name = "<&>" })), - 1 => try testing.expectError(error.WorkLimitExceeded, response.mustache(200, &budgeted, .{ .rows = [_]bool{true} ** 100 })), + 1 => try testing.expectError(error.WorkLimitExceeded, response.mustache(200, &budgeted, .{ .rows = @as([100]bool, @splat(true)) })), 2 => try testing.expectError(error.InvalidResponse, response.mustache(204, &template, .{ .name = "x" })), else => unreachable, } @@ -1308,7 +1312,7 @@ test "Mustache overflow work exhaustion and bodyless status keep prefixes privat try response.text(500, "fallback"); _ = try response.finish(); try testing.expectEqualStrings("fallback", writer.committed()); - try testing.expect(std.mem.indexOf(u8, arena[0..writer.buffered], "private") == null); + try testing.expect(std.mem.find(u8, arena[0..writer.buffered], "private") == null); writer.release(); } } @@ -1327,8 +1331,8 @@ test "cookie headers copy metadata once, repeat independently, and coexist with try testing.expect(!writer.began); _ = try response.finish(); const head = arena[0..writer.body_start]; - try testing.expect(std.mem.indexOf(u8, head, "Set-Cookie: sid=original; Path=/; HttpOnly; SameSite=Lax\r\n") != null); - try testing.expect(std.mem.indexOf(u8, head, "Set-Cookie: old=; Path=/app; Domain=example.test; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Secure; HttpOnly; SameSite=Strict\r\n") != null); + try testing.expect(std.mem.find(u8, head, "Set-Cookie: sid=original; Path=/; HttpOnly; SameSite=Lax\r\n") != null); + try testing.expect(std.mem.find(u8, head, "Set-Cookie: old=; Path=/app; Domain=example.test; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Secure; HttpOnly; SameSite=Strict\r\n") != null); try testing.expectError(error.InvalidState, response.setCookie("late", "x", .{})); } @@ -1389,7 +1393,7 @@ test "redirect validates destination and status atomically and leaves cookie hea _ = try response.finish(); try testing.expectEqual(status, writer.status); try testing.expectEqualStrings("", writer.committed()); - try testing.expect(std.mem.indexOf(u8, arena[0..writer.body_start], "Location: /home?x=%20#ok\r\nSet-Cookie: after=yes;") != null); + try testing.expect(std.mem.find(u8, arena[0..writer.body_start], "Location: /home?x=%20#ok\r\nSet-Cookie: after=yes;") != null); writer.release(); } } diff --git a/src/static_bytes.zig b/src/static_bytes.zig new file mode 100644 index 0000000..78622cf --- /dev/null +++ b/src/static_bytes.zig @@ -0,0 +1,32 @@ +//! Compile-time construction of immutable byte fixtures without heap allocation. +const std = @import("std"); + +/// Repeat a byte pattern and retain the string sentinel outside its payload. +/// Prefix doubling bounds evaluator iterations even for multi-megabyte assets. +pub fn repeat(comptime pattern: []const u8, comptime count: usize) [pattern.len * count:0]u8 { + const length = pattern.len * count; + // A fully defined byte buffer avoids quadratic partially defined aggregate + // updates in the 0.17 comptime evaluator for the multi-megabyte fixtures. + var bytes: [length:0]u8 = @splat(0); + if (length == 0) return bytes; + @memcpy(bytes[0..pattern.len], pattern); + var initialized = pattern.len; + while (initialized < length) { + const next = @min(initialized, length - initialized); + @memcpy(bytes[initialized..][0..next], bytes[0..next]); + initialized += next; + } + return bytes; +} + +test "static repetition retains binary octets payload bounds and sentinel" { + const bytes = comptime repeat("\x00\xffA", 3); + try std.testing.expectEqualStrings("\x00\xffA\x00\xffA\x00\xffA", &bytes); + try std.testing.expectEqual(@as(u8, 0), bytes[bytes.len]); + const empty_pattern = comptime repeat("", 5); + const empty_count = comptime repeat("unused", 0); + try std.testing.expectEqualStrings("", &empty_pattern); + try std.testing.expectEqualStrings("", &empty_count); + try std.testing.expectEqual(@as(u8, 0), empty_pattern[0]); + try std.testing.expectEqual(@as(u8, 0), empty_count[0]); +} diff --git a/src/streaming_demo.zig b/src/streaming_demo.zig index 671ca6a..df157ed 100644 --- a/src/streaming_demo.zig +++ b/src/streaming_demo.zig @@ -191,17 +191,17 @@ fn longLength(ctx: *Context) !void { } fn largeWrite(ctx: *Context) !void { - const bytes = "s" ** 8193; + const bytes: [8193]u8 = @splat('s'); var stream = try ctx.response.stream(200, "text/plain", .{}); try stream.writeAll(bytes[0 .. ctx.shared.chunk_bytes + 1]); try stream.finish(); } fn cumulativeLimit(ctx: *Context) !void { - const bytes = "b" ** 512; + const bytes: [512]u8 = @splat('b'); var stream = try ctx.response.stream(200, "text/plain", .{}); for (0..3) |_| { - try stream.writeAll(bytes); + try stream.writeAll(&bytes); try stream.flush(); } try stream.finish(); @@ -224,7 +224,7 @@ fn sleeping(ctx: *Context) !void { fn pressure(ctx: *Context) !void { _ = ctx.shared.started.fetchAdd(1, .release); defer _ = ctx.shared.finished.fetchAdd(1, .release); - const bytes = "p" ** 8192; + const bytes: [8192]u8 = @splat('p'); var stream = try ctx.response.stream(200, "application/octet-stream", .{}); // This upper bound exceeds socket buffers. The wire gate stops reading. for (0..8192) |_| { diff --git a/tests/borrow_integration.py b/tests/borrow_integration.py index 6a49193..655eb23 100644 --- a/tests/borrow_integration.py +++ b/tests/borrow_integration.py @@ -45,7 +45,7 @@ def connect(self, timeout=10.0): def __enter__(self): super().__enter__() try: - wire.require(any("optimize=ReleaseSafe" in line for line in self.lines), + wire.require(any("optimize=safe" in line for line in self.lines), "borrowed-body wire gates require a ReleaseSafe binary") except BaseException: import sys @@ -252,7 +252,7 @@ def main(): args = parser.parse_args() cases = run(args.server.resolve()) result = dict(passed=len(cases), cases=cases, platform=platform.platform(), - optimize="ReleaseSafe", performance_comparison=False, + optimize="safe", performance_comparison=False, asset=dict(bytes=ASSET_SIZE, sha256=ASSET_SHA256, client_maximum=CLIENT_LIMIT)) if args.json: args.json.parent.mkdir(parents=True, exist_ok=True) diff --git a/tests/cli_integration.py b/tests/cli_integration.py index 0a0edfb..0e131d7 100644 --- a/tests/cli_integration.py +++ b/tests/cli_integration.py @@ -121,7 +121,7 @@ def __enter__(self): wire.require(0 < self.port <= 65535, "invalid bound CLI port") ready = [line for line in self.lines if line.startswith("READY ")] wire.require(len(ready) == 1, "CLI server emitted repeated READY records") - wire.require("optimize=ReleaseSafe" in ready[0], "CLI startup gates require ReleaseSafe") + wire.require("optimize=safe" in ready[0], "CLI startup gates require ReleaseSafe") wire.require("execution=" + self.expected_execution + " " in ready[0], "CLI execution selection changed: " + ready[0]) except BaseException: @@ -229,7 +229,7 @@ def startup(name, label, arguments, workers, execution): return dict(passed=len(exits) + len(startups), executables=len(binaries), exit_cases=exits, startup_cases=startups, - platform=platform.platform(), optimize="ReleaseSafe", + platform=platform.platform(), optimize="safe", performance_comparison=False) diff --git a/tests/continuations_integration.py b/tests/continuations_integration.py index da17ed2..21f0446 100644 --- a/tests/continuations_integration.py +++ b/tests/continuations_integration.py @@ -28,7 +28,7 @@ def __init__(self, binary, execution, workers): def __enter__(self): super().__enter__() try: - wire.require(any("optimize=ReleaseSafe" in line for line in self.lines), "continuation gates require ReleaseSafe") + wire.require(any("optimize=safe" in line for line in self.lines), "continuation gates require ReleaseSafe") except BaseException: self.__exit__(*sys.exc_info()) raise diff --git a/tests/cookies_integration.py b/tests/cookies_integration.py index 1c9890c..c72bac4 100644 --- a/tests/cookies_integration.py +++ b/tests/cookies_integration.py @@ -24,7 +24,7 @@ def __init__(self, binary, execution="inline", workers=0): def __enter__(self): super().__enter__() try: - wire.require(any("optimize=ReleaseSafe" in line for line in self.lines), + wire.require(any("optimize=safe" in line for line in self.lines), "cookie wire gates require a ReleaseSafe binary") except BaseException: self.__exit__(*sys.exc_info()) diff --git a/tests/jobs_integration.py b/tests/jobs_integration.py index 2c13dc0..4e4a567 100644 --- a/tests/jobs_integration.py +++ b/tests/jobs_integration.py @@ -34,7 +34,7 @@ def __init__(self, binary, execution, workers, **options): def __enter__(self): super().__enter__() try: - wire.require(any("optimize=ReleaseSafe" in line for line in self.lines), + wire.require(any("optimize=safe" in line for line in self.lines), "job gates require ReleaseSafe") except BaseException: self.__exit__(*sys.exc_info()) diff --git a/tests/middleware_integration.py b/tests/middleware_integration.py index 7eb31fd..b83d06a 100644 --- a/tests/middleware_integration.py +++ b/tests/middleware_integration.py @@ -41,7 +41,7 @@ def __init__(self, binary, execution="inline", workers=0, connections=1): def __enter__(self): super().__enter__() try: - wire.require(any("optimize=ReleaseSafe" in line for line in self.lines), "middleware gates require ReleaseSafe") + wire.require(any("optimize=safe" in line for line in self.lines), "middleware gates require ReleaseSafe") except BaseException: self.__exit__(*sys.exc_info()) raise diff --git a/tests/mustache_integration.py b/tests/mustache_integration.py index 0f72cc4..bc514c1 100644 --- a/tests/mustache_integration.py +++ b/tests/mustache_integration.py @@ -32,7 +32,7 @@ def __init__(self, binary, execution="inline", workers=0, connections=1): def __enter__(self): super().__enter__() try: - wire.require(any("optimize=ReleaseSafe" in line for line in self.lines), + wire.require(any("optimize=safe" in line for line in self.lines), "Mustache wire checks require a ReleaseSafe binary") except BaseException: self.__exit__(*sys.exc_info()) diff --git a/tests/streaming_integration.py b/tests/streaming_integration.py index c66aeb5..08a222d 100644 --- a/tests/streaming_integration.py +++ b/tests/streaming_integration.py @@ -34,7 +34,7 @@ def __init__(self, binary, **options): def __enter__(self): super().__enter__() try: - wire.require(any("optimize=ReleaseSafe" in line for line in self.lines), + wire.require(any("optimize=safe" in line for line in self.lines), "streaming wire gates require a ReleaseSafe binary") except BaseException: import sys @@ -349,7 +349,7 @@ def passed(name, server): if example is not None: with ExampleServer(example, workers=2) as server: - wire.require(any("optimize=ReleaseSafe" in line for line in server.lines), + wire.require(any("optimize=safe" in line for line in server.lines), "streaming example gate requires a ReleaseSafe binary") with server.connect() as sock: reader = StreamReader(sock) @@ -374,7 +374,7 @@ def main(): args = parser.parse_args() cases = run(args.server.resolve(), args.example.resolve()) result = dict(passed=len(cases), cases=cases, platform=platform.platform(), - optimize="ReleaseSafe", performance_comparison=False) + optimize="safe", performance_comparison=False) if args.json: args.json.parent.mkdir(parents=True, exist_ok=True) args.json.write_text(json.dumps(result, indent=2) + "\n") diff --git a/tools/build_pages.py b/tools/build_pages.py index 1153110..0a145f8 100644 --- a/tools/build_pages.py +++ b/tools/build_pages.py @@ -15,7 +15,7 @@ # Pages does not serve dot-prefixed paths. Keep the reader's canonical file name. DOCUMENT_URLS = {'.zig-version': 'docs/zig-version.txt'} PAGES = { - 'index': ('Overview', 'Baz — Bounded Async Zap', 'Pure Zig 0.16.0, typed applications, streaming responses, and explicit memory boundaries.', []), + 'index': ('Overview', 'Baz — Bounded Async Zap', 'Pure Zig 0.17.0, typed applications, streaming responses, and explicit memory boundaries.', []), 'get-started': ('Get started', 'Build your first App', 'Run Baz, explore a typed endpoint, stream updates, and send borrowed file bodies.', [('start', 'Run the demo'), ('app-example', 'App basics'), ('streaming', 'Streaming'), ('borrowed', 'Avoid body copies')]), 'design': ('Design', 'How Baz fits together', 'The Zap heritage, HTTP engine, request data, ownership, limits, and backpressure.', [('idea', 'The idea'), ('engine', 'HTTP engine'), ('data', 'Request data'), ('limits', 'Limits & backpressure')]), 'examples': ('Examples', 'Learn from working code', 'Explore all 26 maintained Baz examples, from a first route to a complete live application.', []), @@ -228,7 +228,7 @@ def api_page(source): shell = shell.replace('', '\n' '\n\n') intro = '

    Baz / Reference

    API reference

    ' - content = '

    Types, functions, and source, generated with Zig 0.16.0. ' + content = '

    Types, functions, and source, generated with Zig 0.17.0. ' content += 'Read the guides for walkthroughs and ownership rules.

    ' content += '' @@ -237,7 +237,7 @@ def api_page(source): content += 'Read the public source or ' content += 'browse the guides.

    ' content += '
    ' + viewer + '
    ' - values = {'TITLE': 'API reference · Baz', 'DESCRIPTION': 'Source-generated Baz types, functions, and documentation for Zig 0.16.0.', + values = {'TITLE': 'API reference · Baz', 'DESCRIPTION': 'Source-generated Baz types, functions, and documentation for Zig 0.17.0.', 'CANONICAL': 'https://technologylab-ai.github.io/baz/api/', 'PAGE_CLASS': 'topic-page api-page', 'NAVIGATION': navigation('api', '../'), 'PAGE_INTRO': intro, 'CONTENT': content, 'LEGACY_SCRIPT': ''} for key, value in values.items(): @@ -247,9 +247,9 @@ def api_page(source): def build(): version = subprocess.check_output(['zig', 'version'], text=True).strip() - if version != (ROOT / '.zig-version').read_text().strip() or version != '0.16.0': - raise ValueError('The API reference requires exact Zig 0.16.0') - subprocess.run(['zig', 'build', 'docs', '-Doptimize=ReleaseSafe', '-j2'], cwd=ROOT, check=True) + if version != (ROOT / '.zig-version').read_text().strip() or version != '0.17.0': + raise ValueError('The API reference requires exact Zig 0.17.0') + subprocess.run(['zig', 'build', 'docs', '-Doptimize=safe', '-j2'], cwd=ROOT, check=True) api_source = ROOT / 'zig-out/docs/api' revision = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=ROOT, text=True).strip() if not re.fullmatch('[0-9a-f]{40}', revision): diff --git a/tools/prepare_api_docs.py b/tools/prepare_api_docs.py index 8938f06..f8e4175 100644 --- a/tools/prepare_api_docs.py +++ b/tools/prepare_api_docs.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""Normalize Zig 0.16 Autodoc's filename/order-based module root selection. +"""Normalize Zig 0.17 Autodoc's filename/order-based module root selection. The viewer chooses root.zig, .zig, or the first file in each module. Baz uses baz.zig; two dependencies use different root names. Keep every source byte and @@ -59,7 +59,7 @@ def prepare(source, destination, roots): for name in FILES[:-1]: shutil.copyfile(source / name, destination / name) manifest = normalize_archive(source / 'sources.tar', destination / 'sources.tar', roots) - manifest['generator'] = 'Zig 0.16.0 Autodoc' + manifest['generator'] = 'Zig 0.17.0 Autodoc' manifest['files_sha256'] = {name: hashlib.sha256((destination / name).read_bytes()).hexdigest() for name in FILES} (destination / 'api-build.json').write_text(json.dumps(manifest, indent=2) + '\n') diff --git a/tools/verify_linux_ssh.sh b/tools/verify_linux_ssh.sh index 62a424f..984a29a 100755 --- a/tools/verify_linux_ssh.sh +++ b/tools/verify_linux_ssh.sh @@ -24,9 +24,9 @@ COPYFILE_DISABLE=1 tar --no-xattrs --exclude=.git --exclude=.zig-cache --exclude "$(uname -n)" "$(uname -m)" "$(uname -r)" "$(zig version)" \ "$(cat /proc/sys/kernel/io_uring_disabled)" cat /etc/os-release - timeout 600 zig build verify -Doptimize=Debug -j2 --summary all - timeout 600 zig build verify -Doptimize=ReleaseSafe -j2 --summary all - timeout 600 zig build install examples -Doptimize=ReleaseSafe -j2 + timeout 600 zig build verify -Doptimize=debug -j2 --summary all + timeout 600 zig build verify -Doptimize=safe -j2 --summary all + timeout 600 zig build install examples -Doptimize=safe -j2 PYTHONDONTWRITEBYTECODE=1 timeout 120 python3 tests/app_integration.py PYTHONDONTWRITEBYTECODE=1 timeout 120 python3 tests/examples_integration.py ' From 74768283c375fdd6136ccf7fb6463bd29563721e Mon Sep 17 00:00:00 2001 From: renerocksai Date: Sun, 4 Oct 2026 18:26:17 +0200 Subject: [PATCH 2/3] Allow generous compiler watchdogs and record wiki upgrade scope --- .github/workflows/ci.yml | 2 +- .github/workflows/windows-build.yml | 2 +- HANDOFF.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fc655e..aff0806 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} - timeout-minutes: 25 + timeout-minutes: 60 env: PYTHONDONTWRITEBYTECODE: "1" steps: diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index d406228..3855d67 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -15,7 +15,7 @@ concurrency: jobs: windows-x64: runs-on: windows-latest - timeout-minutes: 25 + timeout-minutes: 60 env: PYTHONDONTWRITEBYTECODE: "1" steps: diff --git a/HANDOFF.md b/HANDOFF.md index 6d69866..ec2eba2 100644 --- a/HANDOFF.md +++ b/HANDOFF.md @@ -36,7 +36,7 @@ The final URL graph has separate package-consumer checks. Hosted native CI records the published branch's Linux, Mac, and Windows results. Earlier receipts in this file retain their original compiler, revision, and platform scope. No performance measurement was performed for this migration. -The separate Zig wiki remains on 0.16.0 and receives the agent migration guide after these ports. +The user also authorized the separate Zig wiki's full 0.17.0 upgrade and agent migration guide. ## Earlier baseline — 2026-09-06 From 42b1d02c5d92ecd863fa1f5e8efd4f4e378680b4 Mon Sep 17 00:00:00 2001 From: renerocksai Date: Sun, 4 Oct 2026 19:15:19 +0200 Subject: [PATCH 3/3] Correct remaining current compiler labels and example count --- examples/README.md | 2 +- examples/endpoint/session_options.zig | 2 +- src/baz.zig | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/README.md b/examples/README.md index 1e9eba6..4f5221a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -47,7 +47,7 @@ before delivery; only terminal shutdown establishes released storage. ## Typed CLI options with process initialization -All 24 public examples use [zli](https://github.com/renerocksai/zli) through +All 26 public examples use [zli](https://github.com/renerocksai/zli) through [shared executable support](support.zig). The main App demonstration and all five wire fixtures use the same parser with their own typed option structs. Each entry point receives Zig 0.17's `std.process.Init`: diff --git a/examples/endpoint/session_options.zig b/examples/endpoint/session_options.zig index a2537eb..4f3ef8e 100644 --- a/examples/endpoint/session_options.zig +++ b/examples/endpoint/session_options.zig @@ -12,7 +12,7 @@ pub const Options = struct { pub const aliases = .{ .port = "p" }; pub const help = - \\Baz session example — Zig 0.16.0 + \\Baz session example — Zig 0.17.0 \\Usage: userpass_session [options] \\ \\ -h, --help Show this help and exit diff --git a/src/baz.zig b/src/baz.zig index 29010aa..9204245 100644 --- a/src/baz.zig +++ b/src/baz.zig @@ -1,4 +1,4 @@ -//! Baz — Bounded Async Zap. Experimental application API for exact Zig 0.16.0. +//! Baz — Bounded Async Zap. Experimental application API for exact Zig 0.17.0. //! //! Start with `App(Shared)` for typed routes and endpoints, or `AppWithLocals` //! for middleware with request-local state. `Request` borrows request input;