| Commit message (Collapse) | Author | Age |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 `<N bytes>` 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/<n>/patterns/<n>/<n>/<n>/
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Six hand-kept lists said one vocabulary: root.zig's parser, its usage
and its header; the console's completion list, its help strings and the
execute chain; Host.zig's list of lines that do not move State; the
script's header comment and its step chain; control.zig's names and its
magic node numbers. Now each is a table, and the parser, the help, the
completion and the dispatch read it.
- root.zig: `Flag`, an enum, and `flags`, a row each (arg, doc): the
loop looks the word up, takes its argument when the row names one, and
a switch sets what it means; `usage` is made from the rows at compile
time (the same text, and a line for --help). Errors say the flag and
what it needs.
- Console.zig: `Verb` and `verbs`, a row each (args, doc, moves_state):
execute is a switch on the verb, a line whose first word is none goes
to the sketch as before; Tab completes from the rows (a verb, and with
each lowercase word its first argument may be: `seek start`); `help`
prints the rows wrapped to the log's width, `help VERB` its line.
- Host.zig: movesState asks the row; a sketch's command moves State.
- script.zig: `Verb` and `verbs` (args, doc, frame, input): step is a
switch, a row with `frame` is followed by one; the input verbs are
`input`, which a 9P ctl will call live.
- control.zig: `File` and `files` (mode, doc), a node being its number
(the same numbers); `Verb` and `verbs` for ctl's own two words.
Behaviour is unchanged but for help's text, completion's list (the same
words, and `timing`, `play`, `seek`... alone) and errors' words. The
diff adds more than it deletes (+630 -521): the rows carry a line of doc
for every verb, which nothing had before.
Tests: test-control, test-timing, test-setup, test-same, test-kill,
test-past, test-import, test-paths: 70/70 steps, 29/29 tests.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
first
A save grew without bound. Now Sessions.max_save is 64 MiB and
layout.max_state 32 MiB, so history always has room (the compile error
says so: "State is N bytes, and may be 32 MiB, half of a save, so
history has room: ...").
A commit that leaves the file past the cap trims it (Sessions.trim): one
transaction drops history oldest first, a keyframe by removing its pages
(its frame, batch and time stay, so keyframe numbers, keyBefore and
marks by index still resolve) and a batch of frames by emptying its
slot, until the keyframes' written pages and the batches left count
three quarters of the cap; then the file is compacted into `<path>.new`
and renamed over it, and the run goes on in the new file (compact now
reopens). A dropped keyframe's pages may still be shared by a later one,
so a round can free less than it counted: the next round lowers the
count by the overshoot, four rounds at most. Never dropped: the present
(the newest keyframe and the batches from its own on), the keyframe of
the newest mark of each name, the keyframe of the newest clip of each
name and every batch holding one of its frames. A session left with
nothing loses its keyframes, batches and stretches; its summary stays.
Asked for, what was dropped is error.HistoryDropped, which the console
says in words ("That part of the history is gone: a save keeps 64 MiB,
the newest.").
Marks are pinned under the cap: a mark of a new name needs room for a
whole State, history trimmed to make it; without, it is refused,
error.SaveFull, the console saying how to make room: save over a mark's
name (the older one then goes with history) or start another save. A
mark over an existing name is always taken. (The spec's "room" rule,
refusing only after a trim failed, let one mark take the file past the
cap; room for a whole State keeps the cap hard, at the price of
refusing early for a big State.)
Builds that do not record (`history` false, from Info.record) use the
same mechanism with the history limit zero: every commit holding a
keyframe drops all it may (no compaction unless past the cap), and the
exit compacts, so the disk holds at most the last minute of input while
it runs and the present and the marks after. The exit compaction a
recording build made past twice its contents plus 64 MiB is gone: the
cap's compaction does that work.
Measured (Debug, unit test): a trim of a 64 MiB file to 48 MiB takes
165-187 ms (two rounds of drop and compaction, the first ending 0.5%
over); a no-history trim at a keyframe, 0-5 ms. ReleaseFast not
measured.
The console's `marks` reads each mark's keyframe fields, not its State:
an older mark of a name may have gone with history (listed "dropped"
when its session went whole). Docs: record means "keep history" in
App.Options, sketch.Build and abi.Info.
Tests: zig build test, 168/168 steps, 137/137 tests. New, in
Sessions.zig: 100 keyframes of 1 MiB each with marks at the 5th and
20th: the file never past the cap, the oldest keyframes and frames
HistoryDropped, both marks and the newest keyframe whole, the present's
frames readable; without history, 20 keyframes and a mark: only the
mark and the present stay, the file compacted at exit under three times
the State and the present reopening whole; 2 MiB marks until one is
refused (SaveFull, the file under the cap), then one over an old name
taken and the file under the cap, every mark whole. micscope 67/67,
10/10; spheres 75/75, 3/3; noc e2e 292/292; the drat-meout copy 87/87,
30/30.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A sketch kept its live State in a mapped state file and its history in
a sessions database beside it. Now the database is the save, the one
file: the present is its newest keyframe and the frames logged after
it, and a run starts there (Sessions.present: the newest session with a
keyframe, its last keyframe loaded and the frames after it read). Host
restores it (migrating across a layout change, as a seek does) and
replays the frames through `update`, unlogged, `started` as it was fed
(true only from a session's first frame); played by another build, they
are not replayed, and the run says how many frames that was. The run's
first keyframe then starts from the present's pages, so a session costs
what changed since the last one. --fresh still starts from defaults,
the save untouched.
State is process memory (memory.State: one page-aligned allocation, its
layout, and its layout header for the stretches); a reload's adopt
allocates the new layout's defaults and migrates the old bytes into it,
and returns null when unchanged. Gone: StateFile, its slots, used bits,
resize, dropSnapshots and the adopt that rewrote a file's header; the
sketch-facing `Host.state` keeps `layout`; Timeline restores into
`state.live()`. `adopt` no longer runs `init`: openPresent does when
there is no present.
Every run saves: the database is opened in a file for every run but a
scripted one from fresh state (memory, nothing on disk) and an export
(none). So release builds keep their State as before, and marks and
clips work there; `.record` keeps or trims history (next change).
The save is `<stem>.xitdb`, `<stem>` being --state without `.xitdb` or
`.state`: `--state x.state` and `--state x.xitdb` name the same save.
Defaults: `.sketchbook/<name>.xitdb` under zig build run, and
`$XDG_DATA_HOME/<name>/<name>.xitdb`. A sketch's appended files are
`<stem>.<name>` (micscope's takes: `.sketchbook/micscope.take-3.f32`,
where Phase 1 wrote `micscope.state.take-3.f32`; that naming never left
this workspace, so nothing of the user's is renamed). A scripted run
from fresh state or an export appends to `<stem>.<pid>.<name>` and
removes those at exit; the private state file and the exit's moving of
files by prefix are gone from root.zig.
Old state files: in a new save, `<stem>.state` (one slot or eight, any
of the three formats) is imported once: slot 0 becomes the present (in
today's layout), slots 1-7 marks "1".."7" (migrated to it, as before);
the file is read through a read-only mapping and left exactly as it
was. It is never read again: the save then has a session. A file that
is no state file is said and left. .sketchbook/'s move of an older
build's `<stem>.state` from beside it stays, now by stem.
sketchbook-probe is deleted (86 lines, its build step, Sketchbook's
probe_exe, App.addProbe): it mapped the state file. Reading the save
instead would show State as of the newest keyframe, up to a minute old,
never the frames after it, which only `update` can turn into State;
and it would need a read-only open the host has no other use for. The
planned 9P state/ tree reads live State from the process.
A kill -9 now loses what the session log always lost: the frames not
yet committed (under a second: in test-kill 15 of 255 frames, the
next run starting from frame 240's State), keyframes and marks queued
since the last commit (a mark commits at once, synced), the session's
end time and an open clip's end. The mapped file lost nothing to a
kill. A power loss reopens at the last commit the disk holds whole
(`mend`); commits are fsynced only for marks and at exit, so what the
OS had not written back is lost (not measured); the mapped file, never
synced, could tear page by page.
Measured: drat-meout's State, 20 extra jump keyframes in a 2,400-frame
script, 100,708 B more than the same frames without them: about 5 KB
a keyframe, where the whole State (17.7-20 KiB) was written each time.
Tests: zig build test, 168/168 steps. test-kill runs for a recording
and a non-recording build, and the second run checks `updates` is 240
(replayed), not only the session's frame count. test-paths: the XDG
directory holds `replay.xitdb` alone; .sketchbook/ holds `.gitignore`
and `replay.xitdb`; the next run's State is the one the last left; an
older `old.state` beside .sketchbook/ is moved in once, never over a
file, and left as it was when it is no state file. test-same: a run
from fresh state leaves no file at all. Rewritten: memory.zig's state
file tests as State's (migrate, unchanged) and OldState's (refused
untouched; drat-meout's v1 fixture imports every value, the file
unchanged), Host's snapshot import as importOld (State live, two marks,
the file byte for byte as it was), Host's setup test without a file,
the timeline test on a State. micscope 67/67, 10/10; spheres 75/75,
3/3; noc e2e 292/292; the drat-meout copy 87/87, 30/30.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
export-session [S] FILE writes session S (this run's by default, committed
first), with the marks and clips that point into it, as session 0 of a new
database: written beside FILE, synced, renamed over it. import FILE appends
each session of such a file to this database, from "import <file name>",
its marks and clips renamed NAME@<file name> (cut to 32 bytes). The copy is
value by value, the same few lines for both, over whatever a session holds;
sessions lists where one came from.
test-import records test/past.script's session, exports it, imports it into
another database and replays it there: the mark it carries is the State
half a second in exactly, and two seconds in is frame 120's.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
play session S [at SECONDS] restores the session's keyframe before that
time (a binary search over its keyframes' times), replays its frames up to
it and leaves it paused there; without a time it plays from the start. At
each later keyframe the replay reaches, the State is compared with it over
the leaves migration kept: a keyframe taken of what update made (periodic,
mark, before a reload, exit) that differs is reported once, "diverged
before frame F: N values, first <field>", and every keyframe is restored,
so a replay across a jump the log does not hold (set, load, a sketch
command) goes on from the State that followed it. A session built from
another source or build says so. The console's status line names the
session, frame and time, the mark, the clip and where it records.
test-past records a session, replays it by the same build (the mark's
State exactly, frame 120's two seconds in, no divergence), then by a build
with an edited fixture (one divergence, before the mark).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The state file keeps live state only (SKETCH03, one slot). save NAME is a
keyframe and a mark in the sessions database, synced to disk; load, diff,
snapshot and expect-snapshot take mark names, through the keyframe's own
layout migrated to today's, compared over the leaves migration kept. A
file from before (SKETCH01/02) has its used snapshot slots imported as
marks "1".."7" at open, then drops them; a run that records nothing
leaves them alone.
record NAME, stop and play NAME make and play clips: a frame range of a
session and its start keyframe, nothing overwritten, nothing invalidated
by a later save, no capacity. The 64 MiB .inputs file, its --fresh memset
and Timeline's Bank are gone; numbers still work as names, so every
existing script runs unchanged. Event times in a clip are the session's,
not restarted at record. reload.script also checks that a field a reload
drops is still in the keyframe taken before it (expect-key).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Live play was recorded only after someone typed record N, into 16 fixed
slots. Now every run is a session in one xitdb database per sketch, beside
its state file (<name>.xitdb): an append-only log of the frames live
update was fed, one commit a second of session time, and keyframes of the
State at start, every minute, on jumps, before and after reloads and at
exit. A kill -9 loses at most the uncommitted second (test-kill).
Whether a build records travels in the sketch: App.Options.record, null
meaning Debug, reaching the host as Info.record. Scripted runs from fresh
state record in memory, exports not at all. Each stretch of a session
keeps its build, layout and Info.source: the repository revision (one jj
or git call per build, build_info), zig version, backend and mode.
Sessions.zig takes plain data (bytes, events, strings, a path, an Io), so
a second host can drive it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
|
| | |
|
| | |
|
| |
|
|
| |
spectrum, spectrogram), audio codecs and fonts, web host
|
| |
|
|
|
|
|
|
|
|
|
| |
- input.started: true on the first update of a run, never after a reload,
for a sketch to stop what should not resume from saved state.
- A console line that errors fails its script. Sketch commands answer
unknown, done or failed (abi.Outcome) instead of a bool that hid errors.
- addScript also takes the hot-reloadable library, run through the generic
host, so scripts can reload a real build.
- Sounds that do not load are .none, not an empty clip.
- sk_tag reads an enum field's tag name from the web build, for tests.
|
|
|
The root is the game. The platform library moves to lib/sketchbook (with
serve_web.py, which serves any sketch's web build, as a tool of it), and
vecanim to sketches/vecanim, still its own package on the same library.
|