graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
docs(adr): spec-ptc is already default; io_uring is not process Io
Cursor Agent9b25cf4fd255
diff --git a/docs/adr/0025-io-uring-is-not-the-process-io.md b/docs/adr/0025-io-uring-is-not-the-process-io.mdnew file mode 100644index 00000000..1b784ffd--- /dev/null+++ b/docs/adr/0025-io-uring-is-not-the-process-io.md@@ -0,0 +1,46 @@+# 0025. io_uring is not the process Io; ublk is not ours++Status: accepted 2026-08-25++## Context++A follow-up asked whether [spec-ptc](https://github.com/alexzhang13/spec-ptc)+is already in this build, and whether+[LWN 903855](https://lwn.net/Articles/903855/) (ublk: an io_uring user-space+block driver) plus Zig's `std.Io.Uring` backend would shrink the binary or+SWE wall.++spec-ptc is already the default loop (ADR 0022): `src/spec_ptc.zig` segments+streaming `rlm` source; `rlm.feedLive` / `rlm_spec` launch closed literal+calls as the `code` argument streams; `runScript` claims the futures. Host+functions are graff tools (`read_file`, `edit_file`, `write_file`, `codedb`,+`bash`, `webfetch`) plus `sleep_ms` / `llm_query` / `print` / `subagent`.+`--old` / `--no-rlm` restore structured-only. This is Zig, not the Python+shadow REPL and not Prime's IPython kernel.++ublk is a kernel `/dev/ublk-control` protocol for implementing *block+devices* in user space (null/loop). Graff is a coding harness. Wiring ublk+would add a storage driver, not a faster `read_file`.++Zig 0.17's `std.process.Init` still constructs `std.Io.Threaded`+(`lib/std/start.zig`). `std.Io.Evented` on Linux *is* `Io/Uring.zig` (fiber+stacks, 512 KiB idle). `src/proc_identity.zig` already avoids `Io.Dir` for+`/proc/<pid>/stat` because the io_uring test backend can EBADF and panic.++## Decision++Keep process Io as Zig's default `Threaded`. Do not switch `main` to+`std.Io.Uring` / Evented. Do not implement ublk. Linux `io_uring` stays+available for a hand probe (`scripts/io-uring-probe.zig`), not the REPL,+HTTP client, or TTY.++## Consequences++A 64×4 KiB batch (200 rounds) on this host (`zig run+scripts/io-uring-probe.zig`, two reps): serial `pread` **20 µs/round**,+io_uring submit-and-wait **75 µs/round** (~3.7× slower — setup + enter+dominate small reads). SWE is 41 model turns vs grok's 31; the prefix is+already ~5.7k vs ~5.1k per call. An io_uring process Io would also break+Windows, fight the TTY, and re-expose the `/proc` EBADF panic. Revisit+only if a measured Linux-only path (MCP stdio fan-out, large parallel+walks) shows Threaded as the wall.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 8826e382..c709d566 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -35,6 +35,7 @@ record only when you need the evidence or the edge cases.| [0022](0022-rlm-is-opt-in-speculative-ptc.md) | `rlm` (Alex Zhang spec-ptc + RLM, Zig) is the default loop. `--old` restores structured-only. Prime persist + `subagent()` only — no IPython. || [0023](0023-codex-subagent-is-sidecar-not-v8.md) | Codex check: take sidecar-vs-critical-path spawn prompts; reject V8 Code Mode, extra spawn tools, and parent-history fork. || [0024](0024-three-harness-compare-prompt-subagent-rss.md) | Steal short child briefs + sidecar spawn from grok-build/kimi/dsh; lean catalog must not claim root is approval-denied under yolo; reject root conv-id share, datetime/tree prefix, fork-seed, Harbor. |+| [0025](0025-io-uring-is-not-the-process-io.md) | Process Io stays Zig `Threaded`. spec-ptc is already the default loop (ADR 0022). Do not take ublk or switch `main` to `std.Io.Uring`. |## When to write onediff --git a/scripts/io-uring-probe.zig b/scripts/io-uring-probe.zignew file mode 100644index 00000000..2246d169--- /dev/null+++ b/scripts/io-uring-probe.zig@@ -0,0 +1,93 @@+//! Hand probe: batch file reads via io_uring vs serial pread.+//! Not wired into `zig build test`. Linux only.+//!+//! zig run scripts/io-uring-probe.zig+//!+//! Answers whether swapping process Io from Threaded to Evented/Uring+//! would move the SWE needle (ADR 0025).++const std = @import("std");+const linux = std.os.linux;++const n_files: usize = 64;+const file_bytes: usize = 4096;+const rounds: usize = 200;++pub fn main(init: std.process.Init) !void {+ if (@import("builtin").os.tag != .linux) {+ std.debug.print("linux only\n", .{});+ return;+ }+ const io = init.io;+ var tmp_buf: [65]u8 = undefined;+ const tmp = try zprint(&tmp_buf, "/tmp/graff-uring-{d}", .{linux.getpid()});+ _ = linux.unlink(tmp);+ const mk = linux.mkdir(tmp, 0o755);+ if (linux.errno(mk) != .SUCCESS) return error.Mkdir;++ var payload: [file_bytes]u8 = undefined;+ @memset(&payload, 'a');+ var fds: [n_files]std.posix.fd_t = undefined;+ for (0..n_files) |i| {+ var name_buf: [81]u8 = undefined;+ const name = try zprint(&name_buf, "{s}/f{d}", .{ tmp, i });+ const fd = linux.open(name, .{ .ACCMODE = .RDWR, .CREAT = true, .TRUNC = true }, 0o644);+ if (linux.errno(fd) != .SUCCESS) return error.Open;+ fds[i] = @intCast(fd);+ const wrote = linux.write(fds[i], &payload, payload.len);+ if (linux.errno(wrote) != .SUCCESS or wrote != payload.len) return error.Write;+ }+ defer {+ for (fds) |fd| _ = linux.close(fd);+ for (0..n_files) |i| {+ var name_buf: [81]u8 = undefined;+ const name = zprint(&name_buf, "{s}/f{d}", .{ tmp, i }) catch continue;+ _ = linux.unlink(name);+ }+ _ = linux.rmdir(tmp);+ }++ var dest: [n_files][file_bytes]u8 = undefined;+ const serial_ns = try timeSerial(io, &fds, &dest);+ const uring_ns = try timeUring(io, &fds, &dest);+ std.debug.print(+ "n={d} size={d} rounds={d}\nserial_pread {d} us/round\nio_uring batch {d} us/round\n",+ .{ n_files, file_bytes, rounds, serial_ns / rounds / 1000, uring_ns / rounds / 1000 },+ );+}++fn zprint(buf: []u8, comptime fmt: []const u8, args: anytype) ![:0]const u8 {+ const n = try std.fmt.bufPrint(buf[0 .. buf.len - 1], fmt, args);+ buf[n.len] = 0;+ return buf[0..n.len :0];+}++fn timeSerial(io: std.Io, fds: *const [n_files]std.posix.fd_t, dest: *[n_files][file_bytes]u8) !u64 {+ const t0 = std.Io.Timestamp.now(io, .awake);+ for (0..rounds) |_| {+ for (fds, 0..) |fd, i| {+ const n = linux.pread(fd, &dest[i], dest[i].len, 0);+ if (linux.errno(n) != .SUCCESS or n != file_bytes) return error.ShortRead;+ }+ }+ return @intCast(std.Io.Timestamp.now(io, .awake).nanoseconds - t0.nanoseconds);+}++fn timeUring(io: std.Io, fds: *const [n_files]std.posix.fd_t, dest: *[n_files][file_bytes]u8) !u64 {+ var ring = try linux.IoUring.init(128, 0);+ defer ring.deinit();+ const t0 = std.Io.Timestamp.now(io, .awake);+ for (0..rounds) |_| {+ for (fds, 0..) |fd, i| {+ _ = try ring.read(@intCast(i), fd, .{ .buffer = &dest[i] }, 0);+ }+ _ = try ring.submit_and_wait(n_files);+ var cqes: [n_files]linux.io_uring_cqe = undefined;+ const got = try ring.copy_cqes(&cqes, n_files);+ if (got != n_files) return error.ShortCq;+ for (cqes[0..got]) |c| {+ if (c.res != file_bytes) return error.ShortRead;+ }+ }+ return @intCast(std.Io.Timestamp.now(io, .awake).nanoseconds - t0.nanoseconds);+}