@ai-ecoverse/slicc-kernel 1.185.0 → 1.186.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -1
- package/dist/async-process.js +1 -1
- package/dist/cloudflare-sources.js +1 -1
- package/dist/cloudflare.js +200 -74
- package/dist/cloudflare.js.map +3 -3
- package/dist/driver-worker.js +1 -1
- package/dist/driver-worker.js.map +2 -2
- package/dist/driver.js +1 -1
- package/dist/driver.js.map +2 -2
- package/dist/kernel-worker.js +19 -10
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-driver-worker.js +1 -1
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +19 -10
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +1 -1
- package/dist/types/cloudflare/computer-driver.d.ts +6 -0
- package/dist/types/cloudflare/computer.d.ts +3 -2
- package/dist/types/cloudflare.d.ts +6 -1
- package/dist/types/mount/protocol.d.ts +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -304,6 +304,7 @@ The Worker needs a Worker Loader binding (`worker_loaders`) and a SQLite-backed
|
|
|
304
304
|
| `root`, `meta`, `ranged` | `memoryRoot()` | a root of your own in place of `sql` |
|
|
305
305
|
| `clock` | none | called before every timed wait; pass a call into the Durable Object's own namespace, as above. Without it, `sleep` and timeouts can end early |
|
|
306
306
|
| `isolates` | `{ max: 8, waitMs: 10000, memory: 64 MiB, perInstance: 8 MiB }` | how many Dynamic Workers run at once, how long a spawn waits for one, and the memory budget per Dynamic Worker |
|
|
307
|
+
| `commands` | none | `{ append }`: more command roots, as for `createKernel`; one can be a mount (see [A file system the Durable Object serves](#a-file-system-the-durable-object-serves)) |
|
|
307
308
|
| `network` | none | `{ transport, tlsEngine, uplink, doh }`: the transport programs reach the outside world through, and the TLS engine for their `https://` requests (see [The network](#the-network-in-a-durable-object)) |
|
|
308
309
|
|
|
309
310
|
**How it works.** Workers has no `Worker`, refuses `Atomics.wait`, and does not share memory between isolates, so a process cannot block the way it does in a page. Here a process is a wasm instance in a Dynamic Worker, parked with JSPI (`WebAssembly.Suspending`) while its system call is answered by the Durable Object over Workers RPC.
|
|
@@ -353,6 +354,30 @@ await kernel.run(['curl', '-sS', 'https://example.com/']);
|
|
|
353
354
|
- **How `compiledTlsEngine(factory, module)` works:** the package's glue only instantiates from bytes. So while the engine loads, `WebAssembly.instantiate` answers that one call, which it knows by the bytes the glue was given, with an instance of `module`. Every other call goes to the real function, and the real function is back in place once the engine has loaded or failed.
|
|
354
355
|
- **The option is `() => Promise<TlsEngineModule>`**, asked at the first `CONNECT` and once per kernel, so any other way of loading the engine works too.
|
|
355
356
|
|
|
357
|
+
#### A file system the Durable Object serves
|
|
358
|
+
|
|
359
|
+
A package driver runs in a worker of its own, which a Durable Object does not have. `inProcessMount(spec, driver)` mounts a file system whose handlers run in the Durable Object itself, with the same [handlers and capabilities](#mounts) as a package driver:
|
|
360
|
+
|
|
361
|
+
```js
|
|
362
|
+
import { fsError, inProcessMount } from '@ai-ecoverse/slicc-kernel/cloudflare';
|
|
363
|
+
|
|
364
|
+
const kernel = await createCloudflareKernel({
|
|
365
|
+
loader: env.LOADER,
|
|
366
|
+
commands: { append: ['/image/node_modules'] },
|
|
367
|
+
});
|
|
368
|
+
await kernel.mount(
|
|
369
|
+
inProcessMount(
|
|
370
|
+
{ type: 'image', source: 'tools', target: '/image', options: { ro: '' } },
|
|
371
|
+
{ handlers, capabilities: { readonly: true, ranges: true } }
|
|
372
|
+
)
|
|
373
|
+
);
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
- **Programs on a mount:** a mount under an appended command root (`commands.append`) provides commands as `/node_modules` does, so a kernel can run programs it never copied into its own root: from R2, from the Worker's own modules, or from memory. The kernel reads a program's file when it first runs it.
|
|
377
|
+
- **The mount point** has to exist: `attachKernel(await kernel.connect()).fs.mkdir(target)` makes it, with its parents.
|
|
378
|
+
- **`driver`** is `{ handlers, capabilities?, served? }`. `served` is called once with `{ invalidate(paths) }`, for a driver whose files change outside the kernel.
|
|
379
|
+
- **Limits:** the handlers share the Durable Object's thread with the kernel, so a slow handler holds up every process. A handler that does not answer within 30 s fails its call with `EIO`, as any driver's does.
|
|
380
|
+
|
|
356
381
|
Measured on a deployed Worker, from a client about 40 ms away, next to local `wrangler dev`:
|
|
357
382
|
|
|
358
383
|
| | `wrangler dev` | deployed |
|
|
@@ -385,6 +410,7 @@ const run = await workspace.runtime.exec('ls -la /workspace | wc -l', { backend:
|
|
|
385
410
|
|
|
386
411
|
Output is streamed, `killExec` signals the whole process group, and a timeout sends `SIGTERM` and then `SIGKILL`. `getExec` re-attaches to a run for 5 minutes after it ended (`retentionMs`), as long as the Durable Object has stayed in memory since; the record is dropped at the first call after that time, with no timer. The kernel's own root (`/root`, `/etc`, `/tmp`, `/node_modules`) lives in the same SQLite database as the Workspace, in its own tables.
|
|
387
412
|
- **What the Workspace store does not have:** owners (files show as uid 0 and `chown` fails), `utimes` (`touch -d` does nothing), hard links, and ranged writes (a write that seeks backwards rewrites the file).
|
|
413
|
+
- **Read-only mounts:** a Workspace mount with `mode: 'read-only'` (an `EagerMount` in the Workspace's `mounts`) is read-only in the kernel too, as a read-only file system is on Linux. A change at or below its root fails where it starts, with `EROFS` (`Read-only file system`): a write open (`>`, `>>`, `exec 3<>`, `dd`), the creation of a file, `utimensat` (`touch`), a truncate, `mkdir`, `rmdir`, `unlink`, a rename out of it or into it, `chmod`, `ln` and `ln -s`, and a write through a symlink into it. Its files `stat` as read-only, so `access(W_OK)` (`test -w`) answers `EROFS`. Reads work as before. `sliccBackend` reads the roots from the Workspace's database (`host.db`) whenever it checks, so a new Workspace on the same storage brings its own. A driver of your own reads them from `workspaceDriver(fs, { db })`, or `fs.db` without it, or takes them as `readOnly`, a list of roots or a function that returns one. A directory above such a root (the mount point itself, `/workspace`) stays writable, and a `mkdir` of it is `EEXIST`.
|
|
388
414
|
- **Write-behind:** a file is committed to the Workspace up to 1 s after it is closed, and always before the run's exit event. `workspace.fs` can see a file that late during a run, and an error in a deferred commit is not reported to the program that wrote the file. `sliccBackend({ writeBehind: false })` commits at close.
|
|
389
415
|
- **Deletes are slow:** each removed file is one durable commit, about 30 ms on a deployed Worker.
|
|
390
416
|
|
|
@@ -1030,7 +1056,7 @@ Directories are renamed with `FileSystemHandle.move()` where available, else by
|
|
|
1030
1056
|
- An optional `mount({ source, options })` handler validates the source.
|
|
1031
1057
|
- Errors carry a POSIX `code`.
|
|
1032
1058
|
- `@ai-ecoverse/slicc-kernel/driver` exports the types and `fsError`.
|
|
1033
|
-
- **Capabilities:** `readonly`, `symlinks`, `links` (hard links: the driver answers `link(from, to)`, reports `nlink` in its attributes, and gives every attribute a stable `ino`, the same for all names of a file; a mount whose driver offers `links` but answers an attribute without `ino` loses them: `link` is `EPERM` there and `st_nlink` is 1), `chmod`, `owners`, `ranges`, `maxIo` (the largest read or write per message), `maxFile`, `listingStats`, `sessions`, `linkTimes`, and `attrTtl`/`entryTtl` (in ms, default 1000). `sessions` promises that a handle opened for writing keeps its writes to itself until it is released, so the kernel keeps one open per file being written instead of one per write (the `fsa` driver has it). `linkTimes` promises that `setattr` with `mtime` on a symlink sets the link's own time. Without it, setting a link's own times (`touch -h`, `utimensat` with `AT_SYMLINK_NOFOLLOW`) fails with `EOPNOTSUPP` and never reaches the target. tmpfs has it; hostfs does not. Setting times through a link follows it in the kernel, so `setattr` gets the target. `ranges` (driver protocol 1.1) promises that a write lands in the file at once, with no copy of the whole file on `open` or `release`, and that `setattr` takes `size`. `owners` (driver protocol 1.2) promises that the driver stores owners: its attributes carry `uid` and `gid`, `open` with `create`, `mkdir` and `symlink` may carry the new path's `uid`, `gid` and `mode` (the `owner` of the open flags, the second or third handler argument), a new path without them takes its directory's owner, and `setattr` takes `uid` and `gid`. tmpfs has it. `fifos` (driver protocol 1.3) promises that the driver answers `mkfifo(path, owner)` with a FIFO node: its attributes say `kind: 'fifo'`, `readdir` lists it so, and an `open` of it is `ENXIO`, since the kernel, not the driver, carries a FIFO's data ([#907](https://github.com/ai-ecoverse/slicc-kernel/issues/907)). tmpfs has it, so `mkfifo` works on `/dev/shm` and on a tmpfs `/tmp`; on hostfs, `fsa` and media mounts it's still `EPERM`.
|
|
1059
|
+
- **Capabilities:** `readonly`, `symlinks`, `links` (hard links: the driver answers `link(from, to)`, reports `nlink` in its attributes, and gives every attribute a stable `ino`, the same for all names of a file; a mount whose driver offers `links` but answers an attribute without `ino` loses them: `link` is `EPERM` there and `st_nlink` is 1), `chmod`, `owners`, `ranges`, `maxIo` (the largest read or write per message), `maxFile`, `listingStats`, `sessions`, `linkTimes`, and `attrTtl`/`entryTtl` (in ms, default 1000). `sessions` promises that a handle opened for writing keeps its writes to itself until it is released, so the kernel keeps one open per file being written instead of one per write (the `fsa` driver has it). `linkTimes` promises that `setattr` with `mtime` on a symlink sets the link's own time. Without it, setting a link's own times (`touch -h`, `utimensat` with `AT_SYMLINK_NOFOLLOW`) fails with `EOPNOTSUPP` and never reaches the target. tmpfs has it; hostfs does not. Setting times through a link follows it in the kernel, so `setattr` gets the target. `ranges` (driver protocol 1.1) promises that a write lands in the file at once, with no copy of the whole file on `open` or `release`, and that `setattr` takes `size`. `owners` (driver protocol 1.2) promises that the driver stores owners: its attributes carry `uid` and `gid`, `open` with `create`, `mkdir` and `symlink` may carry the new path's `uid`, `gid` and `mode` (the `owner` of the open flags, the second or third handler argument), a new path without them takes its directory's owner, and `setattr` takes `uid` and `gid`. tmpfs has it. `fifos` (driver protocol 1.3) promises that the driver answers `mkfifo(path, owner)` with a FIFO node: its attributes say `kind: 'fifo'`, `readdir` lists it so, and an `open` of it is `ENXIO`, since the kernel, not the driver, carries a FIFO's data ([#907](https://github.com/ai-ecoverse/slicc-kernel/issues/907)). tmpfs has it, so `mkfifo` works on `/dev/shm` and on a tmpfs `/tmp`; on hostfs, `fsa` and media mounts it's still `EPERM`. An attribute may also carry `readonly: true` (driver protocol 1.4): that path is read-only on a mount that isn't, so `stat` reports it, an open for writing or creating there is `EROFS` in the kernel, and so is a hard link into a directory with it; the driver refuses its other changes itself. The Workspace driver marks a Workspace's read-only mounts so.
|
|
1034
1060
|
- **Caching:** the kernel caches attributes and listings for those TTLs, and a driver can push `invalidate` for changes made outside.
|
|
1035
1061
|
- **File contents:** on a mount with `ranges`, as `tmpfs` is, and on the root file system when it is in OPFS (in a browser with sync access handles) or an in-memory root, a program reads and writes a file in 64 KiB pages: reads come from the driver 1 MiB at a time, and changed pages go back in 1 MiB runs once 8 MiB have changed, at `fsync`, and when the file is closed (from the kernel's own descriptors also 250 ms after a write). A file of any size the mount can hold works, with memory to spare for about one more copy of it. In OPFS a write opens a sync access handle for just that write. An `fsa` mount (a picked folder) has no sync access handles, and Chrome copies the whole file into a swap file for every writable stream, so it writes through one stream per open file: the first write back opens it, later runs go into it at their offsets, and it is committed, one copy of the file, when the last process writing the file closes it (or exits), before another process reads what was written, and before a rename, unlink or unmount. Until then other processes see the new size but read the old bytes outside what was written. Elsewhere (`hostfs` with an older proxy, and a root outside OPFS), file contents are read whole when a program opens a file and written back when it closes it. Before a program's next call into the kernel (any wait, read of a pipe or terminal, sleep or spawn), its changed pages also go back, so other processes and the embedder see a write as soon as the writer does anything but compute: a daemon's pidfile, a log another process follows. On a whole-file mount that holds only for files of up to 64 KiB; a larger one goes back at close, fsync and exit, as before. Beyond that, both give close-to-open consistency, as NFS has. A write-back that can't reach the folder (a `hostfs` port or proxy gone, a medium ejected) keeps the pages and isn't dropped quietly ([#1062](https://github.com/ai-ecoverse/slicc-kernel/issues/1062)): the next `fsync` or close of the file fails with the error (`ENOMEDIUM`, `ENODEV` for WASI), and so does every later write or truncate on it, each of which first retries the write-back, until one succeeds. When a mount's folder goes away, every file the kernel buffers for it is checked at its next write (one with unwritten pages retries them; one already written back asks the folder once, and fails while it's unreachable), so `for …; do echo …; done > /mnt/h/f` stops reporting success as soon as the folder is gone. A program's own whole-file buffer (`hostfs` without `ranges`, one process, no fork) still reports only at close or `fsync`, and a shell ignores a redirection's close error, as on Linux. A process that ends without closing its files keeps what it wrote: on exit, on a trap, and when a signal kills it. For a killed WASI program, the kernel lets its worker write its changed pages back before `waitpid` reports the death. The only exception is a worker that makes no call into the kernel for 2 seconds after the signal; it is stopped without that write-back.
|
|
1036
1062
|
- **Exclusive create across tabs** ([#912](https://github.com/ai-ecoverse/slicc-kernel/issues/912)): two kernels on one OPFS root (two tabs, or a tab and a worker page) agree on `O_CREAT|O_EXCL` and `set -C`: exactly one wins a name. While another kernel on the root is present, the create runs under a Web Lock for its path and checks the OPFS entry itself. A kernel alone on its root takes no lock. Each kernel holds an alive Web Lock, granted before it first looks for peers. A kernel that finds peers waits for their answer (at most 500 ms) before its first exclusive create, and a kernel answers a newcomer only once its unlocked creates are done. So of two kernels that boot at the same moment, the later one to look sees the other, and no unlocked create overlaps a locked one.
|
package/dist/async-process.js
CHANGED
|
@@ -1337,7 +1337,7 @@ function createParentRefreshCount() {
|
|
|
1337
1337
|
}
|
|
1338
1338
|
|
|
1339
1339
|
// src/version.ts
|
|
1340
|
-
var KERNEL_VERSION = true ? "1.
|
|
1340
|
+
var KERNEL_VERSION = true ? "1.186.1" : "0.0.0-dev";
|
|
1341
1341
|
var OS_RELEASE = "6.0.0-slicc";
|
|
1342
1342
|
function procVersion() {
|
|
1343
1343
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|