<feed xmlns='http://www.w3.org/2005/Atom'>
<title>sketchbook.git/src/host/state_files.zig, branch main</title>
<subtitle>A small Zig platform for sketching games and toys</subtitle>
<id>https://git.0x4200.cafe/sketchbook.git/atom?h=main</id>
<link rel='self' href='https://git.0x4200.cafe/sketchbook.git/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/'/>
<updated>2026-11-17T15:15:01Z</updated>
<entry>
<title>The tree describes itself: README and commands from the tables; ctl takes input live</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T04:53:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=f3591d48a16086dd4b3b081da00804d2541fefcc'/>
<id>urn:sha1:f3591d48a16086dd4b3b081da00804d2541fefcc</id>
<content type='text'>
README is made at each open from the tables (pinned per open, as the
traces are): a line a file from control.zig's `files`, ctl's verbs
indented under ctl (ctl's own, the script's input verbs, the console's,
each with its args and doc from its row), and a line per State file under
state/, from the layout (its path with &lt;n&gt; for an index, its type, an
enum's tags, a row's length), in the shape cloud9's `help` reads:
`help ctl` prints the verbs, `help state/tracker` the state/ line and
every file under it. `commands` is the verb lines alone, unindented,
the sketch's own words (App.commands) last. A ctl read points at both.

ctl takes the script's input verbs live: click, move, down, up, wheel,
wheel-x, cancel, key, hold, release, type route their events at the wall
clock through script.input, the same code a script runs, with no frame
of their own: the next frame feeds them to update. Order: ctl's own
words, then the input verbs, then a console line (and through it the
sketch's); so a sketch command named like an input verb is shadowed over
ctl (none is today).

Tests: test-control, a new test: ctl's click and hold reach the pending
events, a short click is refused (ExpectedPoint), README and commands
read the rows and the layout: 40/40 steps, 10/10 tests. Live with the
replay fixture: README read over 9P, `down 5 5` written to ctl moved
state/pressing.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
<entry>
<title>The State as files: state/ in the 9P tree, a directory per struct and array</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T04:52:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=3e5ad32c529c4c566989ef8201159100a4a3e32c'/>
<id>urn:sha1:3e5ad32c529c4c566989ef8201159100a4a3e32c</id>
<content type='text'>
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 `&lt;N bytes&gt;` 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/&lt;n&gt;/patterns/&lt;n&gt;/&lt;n&gt;/&lt;n&gt;/
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 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
</feed>
