summaryrefslogtreecommitdiff
path: root/src/host/control.zig
Commit message (Collapse)AuthorAge
* state/: a value is read as it was at the openGabriel Schneider94 min.
| | | | | | | | | | | | | | | | | A read of a State file formatted the value at each Tread and sent the window at its offset; a value that changed between two reads (a float a frame moves) could change length, and the second read sent the tail of the new text after the head of the old: `1.526633` then `5`, which a shell loop awaiting a number read as "1\n4". Now the open formats the value once into one of the connection's snapshots, as the traces and README are, and reads window it; release frees it. A write is unchanged. Found driving drat-meout from a shell loop, `until [ "$(drat-meout fs read state/street/time | cut -d. -f1)" -ge 3 ]`. Tests: test-control and test-fs, 51/51 steps, 11/11 tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* The door for sketch-owned files: sketch/ and the nodes from 2^63, reservedGabriel Schneider94 min.
| | | | | | | | | | | | | | | | | | | | | | A sketch may one day serve files of its own (an embedded editor's buffers, Round 2 §4 of the 9P survey): the host's tree now keeps the place for them and builds nothing behind it. sketch/ is an empty directory the host never fills (its README line says so); every node from 2^63 on is the sketch's, and the host answers none but sketch/ itself (2^63): a lookup under it, or any other node of the range, is UnknownFile. state/'s nodes have bit 62 set and bit 63 clear, so the two ranges never meet. Served offline too, empty. Later, one optional ABI entry can take the requests whose node is in the range or under sketch/, cloud9's engine keeping fids, permissions, readdir cursors and parking; not now. Tests: test-control, a new test: sketch/ is a directory, empty, nothing under it, and nodes of the range refused; README names it. test-control and test-fs: 51/51 steps, 11/11 tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* Dial by name, and fs in every sketch's binary, answering with the sketch closedGabriel Schneider94 min.
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A run a person watches (not headless, a script or an export) posts its tree as $XDG_RUNTIME_DIR/9p/sketchbook/<name>, the sketch's Info.name; --9p NAME posts under another name, --9p /path listens at a socket path as before. A name a live run holds is refused, a stale one replaced; a default post that fails says so and the run goes on without one, an explicit --9p that fails ends it as before. (cloud9's post() takes names without a slash, so control.zig makes the sketchbook/ directory and binds there itself, with post.probe deciding live or stale.) `fs VERB [PATH [WORDS]]`, after the options, in the generic host (`sketchbook LIBRARY fs ...`) and in every executable built with sketchbook (`drat-meout fs read state/scene`), is cloud9.verbs.run on an Fsys: the running sketch's tree when one is posted (or at --9p), else the same tree served in this process over a socketpair, on a thread (Control.serveOffline, the same respond with `offline` set), from the save's newest State (--state's save, else the default one; read only: Sessions.openRead, no session started, restored into today's layout), else from the State's declared defaults (init is not run). README, commands, ctl's read and state/ answer; a write and status, log, screen.png and the traces answer in words, "drat-meout is not running: this is its save's newest State, frame 61 of <save>". No window, no SDL. sketchbook.init's modules gain cloud9, so an app's own tests can dial its executable with cloud9.Fsys. Tests: a new step, test-fs (in test): the replay fixture posted by name under a private runtime directory, driven with its own binary's fs: ls, a state write and read, a refused value in words, a live click, a screenshot read, help of state/dots and ctl, quit and the name gone; then closed: a state file read from the defaults, status refused in words. test-fs, test-control, test-paths, test-setup, test-sessions: 56/56 steps, 27/27 tests. drat-meout's copy builds unchanged and answers fs with the game closed: 94 leaves, 16,522 files, 17,608 values, 10,408 directories. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* screen.png: one read, answered when its frame has landedGabriel Schneider94 min.
| | | | | | | | | | | | | | | | | | | | | | | | | | | A screenshot over 9P was a write of `screenshot` to ctl, then reads of status until screenshot_generation moved, then a read of screen.png (an open while a capture was pending failed). Now an open of screen.png asks for the next frame itself and is parked (cloud9's Status.again) until the capture lands: the service loop answers the engine's retry() each pass, so a parked open is asked again every frame, and respond (unchanged) answers it once nothing is pending, pinning that frame's PNG, or with the capture's error. So `9p read screen.png` or `fs read screen.png` is the whole recipe. A write of `screenshot` still works and status still counts, and an open after it waits for a frame of its own. The frame-thread loop carries the park cleanly: retry() and next() run on the frame thread between frames like every request, a parked open keeps its fid, a flush or a hangup drops it, and the four parking slots a connection has bound how many wait at once (a fifth open is refused "waiting"). Tests: test-control 46/46 steps, 10/10 tests (the snapshot test's CapturePending is now what answer() parks). Live, headless, the replay fixture: three reads of screen.png with no write, 24-26 ms each with the 9p process's start, 640x360 PNGs; the old write-then-read still works. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* The tree describes itself: README and commands from the tables; ctl takes ↵Gabriel Schneider94 min.
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | input live 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 <n> 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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* The State as files: state/ in the 9P tree, a directory per struct and arrayGabriel Schneider94 min.
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* One verb table: the flags, the console's, the script's and ctl's words are rowsGabriel Schneider94 min.
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add display-paced frame timing and presentation feedback in ZigGabriel Schneider17 hours
|
* Add glTF scene rendering, resource setup and 9P controlsGabriel Schneider20 hours