From 3e5ad32c529c4c566989ef8201159100a4a3e32c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 01:52:03 -0300 Subject: The State as files: state/ in the 9P tree, a directory per struct and array state/ serves the running sketch's State nested: a directory per struct and per array, a file per value, state/tracker/songs/3/bpm. A read is the value as get shows it, and a newline; a write is the console's set with the file's path (control.zig builds `set tracker.songs[3].bpm 90` and runs it through runLine, so it stops a replay, logs, marks a jump and notes the line like any set). Numbers, bools and enums are written; optionals, unions and the like read as `` and refuse writes. An array of scalars (a vector's lanes, talk.text) is one file of its values, blank-separated; an array of arrays is a directory of such rows (grid/1 for grid[1] of a [2][3]i16). So a file is one value or one row, the run of values one set names, and stays the size of a row however large the array; and paths keep the State's own shape. An array of structs is a directory of indices: drat-meout's patterns, 8x16x16x4 of {pitch, velocity}, are state/tracker/songs//patterns//// pitch, reached by walking, listed a dimension at a time. state_files.zig does the walking from a (Layout, bytes) alone: lookup, readdir, read, the set path and a README line per file, so the save's newest State and a sketch's defaults can be served the same way. A node is the layout's first leaf under it, its depth and the element's offset, with bit 62 set (bit 63 stays the sketch's). A node a reload made stale is refused, "StateLayoutChangedWalkAgain". fields.setRow sets a row from its words, all or none, and the console's set takes it: `set talk.text 104 105 0`. The engine keeps names up to 64 bytes (from 28), for long field names. Tests: test-control (now also "the State as files" and "a row of scalars"): 40/40 steps, 9/9 tests. Live, headless, the replay fixture over plan9port 9p: ls state, read and write dots/buffer/3/kind and the position vector, a bad value refused as InvalidValue. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- src/host/root.zig | 1 + 1 file changed, 1 insertion(+) (limited to 'src/host/root.zig') diff --git a/src/host/root.zig b/src/host/root.zig index 42362d3..44512b2 100644 --- a/src/host/root.zig +++ b/src/host/root.zig @@ -216,5 +216,6 @@ test { _ = @import("audio.zig"); _ = @import("Console.zig"); _ = @import("control.zig"); + _ = @import("state_files.zig"); _ = @import("timing_marker.zig"); } -- cgit v1.3