From 5e162e2e8b208367720b8be8de3bfe51b010aa68 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 05:50:51 -0300 Subject: core: the reads no tape saw are taped, and a check counts what core/ asks of the machine (the reorganisation's 12b, the design round's step 4 and its finds): DumpDir's check whether its directory may be written (fs.deniedAbove in config.Runtime.apply, two `access` calls in a step) is the session's disk's answer, tape.value(.denied) as a failed save's is, and Font and Fonts, which walked the machine's font directories in a step (dev/fonts.list), ask the session's machine through a new site, `fonts` (a far client's Font or Fonts waits a round trip; its replay takes the session's answer); each was a real fault: a client on another machine diverged at its replay of the session's unit, a test each at the end of core/replica.zig (a directory the session may not write and the client may, the setting refused on both; a face the session's machine has and the client's lacks, its family renamed so no installed face shares it, listed and chosen alike on both), each shown failing on the change before (the digests differ); Edit's pipe environment (host_io.commandEnv) is shown harmless and left as it is: it is kept in Pipe.edit_run, `.authority` state (Pipe.zig:21: in no digest and no copy), read only by the host's `pipe` entry, which a client never calls (a speculation records the void call, a replay answers from the tape); the check, the twin of allowed_vars, at the end of core/root.zig: per file of core/, the lines outside tests naming std.c., libc., std.posix., getenv, std.Io's File, Dir, net or Threaded (not Dir.path, a path's text, nor max_path_bytes) or importing dev or runtime, against one list, machine_lines, 34 files and 313 lines, each file with why; a file whose count moves is named with its lines, shown failing once (a getenv added to Messages.zig: 7 lines against 6, its line 891 named); found by it and not changed: Messages.noTime reads PARDES_NOTIME in a step (a test's knob: set on one side only it would diverge); may_wait gains Font and Fonts at `fonts` in a window's build; Stats.unspeculated is not deleted: its only reader is the soak's (test/replicas.zig: the field, its sum, the view column), a file another agent is rewriting; the semantics word moves again (a site added), 517cd1c276996a3c -> 0900e560fd6395ef; tui core-test 836/979 (143 skipped), shell-test 1014/1017, pane-test 183/184, behaviour-test 275/275 and --replay 275/275, process-test 2 of 144 failed (lspcomplete, lspcompletemoved, the base's), replicas --clients 5 diverged 0 unequal 0 deltas wrong 0 (1827/0, 1596/0, 1803/0) quiet differ 0 (422/0, 563/0, 655/0) at 30/80/207 ms, stopped 89/73/108, mispredicted 37/34/36, gui unit-test 1612/1616 (its perf check's BaselineHarnessMismatch the base's), daemon.py plain, --far, --games, --window-clients pass; gate-w seam-b-4 against tree1: 77/77 frames byte-identical in Debug, its unit-test 1612/1616, perfab corpus2x +0.047% (pictures identical in all 10 runs), perfops 97 counts within 0.1% (largest +0.0199%, body-appends on longline) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/root.zig | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) (limited to 'core/root.zig') diff --git a/core/root.zig b/core/root.zig index ae6fc454..c10a2598 100644 --- a/core/root.zig +++ b/core/root.zig @@ -593,3 +593,129 @@ test "nothing of a core is a process global: every container-level var in core/ try std.testing.expect(files > 100); try std.testing.expectEqual(@as(usize, 0), unlisted); } + +/// The lines of each file of core/ that name the machine outside a test: +/// `std.c.`, `libc.`, `std.posix.`, `getenv`, std.Io's File, Dir, net and +/// Threaded (a path's text, `Dir.path`, and `max_path_bytes` are none), and +/// `@import("dev")` and `@import("runtime")`, by file, how many and why. A +/// step's read of its own machine with no tape diverges a far client, and +/// the soak (one machine) never sees it: a new line here makes someone look. +/// The count is a file's, so it cannot tell a step's read from its host +/// half's; the reason says which the file's are. +const machine_lines = [_]struct { []const u8, usize, []const u8 }{ + .{ "Addon.zig", 48, "the process's addon libraries: the start's scan of their directories, dlopen, the crash mark; the host's, never a step's" }, + .{ "Core.zig", 5, "the session's directory read once at its start (taped), a frame log (PARDES_FRAMES), a host_io type" }, + .{ "Db.zig", 18, "the state file every session of the user shares: the authority's (`db`), off in every replica" }, + .{ "Dir.zig", 2, "a directory's listing, the function under tape.site(.dir_listing)" }, + .{ "Effect.zig", 1, "host_io, named for the host entries it performs" }, + .{ "FrameStats.zig", 7, "a frame's clock and log: frames are local, never digested" }, + .{ "Handover.zig", 29, "a window carried to another process over a socket: the session's host" }, + .{ "Kind.zig", 1, "host_io's KindJob: a kind's job is the host's" }, + .{ "Messages.zig", 6, "the message clock, read through tape.value(.clock); PARDES_NOTIME, the tests' (a step's read of the environment: set on one side only it would diverge)" }, + .{ "Output.zig", 2, "the fonts module (Fonts lists them under tape.site(.fonts)) and the build's version line" }, + .{ "Stream.zig", 14, "the disk search's worker: it runs off the step and its batches are inputs" }, + .{ "builtins.zig", 2, "Mount's probe (tape.site(.probe)) and Term's shell check (tape.site(.shell))" }, + .{ "config.zig", 6, "the default shell, read once at the start (taped); the config file read at startup and written by DumpConfig (the session's); the docs check's" }, + .{ "draw.zig", 1, "PARDES_TEST_CLOCK: a frame's, not a step's" }, + .{ "dump.zig", 4, "a dump's clock and the state file's directory (XDG, the process's directory): the session's side (a client's Restore waits)" }, + .{ "echo.zig", 1, "PARDES_REPLICA_TRACE: a trace" }, + .{ "edit_cmd.zig", 1, "Edit's pipe environment (host_io.commandEnv): kept in Pipe.edit_run, `.authority` state, read only by the host's `pipe`, which a client never calls" }, + .{ "exec.zig", 4, "kindOf's stat (tape.site(.kind)) and Shell's check (tape.site(.shell))" }, + .{ "fs.zig", 39, "the file system behind the tape's sites (open, read, write, stat, mkdir, access), the process's home (read once at the start, taped), the 9P transport" }, + .{ "hunks.zig", 1, "a test helper's file read" }, + .{ "look.zig", 6, "openLink's fork (the host's: a view's frontend opens a link) and a remote's error name" }, + .{ "memory.zig", 7, "the memory regions themselves (mmap, madvise, their locks)" }, + .{ "replica.zig", 70, "the client and session engines: sockets, threads, clocks, the blob cache, traces" }, + .{ "rollback.zig", 1, "a test helper's directory" }, + .{ "root.zig", 4, "dev's modules re-exported (host_io, file_watch, glide, fonts)" }, + .{ "selection_pipe.zig", 14, "a pipe's child processes and their files: the host's `pipe` entry" }, + .{ "tape.zig", 10, "the tape's own files and host_io's types: a recording, a replay" }, + .{ "lsp/lsp.zig", 1, "the language server's client (dev): the host's `lsp` entry" }, + .{ "ninep/ctl.zig", 1, "the session's pid in a 9P read: the session's server" }, + .{ "ninep/events.zig", 2, "the 9P event log's clock: the session's server" }, + .{ "ninep/pty.zig", 1, "a 9P exec's shell check (tape.site(.shell))" }, + .{ "ninep/screen.zig", 1, "a 9P address's text type" }, + .{ "ninep/tree.zig", 1, "the daemon's registry (/sessions, tape.site(.sessions))" }, + .{ "term/terminal.zig", 2, "the emulator's image files (TMPDIR) and its Io: the session's emulator (a client's are written by deltas)" }, +}; + +/// The lines of `src` that name the machine (`machine_lines`'s rules). +fn machineLines(src: []const u8, gpa: std.mem.Allocator, out: *std.ArrayList(usize)) !void { + const names = [_][]const u8{ "std.c.", "libc.", "std.posix.", "getenv", "std.Io.File", "std.Io.Dir", "std.Io.net", "std.Io.Threaded", "Io.File", "Io.Dir", "Io.net", "Io.Threaded" }; + const pure = [_][]const u8{ "std.Io.Dir.path.", "Io.Dir.path.", "std.Io.Dir.max_path_bytes", "Io.Dir.max_path_bytes" }; + var open: std.ArrayList(u8) = .empty; + defer open.deinit(gpa); + var tests: usize = 0; + var line: usize = 1; + var i: usize = 0; + while (i < src.len) { + const c = src[i]; + if (c == '\n') line += 1; + const at = src[i..]; + if ((c == '/' or c == '\\') and i + 1 < src.len and src[i + 1] == c) { + i = std.mem.indexOfScalarPos(u8, src, i, '\n') orelse src.len; + } else if (c == '@' and tests == 0 and (std.mem.startsWith(u8, at, "@import(\"dev\")") or std.mem.startsWith(u8, at, "@import(\"runtime\")"))) { + if (out.items.len == 0 or out.getLast() != line) try out.append(gpa, line); + i += 1; + } else if (c == '"' or c == '\'') { + i += 1; + while (i < src.len and src[i] != c) : (i += 1) if (src[i] == '\\') { + i += 1; + }; + i += 1; + } else if (c == '{') { + const kind = braceKind(src[0..i]); + if (kind == 't') tests += 1; + try open.append(gpa, kind); + i += 1; + } else if (c == '}') { + if ((open.pop() orelse 0) == 't') tests -= 1; + i += 1; + } else if (std.ascii.isAlphabetic(c) or c == '_') { + const named = for (names) |n| { + if (std.mem.startsWith(u8, at, n)) break true; + } else false; + const path = for (pure) |n| { + if (std.mem.startsWith(u8, at, n)) break true; + } else false; + if (tests == 0 and named and !path and (out.items.len == 0 or out.getLast() != line)) try out.append(gpa, line); + i = wordEnd(src, i); + } else i += 1; + } +} + +test "what core/ asks of the machine is where the list says, with why: a new line naming libc, std.c, std.posix, getenv, a std.Io file, directory or socket, dev or runtime is named" { + const gpa = std.testing.allocator; + const io = std.testing.io; + var dir = try std.Io.Dir.cwd().openDir(io, "core", .{ .iterate = true }); + defer dir.close(io); + var walker = try dir.walk(gpa); + defer walker.deinit(); + var found: std.ArrayList(usize) = .empty; + defer found.deinit(gpa); + var wrong: usize = 0; + var seen: [machine_lines.len]bool = @splat(false); + while (try walker.next(io)) |e| { + if (e.kind != .file or !std.mem.endsWith(u8, e.basename, ".zig")) continue; + const src = try e.dir.readFileAlloc(io, e.basename, gpa, .limited(16 << 20)); + defer gpa.free(src); + found.clearRetainingCapacity(); + try machineLines(src, gpa, &found); + const listed: usize = for (machine_lines, 0..) |m, k| { + if (std.mem.eql(u8, m[0], e.path)) { + seen[k] = true; + break m[1]; + } + } else 0; + if (found.items.len == listed) continue; + wrong += 1; + std.debug.print("core/{s}: {d} lines name the machine, root.zig's machine_lines says {d}:", .{ e.path, found.items.len, listed }); + for (found.items) |l| std.debug.print(" {d}", .{l}); + std.debug.print("\n a step that reads its own machine with no tape diverges a far client: tape the read (tape.site, tape.value), or count the line with why it is not a step's\n", .{}); + } + for (machine_lines, seen) |m, s| if (!s) { + wrong += 1; + std.debug.print("core/{s}: on machine_lines, and no such file\n", .{m[0]}); + }; + try std.testing.expectEqual(@as(usize, 0), wrong); +} -- cgit v1.3