@ai-ecoverse/slicc-kernel 1.184.1 → 1.184.2

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
@@ -321,6 +321,8 @@ The Worker needs a Worker Loader binding (`worker_loaders`) and a SQLite-backed
321
321
  - **Durability:** the SQLite root writes behind. Every `run()`, `writeFile()`, `chmod()`, terminal exit and client reply, and every `fsync` or `fdatasync`, makes all earlier writes durable. A program that never syncs can lose, on an unclean stop of the Durable Object, what it wrote since the last of those points: at most the last second, or 50 ms after its last write if it then went quiet. What survives is always a consistent tree. `sync` without a file does nothing, because Emscripten's libc compiles it away. `sqlite: { writeBehind: false }` commits every change at once, at about 25 ms per change.
322
322
  - **Hard links** are refused on the root, as on every root.
323
323
  - **Speed:** a system call costs about 0.3 ms and starting a process about 50–90 ms.
324
+ - **Idle:** a kernel with no process running keeps no timer pending, so the Durable Object goes idle about 10 s after its last request and Cloudflare bills about the time it worked (1.5 s for four short commands on two objects, where a pending timer used to add 75 s for each object). What it held in memory is gone then, and the next request boots a new kernel on the persisted root, in 0.1–0.2 s. While a process runs or a terminal is open, the object stays active and is billed.
325
+ - **Cron:** jobs run only while the Durable Object is awake, and a table with a job coming keeps a timer pending, so the object is billed until Cloudflare evicts it, about 70 s after its last request. The runs that were due meanwhile are folded into one at the next boot, as [Cron](#cron) says. `cron: { poll: false }` is the default here: the service reads the tables when one is written, not every minute.
324
326
 
325
327
  Measured on a deployed Worker, from a client about 40 ms away, next to local `wrangler dev`:
326
328
 
@@ -352,7 +354,7 @@ const workspace = new Workspace({
352
354
  const run = await workspace.runtime.exec('ls -la /workspace | wc -l', { backend: 'slicc' });
353
355
  ```
354
356
 
355
- Output is streamed, `killExec` signals the whole process group, and a timeout sends `SIGTERM` and then `SIGKILL`. The kernel's own root (`/root`, `/etc`, `/tmp`, `/node_modules`) lives in the same SQLite database as the Workspace, in its own tables.
357
+ 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.
356
358
  - **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).
357
359
  - **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.
358
360
  - **Deletes are slow:** each removed file is one durable commit, about 30 ms on a deployed Worker.
@@ -1289,7 +1291,7 @@ A request can end without an answer: nobody was there within the 5 minutes, and
1289
1291
 
1290
1292
  ### Cron
1291
1293
 
1292
- The kernel runs scheduled jobs itself, with no daemon process: a cron service starts with the kernel and stops with `terminate()`. It reads `/etc/crontab` and the per-user tables in `/var/spool/cron/crontabs/<user>`, and runs each due job as `$SHELL -c '<command>'` (`/bin/bash` unless the table sets `SHELL`) as the table's user, in that user's home (`/` if the home is missing), with no terminal and `/dev/null` as standard input.
1294
+ The kernel runs scheduled jobs itself, with no daemon process: a cron service starts with the kernel and stops with `terminate()`. It reads the tables again every minute and whenever one is written in this kernel; with `cron: { poll: false }` (`createNodeKernel`, and the default of `createCloudflareKernel`) only when one is written, so a kernel with no job coming keeps no timer. It reads `/etc/crontab` and the per-user tables in `/var/spool/cron/crontabs/<user>`, and runs each due job as `$SHELL -c '<command>'` (`/bin/bash` unless the table sets `SHELL`) as the table's user, in that user's home (`/` if the home is missing), with no terminal and `/dev/null` as standard input.
1293
1295
 
1294
1296
  - **`crontab`** is a command of the kernel itself, in `/usr/bin` (a package's `crontab` never wins over it), with Vixie's options: `crontab -l` prints the caller's table, `crontab -r` removes it, `crontab <file>` and `crontab -` (standard input) install one, and `crontab -e` copies the table to `/tmp`, runs `$VISUAL` (or `$EDITOR`) on the copy through `/bin/bash -c '<editor> "$1"'`, and installs it if it changed and the editor exited with 0. If the edit doesn't parse, the copy is kept and its path is printed. `-u <user>` works on another user's table and needs an effective uid of 0 (`sudo crontab -u cone -l`). An install is checked first: a table with a line that doesn't parse is refused with every error (`"-":<line>: <message>`), and the old one stays. The table becomes the user's `0600` file in the spool, written to a dotfile of a random name and renamed, so the service, which skips dotfiles, never reads half a table. The command only reads the file it is given and passes it on (`ctx.crontab`, see [JS programs](#js-programs)). The kernel decides whose table it is from the caller's real uid, so a user reaches only their own table, and `/etc/crontab` stays root's to edit.
1295
1297
  - **Format:** Vixie's. Five fields (minute, hour, day of month, month, weekday) with lists, ranges, steps and the names `jan`–`dec` and `sun`–`sat` (7 is Sunday too), or one of `@yearly`/`@annually`, `@monthly`, `@weekly`, `@daily`/`@midnight`, `@hourly` and `@reboot`. As in cronie, when the day of month or the weekday starts with `*`, a day must match both fields; when both are restricted, it may match either. `/etc/crontab` has a user field after the schedule; a user's table doesn't. `NAME=value` lines set the environment for the jobs after them, `#` lines are comments, and `# name: <id>` on the line above a job gives it a stable id (letters, digits, `_`, `.`, `-`), which names its log. Without one, the id is a hash of the table, the user, the schedule and the command. `%` is not special.
@@ -1594,7 +1596,7 @@ The kernel is ported from SLICC's `packages/webapp/src/kernel/` with the browser
1594
1596
  - `src/cdp/`: the CDP facade on `127.0.0.1:9222`, its WebSocket framing, the registry of hosts and the `MessagePort` bridge to them.
1595
1597
  - `src/sudo.ts`, `src/sudoers.ts`, `src/sudo-command.ts`: the kernel side of `sudo` and `visudo -c`, the policy parser (both line forms and their diagnostics), and the two commands.
1596
1598
  - `src/time-zone.ts`: the system time zone (`timeZone`, or the browser's) and UTC offsets of a zone, which cron's schedules and `TZ` both come from.
1597
- - `src/async/`, `src/process/emscripten/`, `src/cloudflare.ts`, `src/cloudflare/` and `tools/derive-async/`: the kernel [in a Cloudflare Durable Object](#in-a-cloudflare-durable-object). `src/async/` is the link between the kernel and a process that shares no memory with it; `src/process/emscripten/` the kernel's own Emscripten imports; `src/cloudflare/` the Durable Object host, the SQLite root and the Cloudflare Computer backend; `tools/derive-async/` the build step that derives the async process runtime. Their tests are in `test/integration/cf/` and run in Node, with `node --test --test-concurrency=2 'test/integration/cf/*.test.mjs'`; those named `cloudflare-*` and `computer-cloudflare-*` start `wrangler dev`, and run against a deployed Worker when given its URL and key. `npm test` and CI run them with the rest. On a pull request, CI's `deploy` job runs `tools/cf-staging.mjs`, which deploys `examples/cloudflare-computer` as the Worker `slicc-kernel-do-pr-<number>` with a fresh random key, and hands its address to the test shards and the reviewers as `STAGING_URL` (`https://…workers.dev/?key=…`); `computer-cloudflare-staging.test.mjs` then runs the Computer example's tests against it. That address, key included, shows in the run's log and on the pull request, so the Worker stops answering 24 hours after its deploy, and its programs have no network. The job needs the secret `SLICC_KERNEL_CLOUDFLARE_API_TOKEN` (a Cloudflare API token that may edit Workers scripts; `SLICC_KERNEL_CLOUDFLARE_ACCOUNT_ID` too when the token sees several accounts). Without it, on a fork, in the merge queue, or when the deploy fails, there is no staging Worker and that test file skips. Each deploy deletes the staging Workers of other pull requests that no deploy has touched for a week.
1599
+ - `src/async/`, `src/process/emscripten/`, `src/cloudflare.ts`, `src/cloudflare/` and `tools/derive-async/`: the kernel [in a Cloudflare Durable Object](#in-a-cloudflare-durable-object). `src/async/` is the link between the kernel and a process that shares no memory with it; `src/process/emscripten/` the kernel's own Emscripten imports; `src/cloudflare/` the Durable Object host, the SQLite root and the Cloudflare Computer backend; `tools/derive-async/` the build step that derives the async process runtime. Their tests are in `test/integration/cf/` and run in Node, with `node --test --test-concurrency=2 'test/integration/cf/*.test.mjs'`; those named `cloudflare-*` and `computer-cloudflare-*` start `wrangler dev`, and run against a deployed Worker when given its URL and key. `npm test` and CI run them with the rest. On a pull request, CI's `deploy` job runs `tools/cf-staging.mjs`, which deploys `examples/cloudflare-computer` as the Worker `slicc-kernel-do-pr-<number>` with a fresh random key, and hands its address to the test shards and the reviewers as `STAGING_URL` (`https://…workers.dev/?key=…`); `computer-cloudflare-staging.test.mjs` then runs the Computer example's tests against it. That address, key included, shows in the run's log and on the pull request, so the Worker stops answering 24 hours after its deploy, and its programs have no network. The job needs the secret `SLICC_KERNEL_CLOUDFLARE_API_TOKEN` (a Cloudflare API token that may edit Workers scripts; `SLICC_KERNEL_CLOUDFLARE_ACCOUNT_ID` too when the token sees several accounts). Without it, on a fork, in the merge queue, or when the deploy fails, there is no staging Worker and that test file skips. Each deploy deletes the staging Workers of other pull requests whose last deploy is more than 24 hours old, which no longer answer, and warns about one it could not delete.
1598
1600
  - `src/cron/`: the cron service (`service.ts`), the schedule and table parsers, the clock, and the `crontab` command with the kernel side of `ctx.crontab`. An embedder that uses `Launcher` directly passes `cron: { lock }` to share the firing lock among the kernels on one root; the default, `slicc-kernel-cron`, is one lock for the whole origin.
1599
1601
 
1600
1602
 
@@ -1337,7 +1337,7 @@ function createParentRefreshCount() {
1337
1337
  }
1338
1338
 
1339
1339
  // src/version.ts
1340
- var KERNEL_VERSION = true ? "1.184.1" : "0.0.0-dev";
1340
+ var KERNEL_VERSION = true ? "1.184.2" : "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