@ai-ecoverse/slicc-kernel 1.188.1 → 1.189.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 +7 -6
- package/dist/async-process.js +1 -1
- package/dist/cloudflare-sources.js +1 -1
- package/dist/cloudflare.js +659 -469
- package/dist/cloudflare.js.map +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +4786 -4672
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +563 -446
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/types/cloudflare/images.d.ts +17 -5
- package/dist/types/cloudflare/sqlite-store.d.ts +2 -0
- package/dist/types/kernel/net/dns-stub.d.ts +6 -3
- package/dist/types/kernel/net/resolver.d.ts +6 -1
- package/dist/types/kernel/net/uplink.d.ts +1 -1
- package/dist/types/launcher.d.ts +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -316,7 +316,8 @@ The Worker needs a Worker Loader binding (`worker_loaders`) and a SQLite-backed
|
|
|
316
316
|
- **Threads take turns.** They never run at the same time, so threads don't make a program faster, and a thread that computes without a kernel call holds up the others. A thread waits on a futex only through wasix-libc's `futex_wait`: a program whose own code blocks with wasm's `memory.atomic.wait32` instruction (Rust's std, so tokio's runtime and a `std::thread` that parks) traps there with `Atomics.wait cannot be called in this context` (status 134); on Node's `blocking: 'async'`, where that instruction is allowed, it holds up the whole process for the time it waits. A thread costs no Dynamic Worker and no memory of its own beyond its instance and stack: its memory is the process's, counted once under `isolates.memory`. At most 64 threads run in a process, as on the page (`SLICC_WASM_THREADS`).
|
|
317
317
|
- **Not supported:** `dlopen` and anything else that compiles wasm at run time, JS programs (`"abi": "js"`), and an imports module without `createAsyncImports` (126, `the imports module exports no createAsyncImports function, which the async process host calls`). Each fails with an errno or a message, never a hang.
|
|
318
318
|
- **Imports modules:** a WASI command's [imports module](#program-imports) is one of its Dynamic Worker's modules, beside the wasm, so it is loaded without `import()` and without the embedder. The Dynamic Worker is the program's and that module's: a command whose module differs (another package, or the file changed) gets a Dynamic Worker of its own. The module is evaluated when the Dynamic Worker starts and shared by the processes in it, so it must be one self-contained file (no `import`), and state at its top level is seen by all of them. Its HTTP and its commands go through the process's system calls, so through the kernel's transport; a Dynamic Worker has no network of its own (`globalOutbound: null`). The kernel calls `createAsyncImports(ctx)`, not `createImports`: see [Program imports](#program-imports).
|
|
319
|
-
- **Program size:** a Dynamic Worker's code (the program's wasm, its imports module, and the 0.5 MB process host) must be under 64 MiB. A larger program fails with status 70 and `Dynamic Worker code size (78982007 bytes) exceeds the maximum allowed size of 67108864 bytes.`, as `gh.wasm` of `@ai-ecoverse/wasi-gh` 2.102.0-2 (78 MB) does, in `wrangler dev` and deployed alike.
|
|
319
|
+
- **Program size:** a Dynamic Worker's code (the program's wasm, its imports module, and the 0.5 MB process host) must be under 64 MiB. A larger program fails with status 70 and `Dynamic Worker code size (78982007 bytes) exceeds the maximum allowed size of 67108864 bytes.`, as `gh.wasm` of `@ai-ecoverse/wasi-gh` 2.102.0-2 (78 MB) does, in `wrangler dev` and deployed alike.
|
|
320
|
+
- **What the Durable Object keeps of a program:** not its wasm. To start a process, the kernel reads the whole wasm once to compile it, and `kernel.images` then keeps only the program's digest, its initial memory and size, and the paths it was read from (`kernel.images.held`, the bytes it keeps, stays 0). The bytes are needed again only when the Worker Loader starts the program's Dynamic Worker from scratch: the first process of a program, one that spills into another Dynamic Worker, or one after Cloudflare evicted it. That cold start reads the program again through the kernel's file system, from where it was compiled (a mount, the SQLite root, `/node_modules`), and checks it against the digest, so it costs one more read of the program (one more R2 `get` behind a mount whose driver doesn't cache it); a warm start reads nothing. A program whose file is gone by then fails to start with status 127 and `ENOENT: <path> is gone since the kernel compiled it`, and one whose file changed with 126 and `ESTALE: <path> changed since the kernel compiled it`; the next spawn compiles the file again, under a new Dynamic Worker. While a program is read, the object holds it once, plus one chunk of the mount's `maxIo` (8 MiB) while a mount's reads are gathered, plus whatever copy the driver keeps, and only until the Dynamic Worker has its code. Measured on a deployed Durable Object with 128 MB: eight programs of 20 MiB, one after another, all run; before, the object kept every one, and the sixth ended the object (Cloudflare error 1101), which came back cold with none of them. What the object does keep for the kernel's life is small: the TLS engine (320 KB of wasm, compiled with the Worker, and one instance with 4 MiB of memory to start), the process host's source (0.5 MB), and the imports module of each running process. A fork's memory snapshot stays in the parent's Dynamic Worker, and the object only passes it to the child in pieces.
|
|
320
321
|
- **Memory:** a Dynamic Worker has 128 MB. A program whose wasm memory starts above that cannot run (`python.wasm` declares 160 MiB). Processes of one program share a Dynamic Worker up to the budget and then spill into another; at most 8 Dynamic Workers run at once, and a spawn beyond that waits, then fails with `EAGAIN`, which bash retries. A Dynamic Worker that outgrows its limit is ended by Cloudflare: its processes exit with status 70 and the kernel carries on.
|
|
321
322
|
- **CPU and signals:** a process that computes for 30 s without a system call is ended by Cloudflare. Nothing can interrupt it sooner: a signal, `SIGKILL` included, is seen at the process's next system call.
|
|
322
323
|
- **Clocks:** inside a Workers request the clock stands still while code computes. `time` and CPU accounting are wrong, and a timed wait that follows a long computation in the same process can end early by that computation's length.
|
|
@@ -353,7 +354,7 @@ 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
|
|
|
356
|
-
**DNS:** the kernel's [DNS stub](#dns) answers on `127.0.0.53` here too, over UDP and TCP, and `network: { doh }` names the DNS over HTTPS endpoint it forwards other names to, through the transport's `fetch`. With `network: { transport: fetchTransport(), doh: 'https://cloudflare-dns.com/dns-query' }
|
|
357
|
+
**DNS:** the kernel's [DNS stub](#dns) answers on `127.0.0.53` here too, over UDP and TCP, and `network: { doh }` names the DNS over HTTPS endpoint it forwards other names to, through the transport's `fetch`. With `network: { transport: fetchTransport(), doh: 'https://cloudflare-dns.com/dns-query' }` (and an exit [uplink](#uplink) without names of its own, if programs are to connect to what they resolve), BIND's `dig example.com`, `host` and `nslookup` need no server argument: they read `/etc/resolv.conf`, ask the stub over UDP, and ask again over TCP when an answer comes back truncated. Without `doh` (and without an [uplink](#uplink) with a `nameserver`), a name the kernel doesn't know itself is `SERVFAIL`.
|
|
357
358
|
|
|
358
359
|
#### A file system the Durable Object serves
|
|
359
360
|
|
|
@@ -858,8 +859,8 @@ WASIX programs get `AF_INET`/`AF_INET6` `SOCK_DGRAM` sockets, and `AF_UNIX` ones
|
|
|
858
859
|
|
|
859
860
|
The kernel answers DNS itself, so DNS clients (BIND's `dig`, `host` and `nslookup`) see the same names as `getaddrinfo` (#1244).
|
|
860
861
|
- **Where it listens:** UDP and TCP port 53 on the kernel's loopback; `/etc/resolv.conf` names `127.0.0.53`, as systemd-resolved does, but any loopback address reaches it. TCP takes several queries on one connection (2-byte length framing), at most 64 connections at once, each closed after 10 s without a query or when an answer can't be written within 10 s (a client that stops reading). Over UDP at most 64 questions are answered at once; while that many wait (on the forwarder, say), more are dropped, as by a full receive queue. Port 53 is the kernel's, as the proxy's and CDP's ports are: a program's `bind` to it, root's included, is `EADDRINUSE` on UDP and TCP, so no program can answer other users' questions, and `kernel.dial` refuses it.
|
|
861
|
-
- **What it answers itself,** from the [kernel's resolver](#node-name): `A` and `AAAA` for `/etc/hosts` names, the node name, `localhost` and `*.localhost`, `host.slicc.internal`, and the [uplink](#uplink)'s names (a tray's `<device>.slicc.internal`, MagicDNS); `PTR` from `/etc/hosts` and the built-in entries (`127.0.0.0/8` is `localhost`). TTLs are 30 s. Answers for `localhost` and `slicc.internal` are authoritative (`aa`), and a name there that nothing knows is `NXDOMAIN`. Other types for a name the kernel knows (`MX` for `host.slicc.internal`) get an empty answer.
|
|
862
|
-
- **Everything else** (other names, other types, other classes, address literals, an `AAAA` the uplink has no answer to, a name whose uplink lookup failed) goes to a forwarder, and
|
|
862
|
+
- **What it answers itself,** from the [kernel's resolver](#node-name): `A` and `AAAA` for `/etc/hosts` names, the node name, `localhost` and `*.localhost`, `host.slicc.internal`, and the [uplink](#uplink)'s names, those its `resolve` answers (a tray's `<device>.slicc.internal`, MagicDNS); `PTR` from `/etc/hosts` and the built-in entries (`127.0.0.0/8` is `localhost`). TTLs are 30 s. Answers for `localhost` and `slicc.internal` are authoritative (`aa`), and a name there that nothing knows is `NXDOMAIN`. Other types for a name the kernel knows (`MX` for `host.slicc.internal`) get an empty answer.
|
|
863
|
+
- **Everything else** (other names, other types, other classes, address literals, an `AAAA` the uplink has no answer to, a name whose uplink lookup failed) goes to a forwarder, unchanged: its CNAME chain, TTLs and authority section reach the client as the forwarder sent them. The stub never answers from what the kernel's resolver learned from that forwarder. There is no forwarder by default: those questions are `SERVFAIL`, and nothing leaves the kernel. An [uplink](#uplink) whose `nameserver` names its DNS server (an address it routes, such as Tailscale's `100.100.100.100`) gets them over its own TCP, length-framed as RFC 1035 has it, so they go where that uplink and its exit send them. Without one, `network: { doh }` names a DNS over HTTPS endpoint (RFC 8484, `POST`, id 0) that the [transport](#network) is asked; `doh: false` or none is no forwarder. A forwarder's answer must repeat the question (name, type and class) or it is `SERVFAIL`, as are a failed connection, an HTTP error or a non-`application/dns-message` answer, and no answer within 5 s. The answer goes back as the forwarder gave it, with the query's id. Over UDP, an answer longer than 512 bytes (or the query's EDNS size, at most 4096) comes back truncated (`tc`, no records), so the client asks again over TCP.
|
|
863
864
|
- **What a forwarder sees:** the question's bytes as the program wrote them (id set to 0), EDNS options included, so a program can carry data to the forwarder in DNS names, as anywhere DNS is resolved. That gives no process more than it has: every process may already use the proxy and the transport, and connect to what the uplink routes; the kernel has no per-user network policy that the stub would bypass.
|
|
864
865
|
- **`/etc/resolv.conf`:** at boot, the kernel writes `nameserver 127.0.0.53` and `options edns0` there when there is no such file (a symlink counts as one), owned by root with mode `0644`. A file root wrote stays, and so does none at all when `/etc/resolv.conf` is a [protected path](#protected-paths). One that root removes comes back at the next boot. It has no `search` line, because musl's `getaddrinfo` (WASIX programs) would then try every short name in that domain first.
|
|
865
866
|
|
|
@@ -888,7 +889,7 @@ Until this, `TZ` was unset, so `date` printed UTC while cron read schedules in t
|
|
|
888
889
|
- `traits`: `{ tcp: true, udp, ipv6 }`. Without `ipv6: true`, the kernel asks only for, and keeps only, IPv4 addresses. With `udp: true` and a `udp` function, routed datagrams go through it.
|
|
889
890
|
- `routes`: the first route table, `{ prefixes, exit }`, which `kernel.setRoutes` replaces when it changes. The kernel matches it itself, so a destination outside it costs no round trip.
|
|
890
891
|
- `nameserver` (optional): an address the uplink routes where a DNS server answers on TCP port 53 (Tailscale: `100.100.100.100`). The kernel's [DNS](#dns) stub forwards the questions it can't answer there.
|
|
891
|
-
- `resolve(name, family, signal)
|
|
892
|
+
- `resolve(name, family, signal)` (optional): resolves with the name's addresses, as a list or as `{ addresses, ttl }` (seconds). `[]` means the name is not the uplink's, and an uplink without `resolve` has no names of its own. `family` is `4`, `6` or `0` (either), and `signal` aborts when the kernel stops waiting. Answer only the uplink's own names (a tailnet's, MagicDNS): the [DNS](#dns) stub answers a name the uplink resolves itself, with the kernel's TTL and no CNAME chain, and forwards every other one, so an exit uplink that resolved every name would hide the forwarder's answers from `dig` and `host`.
|
|
892
893
|
- `dial({ network: 'tcp', host, port, signal })`: opens a TCP connection and resolves with `{ localAddr, remoteAddr, read(), write(bytes), closeWrite(), close() }`.
|
|
893
894
|
- `read()` resolves with the next bytes, or `null` at the end.
|
|
894
895
|
- `write` resolves with how many bytes it took.
|
|
@@ -898,7 +899,7 @@ Until this, `TZ` was unset, so `date` printed UTC while cron read schedules in t
|
|
|
898
899
|
|
|
899
900
|
**Name resolution** (WASIX `sock_addr_resolve`; `Module.sliccKernel.net.resolve(name, family)` for Emscripten programs):
|
|
900
901
|
- `/etc/hosts` names are answered by the kernel itself: `localhost`, every `*.localhost`, `host.slicc.internal`, and literal addresses, IPv6 included.
|
|
901
|
-
- Any other name goes to the uplink. With no uplink or no answer, the name is not found (`EAI_NONAME`).
|
|
902
|
+
- Any other name goes to the uplink's `resolve`. When it has no answer (or the uplink has no `resolve`), the kernel asks the stub's [DNS forwarder](#dns) (the uplink's `nameserver`, else `network.doh`) for the name's `A` records, and `AAAA` when the uplink has `ipv6`, following its CNAME chain, with the shortest TTL of the records it keeps. So with an exit uplink that has no names of its own and `network.doh`, `getaddrinfo` and `dig` both see the forwarder's answer, and a program connects to it through the uplink's `dial`. Names under `localhost` and `slicc.internal` never go to the forwarder. With no uplink, or no answer from either (the forwarder's `NXDOMAIN` included), the name is not found (`EAI_NONAME`). A forwarder that answers `SERVFAIL` (or another error), or nothing within 10 s, fails the lookup with `ETIMEDOUT`, as an uplink that doesn't answer does, and the failure is not cached; wasix-libc's `getaddrinfo` reports that as not found too.
|
|
902
903
|
- Answers are cached for their TTL, at most 60 s, so a change of exit node takes effect quickly.
|
|
903
904
|
- **DNS cannot bridge into the kernel:** an answer that is loopback (`127.0.0.0/8`, `::1`), unspecified (`0.0.0.0`, `::`), the host (`10.0.2.2`), link-local, multicast or otherwise reserved, including the `::ffff:` forms, is dropped and logged with `console.warn`. A name cannot lead a program back to the kernel's loopback.
|
|
904
905
|
- An uplink that does not answer within 10 s resolves nothing.
|
package/dist/async-process.js
CHANGED
|
@@ -1358,7 +1358,7 @@ function createParentRefreshCount() {
|
|
|
1358
1358
|
}
|
|
1359
1359
|
|
|
1360
1360
|
// src/version.ts
|
|
1361
|
-
var KERNEL_VERSION = true ? "1.
|
|
1361
|
+
var KERNEL_VERSION = true ? "1.189.1" : "0.0.0-dev";
|
|
1362
1362
|
var OS_RELEASE = "6.0.0-slicc";
|
|
1363
1363
|
function procVersion() {
|
|
1364
1364
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|