summaryrefslogtreecommitdiff
path: root/core/fs.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 14:29:10 -0300
committerGabriel Schneider <[email protected]>2026-11-20 14:55:38 -0300
commite3d0daa9f89f41b41b7d05d510db553cbd8816d9 (patch)
tree6602e8aca69ec3c160021d4975c43456d38801df /core/fs.zig
parent8a8ce0a6740e9a98ea37a70d401c3ba3fffe0ee1 (diff)
parent27837e6345b51ceb2ceaaee58fd593024feb07c8 (diff)
downloadpardes-e3d0daa9f89f41b41b7d05d510db553cbd8816d9.tar.gz
pardes-e3d0daa9f89f41b41b7d05d510db553cbd8816d9.zip
integration: a client that joins a session with 9P work under way has its 9P state, on the budget as a count and the window's pair: pardes-faults-4 (the open records and each pane's 9P state in the dumps and the digest, dropped again at a revive on a new host; hand-written digests so a step's counts do not move) and pardes-merge39; two conflicts, both the wire's version: the pair's close byte and the 9P state each took 24 on their own lines: the close byte keeps 24, the 9P state is 25, abi/wire.zig's version and test/daemon.py's WIRE are 25; tui core-test 871/1028 (157 skipped), shell-test 1070/1073, term-test 17/17, both soaks diverged 0, unequal 0, unlisted 0, the window builds; the coordinator's gate in the ledger (reorg/merge40)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/fs.zig')
-rw-r--r--core/fs.zig63
1 files changed, 63 insertions, 0 deletions
diff --git a/core/fs.zig b/core/fs.zig
index 6e5829e1..eadb7c19 100644
--- a/core/fs.zig
+++ b/core/fs.zig
@@ -841,6 +841,33 @@ pub const EditHold = struct {
};
pub const Namespace = struct {
+ /// What a step reads that 9P requests made (every request an input
+ /// each replica replays) is the core's like any state: the open
+ /// records (a command pane a script reads is not taken again:
+ /// exec.leased), the panes the last look or exec touched (a new open's
+ /// own), the writes held to go in as one edit and a header tag's
+ /// truncation, digested and dumped (a client's join takes them from
+ /// the dump; a session revived from one drops the opens with the
+ /// connections that held them: dump.zig `loadAndRevive`). The rest is
+ /// the server's (core/walk.zig): its sockets and the mounts (dumped
+ /// on their own), the log and what a reader or a listener is answered
+ /// with, and the request being served's own flags, set and read in
+ /// its step. ponytail: `edit_hold`, set by the session's listener
+ /// between steps and read by the retried write's step, is no
+ /// replica's (reports/pardes-faults-4.md).
+ pub const replica = .{
+ .authority = .{
+ "socket_path", "tcp_address", "mounts", "node_name", "os_paths", "out",
+ "listeners", "origin", "no_prompt", "session_write", "unlogged", "capturing",
+ "serving", "refused", "failure", "failure_len", "no_pane_slot", "no_pane_slot_len",
+ "said", "said_len", "said_at", "late_failure", "late_failure_len",
+ "lsp_answer_at", "edit_started", "edit_hold", "edit_said", "lsp_result", "write_room",
+ "write_waits", "log_full_hash", "pages", "closed_lines", "ran_at", "refilled",
+ "failures", "ename", "news", "hanging_up", "log", "plumb_held",
+ "started",
+ },
+ .len = .{ .{ "opens", "opens_len" }, .{ "results", "results_len" } },
+ };
socket_path: []const u8 = "",
tcp_address: ?std.Io.net.IpAddress = null,
mounts: std.ArrayList(Mount) = .empty,
@@ -848,6 +875,9 @@ pub const Namespace = struct {
os_paths: std.ArrayList(OsPath) = .empty,
/// What each open holds between its open and its release.
opens: [tree.open_slots]tree.Open = @splat(.{}),
+ /// The records past it are free: a digest and a dump take the opens
+ /// this far (an idle session's none).
+ opens_len: u8 = 0,
out: std.ArrayList(u8) = .empty,
listeners: u16 = 0,
origin: u8 = 'K',
@@ -995,6 +1025,39 @@ pub const Namespace = struct {
st.out.deinit(gpa);
}
+ /// Its digest (core/walk.zig): the opens in use, and writes held by
+ /// their length (their bytes are the same writes on every side; a
+ /// stream of 8 KB appends hashed whole cost each its length again;
+ /// none held, the rest of `batch` is nothing a step reads), the panes
+ /// the last look or exec touched, a header's truncation. Nothing at
+ /// all for a session no script holds anything of.
+ pub fn digest(st: *const Namespace, h: *pardes.walk.Hasher) void {
+ comptime if (pardes.walk.fieldNames(Namespace).len != 8) @compileError("Namespace.digest: hash every field the walk does not leave out");
+ for (st.opens[0..st.opens_len]) |*o| pardes.walk.hash(tree.Open, o, h);
+ h.update(std.mem.sliceAsBytes(st.results[0..st.results_len]));
+ if (st.header_rewrite != null or st.header_trunc_pending != null or st.header_held) {
+ const words = [_]u64{ st.header_rewrite orelse std.math.maxInt(u64), st.header_trunc_pending orelse std.math.maxInt(u64), @intFromBool(st.header_held) };
+ h.update(std.mem.asBytes(&words));
+ }
+ const b = &st.batch;
+ if (b.bytes.items.len == 0) return;
+ const words = [_]u64{ b.serial, b.node, b.handle, b.at, b.bytes.items.len, b.last_ns };
+ h.update(std.mem.asBytes(&words));
+ }
+
+ /// What the requests of connections gone made, let go: a session
+ /// revived from a dump has none of the connections that held its opens.
+ pub fn forget(st: *Namespace, gpa: std.mem.Allocator) void {
+ for (&st.opens) |*o| o.deinit(gpa);
+ st.opens_len = 0;
+ st.results_len = 0;
+ st.batch.bytes.deinit(gpa);
+ st.batch = .{};
+ st.header_rewrite = null;
+ st.header_trunc_pending = null;
+ st.header_held = false;
+ }
+
pub fn mount(st: *Namespace, gpa: std.mem.Allocator, name: []const u8, dial: []const u8) !void {
if (!validMountName(name)) return error.BadMountName;
try ninep_io.Client.validateDial(dial);