summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
* Fsys: a deadline on every call, so a silent server is a timeoutGabriel Schneider4 hours
| | | | | | | | | | | | | | | | | | | | | | | A server that accepted and then said nothing held the caller for ever: Fsys read its socket with no limit, the version in init included, while pardes's own client gives a call 2 s and a write that runs a command 30 s. Fsys gains one field, `timeout` (an Io.Timeout), which init sets to `default_timeout`, 30 s, before it speaks; each call's answer is read by operateTimeout until that long after the call is sent, and past it the call is error.Timeout (the answer may come yet, under a tag the next call does not expect, so the connection is to be closed). `.none` waits for ever: verbs' follow sets it, since following an event file waits as long as the events take; read, ls, ask and the rest keep the deadline and say "no answer in 30000 ms; fs follow waits for ever". Test: a held read nobody feeds, on a 100 ms timeout, is error.Timeout after 90-5000 ms (poll counts whole milliseconds). cloud9's test 108 of 108; serve's "two clients at once" and "repeated connect/disconnect" failed once each at load 13 and passed in the four runs after, as on the base: they do not touch Fsys. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* verbs: the fs verbs as a function a program calls with a dialled treeGabriel Schneider4 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The user wants each app's binary to drive the tree it serves ("the cli should be like a living documentation, similar to 9p"): `pardes fs read pane/3/body`, `drat-meout fs read state/scene`. verbs.run(&fsys, args, stdin, stdout, stderr) is that command line, added in five lines (the top of the file shows them): ls, read, write (the words and a newline, or stdin a write a read of it, as 9p write), ask (write then read one open), follow (ask, or read: each answer flushed as it comes), stat (Plan 9's mode letters, length, uid, gid, mtime, name), help and complete. Exit status 0, or 1 with the server's own words on stderr; a verb not known is the usage. help PATH reads the tree's /README: a line is about the file its first word names, a path from the root with a leading or trailing slash or a comma dropped and <anything> standing for one name, and about everything under it; lines after it indented deeper go with it. pardes's src/fs-help.txt, 9proc's and 9agents' READMEs are in that shape already; sketchbook's control tree serves none yet and would write one so. complete PREFIX lists the directory PREFIX ends in, the names it starts, as paths, a trailing slash on a directory. Tests drive run() against TestTree in process: listings, reads, stats, completion, refusals in the server's words, stdin writes, ask, help including the line matcher on pardes's and 9proc's shapes, follow of three held chunks and a hangup mid-read, and the usage. Also run by hand from a scratch program of those five lines against a 9proc-demo on a Unix socket.
* Fsys: a blocking client on a socket, by path, with the server's wordsGabriel Schneider4 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Every program that serves a cloud9 tree should be drivable through it from its own binary and from agents, and pardes, 9ns and pardes's Python tests each carried a blocking client of their own. Fsys is the one the library lacked, plan9port's lib9pclient over `Client`: dial a name posted in the registry (a subdirectory entry such as pardes/main included), unix!PATH or tcp!HOST!PORT; open, create, remove, stat, read, write and clunk by path and fid; readFile, writeFile and ask (write, then read the answer on the same open from the start, as Plan 9 reads /net/cs) streaming into a std.Io.Writer, flushed per answer, so an event file whose reads park streams as it comes. A refusal is error.Refused and said() holds the server's words, which a mount would have turned into an errno. Taken from pardes's Client (src/9p_io.zig): the walk sent ahead of the request that uses its fid, the clunk not waited for, and the answers of both checked or dropped on the way to the request's, so an open, a stat or a remove is one round trip; error words kept as the server said them. Not taken: its kept-connection table, flights of read-ahead, the stat-length end of file and its pardes-only dials. From 9ns: the chunked read/write loops and the iounit. Buffers inline (2 x 64 KiB), no allocator, std.Io streams only, so it builds without libc. TestTree.zig is a small tree on serve.Runner for these tests and the next change's. Tests over a Unix socket and TCP against cloud9's own engine: whole files longer than a message, stats, walks longer than 16 names, a missing first name and a walk short of its names refused in the server's words, a refused write whose words reach the caller, a short read that is not the end, ask, a held read streaming three chunks flushed one at a time, a server that hangs up mid-read, create and remove, a directory decoded as entries, dial by posted name and a name that climbs out of the registry.
* fs: keep parked write bytes outside the slotGabriel Schneider2026-10-23
| | | | | | | | | | Slot carried its park room as an undefined array, so every slot reset and claim (initIn's @splat, a park, a flush) rewrote it: safe builds fill undefined, which made each connection's start touch all of its slots' room, 8 MiB at the default capacity. The room is now its own array on the engine, indexed by slot, written only by the copy of a parked write. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fs: look through parked slots by pointerGabriel Schneider2026-10-23
| | | | | | | | references() iterated s.slots by value, which copied every slot with its park data (8 MiB at the default capacity) onto the caller's stack: in pardes that left the editor thread's whole 8 MiB stack resident. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* Build with Zig 0.17Gabriel Schneider2026-10-21
|
* 9ns: acme's address and argument refusals reach the caller as EINVAL, not ↵Gabriel Schneider2026-10-01
| | | | | | | | | | | | | | | | | EIO; the word rules are cloud9.fs.enameErrno, for a server's tests to ask A server that keeps acme's spellings (pardes) refuses an address or a ctl argument with "no match for regexp", "address out of range", "addresses out of order", "range past end of body" and the like, as EINVAL, but none held a word 9ns knew, so a shell through the mount heard EIO. Each now maps to EINVAL, narrowly and after every older rule, so nothing that maps today is remapped. The rules move from 9ns into the cloud9 module as fs.enameErrno (Linux's numbers), 9ns's enameToErrno a cast of it, so a server's own tests can check that each refusal says its errno in words 9ns maps. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fs: a request past the parking cap is refused "too many reads waiting: N", ↵Gabriel Schneider2026-09-30
| | | | | | | | | | | | | not EAGAIN's C string The engine refused a read or write it had no slot to park with "Resource temporarily unavailable", which reads as the C library's EAGAIN and says nothing about why. The refusal now says so in words and names the cap (opts.slot_capacity), so a client can tell it has too many reads held on one connection. Refusals of what cannot park at all (a walk, a write too long to copy) keep e_again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fs: a stat of an open fid names its open to the backendGabriel Schneider2026-09-28
| | | | | | | | | acme's fsysstat answers from the fid's own window, so a file whose window went while it was open still stats. The backend's getattr for an open fid now carries its handle, so an editor can do the same: pardes keeps a run's answer after its pane closes, and a reader's fstat (cat's) must find it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* serve: a client that finds every slot taken is told so, and the backend ↵Gabriel Schneider2026-09-28
| | | | | | | | | | | | | | hears of it The runner closed an accepted connection without a word when its table was full, which a client cannot tell from a server that died. It now answers the Tversion with an Rerror "too many connections" under NOTAG, reads what the client already sent before closing (a TCP close over unread data resets), and calls the handler's new `refused`. The client takes an Rerror to its Tversion as that call's failure, with its words, instead of a broken protocol. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fs: a backend can keep a parked request by ticket and answer it later, and a ↵Gabriel Schneider2026-09-27
| | | | | | | | | | | | | | | | | | | | | clunk interrupts what is parked on its fid A backend holding a read that has nothing yet had to find its park by walking the engine's slots and matching a tag. Now Conn.hold() answers .again and returns a Ticket (slot and that park's sequence number); Conn.waiting() says whether that very park still waits, and Conn.answerWith() answers it with what a producer makes, asking the producer only while it waits and under the same lock, the way lib9p lets a server keep a Req and respond() later, so a consuming answer is never spent on a flushed request. The sequence number counts on across the connections a runner slot serves (initIn keeps it), so a ticket of one never names a park of the next. A clunk or remove fails everything parked on its fid with EINTR first, so no slot outlives its fid to be retried with a released handle or answered to a fid of the same number walked anew; retry's check for a vanished fid is gone with it. 9ns maps acme's "shut down" to EIO. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fs: name EBUSY, for a second open of something one may hold at a timeGabriel Schneider2026-09-27
|
* 9ns: keep many 9P requests in flight, so a parked read no longer freezes the ↵Gabriel Schneider2026-09-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mount 9ns served one FUSE request at a time per 9P server, so a read the server parks (pardes's log, a pane's event) held up every other operation on the mount: with 'cat log' parked, 'cat status' took 3.5-4.5 s instead of ~1 ms. nine.zig: the session is shared by threads and multiplexes by tag the way Plan 9's mount driver does (devmnt.c mountio/mountmux/mntgate/ mntflushalloc). Each thread calls through its own nine.Caller (reply buffer, wake-up eventfd, interrupt source, ename). A call writes its T-message under wlock; the first waiter with nobody reading takes the reading baton, reads for everyone and hands each R-message to the caller its tag names, then passes the baton on. Tflush is per tag: a reply that beats the Rflush is honoured, the flushed tag is not reused before the Rflush, the baton is let go before the flush is written. With every tag taken a call waits for one (starved list) instead of failing. bridge.zig: one thread (the loop) still owns the inode/handle/qid tables and serves everything that touches them. READ and WRITE are resolved to their fid on the loop and handed to transfer workers (up to 31 per bridge, started on demand), which make the 9P calls on their own Caller and reply themselves. FUSE_INTERRUPT for a worker's request: still queued -> EINTR on the spot; in flight -> its unique down the worker's pipe -> Tflush of exactly that tag. Fids are clunked only on RELEASE. mntgen mounts get the same pool (their dispatcher routes interrupts to it); the mount interrupt pipe moved into Bridge. main.zig attaches through a Caller. Tests: two multiplexing tests in nine.zig (a parked read holds up only its caller and its interrupt flushes exactly its tag; with every tag parked a call waits for a tag), and a serve()-level test driving a fake /dev/fuse (a parked READ holds up neither READs nor GETATTR; INTERRUPT -> one Tflush for the parked tag -> EINTR; RELEASE). Also de-flaked the pre-existing 'short read' test (it raced its own server reply under load). Measured (own 9ns mount on the live pardes socket, read-only): with log parked, cat status 4498 ms before, 7 ms after. Tag window: client.zig gains ClientWith(n) (Client = ClientWith(16) as before; request/result types hoisted so all instantiations share them). 9ns uses ClientWith(32): 32 is fs.zig's default slot_capacity, so one 9ns mount can never have more parked on a cloud9 fs server than it parks, and never meets its "Resource temporarily unavailable" refusal. fs.zig is unchanged (its default is also the ESP32 board's, held to 24 KiB by its budget tests). Full window: the loop keeps its tag (metadata unaffected); the 32nd READ/WRITE waits in the pool queue (blocks, interruptible, never EAGAIN/EIO). More tests (bridge.zig, serve() over a fake /dev/fuse): one open is one fid (two opens of an inode read through distinct fids, concurrently, one of them parked); FLUSH on a handle with a parked read clunks nothing and the read later completes on that fid; only RELEASE clunks; a flushed READ whose reply beats the Rflush returns the data, not EINTR.
* fs, serve: set an engine up in place, so a large fid table costs only the ↵Gabriel Schneider2026-09-25
| | | | | | | | | | | | | | | fids used A kernel mount (9ns) holds a fid for every inode the kernel caches, so a server that wants `ls -l` of a directory of thousands of files to work needs a fid table of tens of thousands. Server.initIn sets an engine up in place and, with fid_index, never writes a fid slot at or past high_water; the walks over the table (references, reset, orphan) stop there. Runner.init sets each connection's small fields one by one and leaves the engine to start(), so connection slots nobody uses are never written. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
* fs: a parked job whose fid was clunked is answered, not asked againGabriel Schneider2026-09-22
| | | | | | | | | | | | A client that gives up on a parked open sends Tclunk for its fid without a Tflush; the fid goes, the parked job stays. On retry the job went back to the backend, which did the work -- opened a handle, made an object -- and the reply then found no fid and dropped it, handle and all. Now the retry looks for the fid first and answers "fid unknown" without asking. Found by an adversarial review of pardes's use of the engine. Co-Authored-By: Claude Fable 5.1 <[email protected]>
* fs: let open, truncate, clunk and remove park on again, not only reads and ↵Gabriel Schneider2026-09-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | writes A backend that is not ready for a request answers `again` and the engine parks the request, so the connection goes on answering everything else and a retry asks the parked request later. That only worked for a read, readdir or write; every other op answering `again` failed with EAGAIN on the spot. pardes needs the rest. Its 9P is answered on the connection's task while the editor's own thread may be out in a syscall in the middle of a step, and in that window a request that would change a pane -- an open of /pane/new, a truncating open or wstat, a remove -- has to wait, not fail, and has to wait without holding the connection up, because the editor's own request may be the next frame on that very connection (it is, when the syscall goes through a mount of the editor's own tree). Parking is exactly that. A parked open, wstat, clunk or remove goes back into the job slot on retry and its reply then goes through `jobReply` like any other, which is why the slot keeps only what an open needs (`omode`, `step`); a wstat parks only as the truncation to zero a Linux client sends for O_TRUNC, and a clunk parks before it lets its fid go, since a release that was never paid still owns its handle. A walk, attach, stat, create or renaming wstat keeps names in the input frame that parking lets go of, so those still answer EAGAIN. A parked job retried and parked again sits the round out like a retried read does -- without that the first version of this looped forever in `retry`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
* 9ns --mntgen: registry subdirectories are mount points tooGabriel Schneider2026-09-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A registry entry that is a directory is now served the way the root is: a synthetic directory listing the real one, dialing the sockets inside it on walk and recursing into further directories, to max_synth_depth (8) levels across max_synth_dirs (64) synthetic nodes. That is the plan9port mntgen shape and the layout zmx now posts under, so a live session reads at /mnt/9p/zmx/<name>. Before this a directory in the registry was dialed like a socket and answered EIO for good. post gains the two entry points the traversal needs: postedDir (the registry scan, against any directory) and dialPath (a dial by composed path, no name validation). Hardening, each from an attack that broke the code: - BATCH_FORGET carries entries for many owners and puts 0 in the header nodeid, so routing it by the header dropped all of them: 32 of 64 synthetic slots leaked in one close burst and the subdirectories that held them answered EIO forever. distributeForgets unpacks the body and hands each entry to its owner. - probe() and connectBlocking() copied a caller's path into the kernel address with no bound: a path past sun_path overran the 110-byte stack sockaddr (a panic in Debug, silent corruption in ReleaseFast). Both refuse it now, probe as `.live` so a claim never deletes what it could not inspect. - That bound then caught 9proc's own listener, which handed probe() the whole 108-byte sun_path array instead of the path inside it. The probe reads `.live` for anything it cannot ask about, so every stale socket became AlreadyListening and no server could ever take a dead predecessor's name back. It passes the path now. Suites: 87/87 root (+7 post/serve attack regressions), 48/48 9ns, 51+88 9ns integration (+4 traversal and slot-recycling checks), 213/0 9ns adversarial, 60/60 9proc plus its adversarial suites with a new stale-socket takeover check, freestanding green.
* post registry + 9ns --mntgen: the /srv translationGabriel Schneider2026-09-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cloud9.post: servers post their socket under a name in $XDG_RUNTIME_DIR/9p (post/unpost, posted, dial, Watch) and serve.Runner.listenPosted posts a server by name, unposting on stop. Names are budget-checked against the 108-byte socket path; a claim binds+listens at a private temp path and takes the name with atomic renames under flock (RENAME_NOREPLACE for free names, RENAME_EXCHANGE grab-verify-commit for stale ones): the registry path is never unlinked by a claim, live names refuse with AlreadyPosted, foreign files with NotSocket, and unpost removes only the caller's inode-matched entry. Watch surfaces inotify overflow and a replaced registry dir. 9ns --mntgen [--mount DIR] -- PROGRAM: one FUSE mount at /mnt/9p whose synthetic root lists the posted registry (no connection made); a walk into an unmounted name dials it and runs the existing bridge dispatch in a per-server worker thread, routed by mount index in the node id's top bits (ordinals never reused, cap 4096); a dead server answers EIO on its subtree and is re-dialed on the next walk. The dial watches stop_fd through Tversion (connectWatched). All existing 9ns forms are unchanged. 9proc's unix listener no longer blind-unlinks its path: a foreign non-socket is refused (Occupied), a live server is refused (AlreadyListening), only a refused socket is cleared, and stop() unlinks only the listener's own inode-matched socket. Hardened by adversarial review (GLM 5.3 x2 + DeepSeek V4.1 Flash, all high-thinking): double-bind races on one name (0 in 180k rounds), foreign-file TOCTOU deletions (0 in 4M flips), a 255-byte-name listing panic, inotify queue overflow silently dropped, listenPosted silently overwriting, dial-time Tversion hangs wedging the dispatcher, --debug silently ignored in mntgen, and xattr/statx probes answering EPERM on the synthetic root (broke `ls -l /mnt/9p`). Tests: root 80/80, 9ns 47/47, 9proc 60/60, integration 88/88 + mntgen 37/37, adversarial 213/0, freestanding riscv32 gate green.
* Add cloud9.serve: an std.Io runner around the file-server engineGabriel Schneider2026-09-20
| | | | | | | | | | | | Runner(Backend, Options, Limits) listens on Unix or TCP, runs a reader and a serve task per connection in one Io.Group, pushes frames into an fs.Server, and lets the backend answer now or later from any task or thread (reply, flush, wake); Tflush, greet timeout, connection limit, close and stop with cancellation are covered by tests over real sockets. The engine and the backend contract stay Io-free, so the push/step mode for freestanding targets is unchanged. Documented as the two ways to drive the engine. Co-Authored-By: Claude Fable 5.1 <[email protected]>
* 9proc core becomes a backend of cloud9.fs; engine gains optional featuresGabriel Schneider2026-09-20
| | | | | | | | | | | | | | | | 9proc's own fid table, walk loop and dir-read engine are replaced by cloud9.fs.Server; the tree (static, vars, providers) is served through the engine's Req/Reply contract with node ids that keep the old qid scheme. Providers may answer later by returning error.Again (parked in the engine, retried each step, Tflush -> EINTR); no new files are exposed. Engine (backward compatible, all opt-in via Backend.features / Options): create, remove, wstat, reference accounting for backends that count handles, a salted fid index, name_capacity 0 (names from getattr), Reply.ename for backend-chosen error text, Attr.path/version/atime. Engine-level error strings and the 217-byte msize floor now apply to 9proc; tests updated accordingly. Co-Authored-By: Claude Fable 5.1 <[email protected]>
* Add the file-server engine: cloud9.fs.Server(Backend, Options)Gabriel Schneider2026-09-20
| | | | | | | | | | | | | The asynchronous 9P file-server engine from the Pardes editor moves into the library: fid table, walks, directory cursors, a job/slot model where backend replies arrive later by tag (status again = parked), Tflush cancellation and orphaned fids on hangup. Allocation-free, no OS calls, no std.Io; comptime Options (fid, slot, park data, name and user capacities) replace the editor's constants. Backend contract types (Req, Reply/ReplyWith, Op, Status, Attr, E, error strings) live here. 29 engine tests plus the client tests that sat beside it in Pardes. Co-Authored-By: Claude Fable 5.1 <[email protected]>
* Add reusable HTTP transport, serial gateway, and WASM file browserGabriel Schneider2026-09-16
|
* Implement base 9P2000 sessions, shared transports, and conformance probesGabriel Schneider2026-09-14