@ai-ecoverse/slicc-kernel 1.188.0 → 1.189.0

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 CHANGED
@@ -271,17 +271,12 @@ import { DurableObject } from 'cloudflare:workers';
271
271
  import { createCloudflareKernel } from '@ai-ecoverse/slicc-kernel/cloudflare';
272
272
 
273
273
  export class Kernel extends DurableObject {
274
- now() {
275
- return Date.now();
276
- }
277
-
278
274
  kernel() {
279
275
  const { storage } = this.ctx;
280
276
  this.booting ??= createCloudflareKernel({
281
277
  loader: this.env.LOADER,
282
278
  sql: storage.sql,
283
279
  sqlite: { transaction: (fn) => storage.transactionSync(fn) },
284
- clock: () => this.env.KERNEL.get(this.ctx.id).now(),
285
280
  });
286
281
  return this.booting;
287
282
  }
@@ -302,7 +297,7 @@ The Worker needs a Worker Loader binding (`worker_loaders`) and a SQLite-backed
302
297
  | `loader` | required | the Worker Loader binding |
303
298
  | `sql`, `sqlite` | none | the Durable Object's `ctx.storage.sql`, and `{ transaction, writeBehind }`: the root file system and its POSIX metadata live in tables prefixed `slicc_` |
304
299
  | `root`, `meta`, `ranged` | `memoryRoot()` | a root of your own in place of `sql` |
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 |
300
+ | `clock` | a timer of 0 ms | awaited before every timed wait, so that the object's clock has moved on when the kernel reads it: a Workers clock stands still while code computes, and a timer moves it. Don't pass a call into the object's own namespace (`this.env.KERNEL.get(this.ctx.id).now()`), as this table used to say: on Cloudflare each such call raises the subrequest depth of the request it is made in, for the rest of that request, so after about 14 timed waits in one request (a `git clone`, eight `curl`s, a loop of `sleep`s) the clock fails, and so does every later call of the object that loops back into the Workers runtime: an R2 `get` with `Unspecified error (0)`, which a program that reads a file from such a mount sees as `EIO`, and a Durable Object stub with `Subrequest depth limit exceeded`. Local `workerd` has no such limit |
306
301
  | `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
302
  | `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)) |
308
303
  | `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)) |
@@ -358,7 +353,7 @@ await kernel.run(['curl', '-sS', 'https://example.com/']);
358
353
  - **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.
359
354
  - **The option is `() => Promise<TlsEngineModule>`**, asked at the first `CONNECT` and once per kernel, so any other way of loading the engine works too.
360
355
 
361
- **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' }`, 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`.
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' }` (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`.
362
357
 
363
358
  #### A file system the Durable Object serves
364
359
 
@@ -863,8 +858,8 @@ WASIX programs get `AF_INET`/`AF_INET6` `SOCK_DGRAM` sockets, and `AF_UNIX` ones
863
858
 
864
859
  The kernel answers DNS itself, so DNS clients (BIND's `dig`, `host` and `nslookup`) see the same names as `getaddrinfo` (#1244).
865
860
  - **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.
866
- - **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.
867
- - **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 there is none 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.
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, 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.
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, 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.
868
863
  - **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.
869
864
  - **`/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.
870
865
 
@@ -893,7 +888,7 @@ Until this, `TZ` was unset, so `date` printed UTC while cron read schedules in t
893
888
  - `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.
894
889
  - `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.
895
890
  - `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.
896
- - `resolve(name, family, signal)`: resolves with the name's addresses, as a list or as `{ addresses, ttl }` (seconds). `[]` means the name is not the uplink's. `family` is `4`, `6` or `0` (either), and `signal` aborts when the kernel stops waiting.
891
+ - `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`.
897
892
  - `dial({ network: 'tcp', host, port, signal })`: opens a TCP connection and resolves with `{ localAddr, remoteAddr, read(), write(bytes), closeWrite(), close() }`.
898
893
  - `read()` resolves with the next bytes, or `null` at the end.
899
894
  - `write` resolves with how many bytes it took.
@@ -903,7 +898,7 @@ Until this, `TZ` was unset, so `date` printed UTC while cron read schedules in t
903
898
 
904
899
  **Name resolution** (WASIX `sock_addr_resolve`; `Module.sliccKernel.net.resolve(name, family)` for Emscripten programs):
905
900
  - `/etc/hosts` names are answered by the kernel itself: `localhost`, every `*.localhost`, `host.slicc.internal`, and literal addresses, IPv6 included.
906
- - Any other name goes to the uplink. With no uplink or no answer, the name is not found (`EAI_NONAME`).
901
+ - 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.
907
902
  - Answers are cached for their TTL, at most 60 s, so a change of exit node takes effect quickly.
908
903
  - **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.
909
904
  - An uplink that does not answer within 10 s resolves nothing.
@@ -1358,7 +1358,7 @@ function createParentRefreshCount() {
1358
1358
  }
1359
1359
 
1360
1360
  // src/version.ts
1361
- var KERNEL_VERSION = true ? "1.188.0" : "0.0.0-dev";
1361
+ var KERNEL_VERSION = true ? "1.189.0" : "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