diff --git a/AGENTS.md b/AGENTS.md index 0404c28..e3fe7c5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,7 +5,7 @@ Guidance for agents working in this repository. Prefer the checked-in code and t ## 1. Project - Published on npm as one package, `serverless-objects` (0.13.x, pre-alpha). It contains the `sobjects` CLI, the native engine, and the `serverless-objects/hotcell` and `serverless-objects/autopilot` modules. There is no `@serverless-objects` npm scope; ship new modules as subpath exports of this package. -- Two engines: celld (external, pinned 0.6.2) and the native engine (`sobjects dev --engine native`: in-process, trusted code, node:sqlite per object). Conformance: Cloudflare 17/17 (`test:cloudflare`, deploys to the logged-in account and deletes afterwards), Wrangler 4.150.0 16/16, celld 0.6.2 17/17, native 17/17 (hibernation runs everywhere but Wrangler); facets are not covered. +- Two engines: celld (external, pinned 0.6.2) and the native engine (`sobjects dev --engine native`: in-process, trusted code, node:sqlite per object). Conformance: Cloudflare 17/17 (`test:cloudflare`, deploys to the logged-in account and deletes afterwards), Wrangler 4.150.0 17/17, celld 0.6.2 19/19, native 18/18 (hibernation runs everywhere but Wrangler; facets pass on Wrangler and celld but not the native engine; a schedule across restart runs on celld and native). - ACME HTTP-01 is verified only against a local Pebble server. Point-in-time restore is not available on celld 0.6. The native engine has bucket backups (`--backup-bucket`; `--backup-mode durable` holds each result until its writes are in the bucket and adds Cloudflare's point-in-time recovery API, back `--backup-retention-days`), several nodes per bucket (`--node-name`, `--peer-listen`), and optional worker threads (`--threads`; fault and CPU isolation, not a security boundary). A `[native]` table in `sobjects.toml` (instead of `[celld]`) makes `sobjects up` run it as `sobjects dev --engine native` in a child process; `[admin]` isn't supported with it yet. Roadmap targets are not guarantees. Serverless Objects is a self-hostable operating layer for Cloudflare Workers and Durable Objects applications, aimed at coding-agent infrastructure. It is JavaScript (ES modules) on Node.js >=22, managed with npm workspaces; the product is the `sobjects` CLI (workspace package `serverless-objects`). The CLI supervises the external celld runtime (pinned v0.6.2) for production nodes and also ships a Node-native engine for trusted code. Cloudflare Workers/Wrangler APIs are the compatibility contract. The dashboard is plain HTML/CSS/JS; there is no application framework or TypeScript codebase. Status: pre-alpha. @@ -20,7 +20,7 @@ Run from the repository root unless a command says otherwise. Node.js 22+ is req | All automated tests | `npm test` | Runs each workspace's test script; CI uses this. | | CLI workspace tests | `npm run test --workspace=serverless-objects` | Node built-in test runner over `packages/cli/test/*.test.js`. | | Conformance (Wrangler) | `npm run test:wrangler --workspace=sobjects-conformance` | Runs the conformance app under pinned `wrangler dev`; CI runs this. | -| Conformance (celld) | `npm run test:celld --workspace=sobjects-conformance` | Runs the same cases against celld, including an alarm across a restart and hibernation; not run in CI. | +| Conformance (celld) | `npm run test:celld --workspace=sobjects-conformance` | Runs the same cases against celld, including an alarm across a restart, hibernation and facets; not run in CI. | | Benchmark | `npm run bench --workspace=sobjects-conformance -- --target native` (or `celld`, `wrangler`, `--url URL`) | Runs `bench-app/` and prints latency/throughput; not run in CI. Results and durability caveats in `docs/benchmarks.md`. | | Conformance (Cloudflare) | `npm run test:cloudflare --workspace=sobjects-conformance` | Deploys both apps with `wrangler deploy` to the account Wrangler is logged in to, runs every check, then deletes the Workers (`--keep-deployment` keeps them). Outward-facing: needs the account owner's OK; not run in CI. | | Conformance (native) | `npm run test:native --workspace=sobjects-conformance` (add `-- --native-threads 3` for threads) | Runs them against the native engine from this checkout; CI runs both. | diff --git a/README.md b/README.md index 3084f1e..01d2683 100644 --- a/README.md +++ b/README.md @@ -94,9 +94,9 @@ State survives `down` and `up` because it lives in the bucket. The [install guid ## Compatibility -Cloudflare's APIs are the contract. The current [conformance results](docs/conformance/results.md) pass every check on real Cloudflare (17/17), Wrangler 4.150.0 (16/16), celld 0.6.2 (17/17) and the native engine (17/17): the same apps, unchanged. They cover Durable Object IDs, KV and SQL storage, transactions, input gates, RPC, alarms (including across a restart), WebSockets with hibernation on celld, and an Agents SDK suite: state, SQL, schedules, addressing and `@callable()` RPC. +Cloudflare's APIs are the contract. The current [conformance results](docs/conformance/results.md) pass every check on real Cloudflare (17/17), Wrangler 4.150.0 (17/17), celld 0.6.2 (19/19) and the native engine (18/18): the same apps, unchanged. They cover Durable Object IDs, KV and SQL storage, transactions, input gates, RPC, alarms (including across a restart), WebSockets with hibernation on celld, facets on Wrangler and celld, and an Agents SDK suite: state, SQL, schedules (including one across a restart), addressing and `@callable()` RPC. -Not covered yet: sockets across a cell move between nodes, facets, PartyServer, Agents SDK chat, MCP and Workflows, and Cloudflare-hosted production behavior. Point-in-time restore isn't available on celld 0.6; the native engine has Cloudflare's point-in-time recovery API in durable mode. The [compatibility table](docs/compatibility.md) has the details, including Containers and `@cloudflare/sandbox` 1.0 on celld. The [porting guide](docs/porting-from-cloudflare.md) covers moving an existing project. +Not covered yet: sockets across a cell move between nodes, PartyServer, Agents SDK chat, MCP and Workflows, and Cloudflare-hosted production behavior. Facets pass on Wrangler and celld but are not implemented by the native engine. Point-in-time restore isn't available on celld 0.6; the native engine has Cloudflare's point-in-time recovery API in durable mode. The [compatibility table](docs/compatibility.md) has the details, including Containers and `@cloudflare/sandbox` 1.0 on celld. The [porting guide](docs/porting-from-cloudflare.md) covers moving an existing project. ## Repository layout @@ -115,7 +115,7 @@ celld is driven through a small contract: the Wrangler bundle, the Wrangler conf | Engine | Status | Notes | |---|---|---| | [celld](https://github.com/denoland/celld) | Supported (0.6.2, pinned) | Runs Wrangler bundles with Durable Objects, KV, D1, R2, Queues, Workflows and Containers. | -| native | In progress: `sobjects dev --engine native` | Runs the Worker and Durable Objects in Node, with each object in its own SQLite file and full Node APIs inside objects. It passes the full conformance suite (17/17, hibernation and the Agents SDK included), with idle eviction. `sobjects build --strict` checks that an app stays portable to Cloudflare. `--backup-bucket` backs objects up to S3-compatible storage (with `--backup-mode durable`, every acknowledged write is in the bucket), `--threads N` spreads objects over worker threads, and `--node-name` lets several nodes share one bucket, taking over each other's objects and forwarding calls. A `[native]` table in `sobjects.toml` runs it under `sobjects up`. For trusted code. See [the native engine](docs/native-engine.md). | +| native | In progress: `sobjects dev --engine native` | Runs the Worker and Durable Objects in Node, with each object in its own SQLite file and full Node APIs inside objects. It passes the full conformance suite (18/18, hibernation and the Agents SDK included, with facets skipped), with idle eviction. `sobjects build --strict` checks that an app stays portable to Cloudflare. `--backup-bucket` backs objects up to S3-compatible storage (with `--backup-mode durable`, every acknowledged write is in the bucket), `--threads N` spreads objects over worker threads, and `--node-name` lets several nodes share one bucket, taking over each other's objects and forwarding calls. A `[native]` table in `sobjects.toml` runs it under `sobjects up`. For trusted code. See [the native engine](docs/native-engine.md). | ## Why diff --git a/deploy/compose/README.md b/deploy/compose/README.md index 139a7dd..e24e35d 100644 --- a/deploy/compose/README.md +++ b/deploy/compose/README.md @@ -57,7 +57,7 @@ The dashboard and admin API stay on loopback inside the container; don't publish ## Notes -- **Pinned versions:** the image pins `serverless-objects` with the `SOBJECTS_VERSION` build argument (default `0.13.4`), and that CLI pins celld 0.6.2. To upgrade, change the argument and rebuild. The `local-s3` profile pins SeaweedFS (`chrislusf/seaweedfs:4.48`); change the tag in `compose.yaml` to move it. +- **Pinned versions:** the image pins `serverless-objects` with the `SOBJECTS_VERSION` build argument, whose default release-please keeps in step with the CLI release, and that CLI pins celld 0.6.2. To upgrade, change the argument and rebuild. The `local-s3` profile pins SeaweedFS (`chrislusf/seaweedfs:4.48`); change the tag in `compose.yaml` to move it. - **Graceful stop:** on stop, celld drains and releases its lease. `stop_grace_period` is 60 s; a stop took about 17 s in testing. - **Key permissions:** the private key must be readable by uid 999, the container's `sobjects` user, and by nobody else: `chmod 600 tls/privkey.pem && sudo chown 999 tls/privkey.pem`. Don't make it world-readable (`chmod 644`), which exposes it to every account on the host. - **Platforms:** linux/arm64 and linux/amd64. The full stack has been tested on arm64 (Docker on macOS). CI builds the amd64 image and checks that `sobjects` and `celld` run in it. diff --git a/docs/compatibility.md b/docs/compatibility.md index 8968f61..2d12bcd 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -1,6 +1,6 @@ # Compatibility and support status -This table distinguishes behavior exercised by the project from functionality described by celld upstream. A celld capability is not automatically a Serverless Objects product guarantee. The conformance results are one local run on macOS arm64 using Wrangler 4.150.0, celld 0.6.2 and the native engine, plus one deployment to Cloudflare; they are not a cross-platform or Cloudflare production certification. +This table distinguishes behavior exercised by the project from functionality described by celld upstream. A celld capability is not automatically a Serverless Objects product guarantee. The conformance results are one local run on macOS arm64 using Wrangler 4.150.0, celld 0.6.2 and the native engine, plus one deployment to Cloudflare; they are not a cross-platform or Cloudflare production certification. CI runs the Wrangler and native suites on Ubuntu x64 but records no results, so the table is macOS arm64 evidence plus unrecorded Ubuntu x64 CI coverage. ## Product and runtime behavior @@ -16,9 +16,9 @@ This table distinguishes behavior exercised by the project from functionality de | `deleteAll()` clears alarm | Tested on Wrangler and celld | Passed with compatibility date `2026-02-24` or later. | | Basic WebSockets | Tested on Wrangler and celld | Upgrade, echo, attachment, tags and auto-response passed. | | WebSocket hibernation/eviction | Tested on celld | Same-node hibernation passed on celld 0.6.2: the object was evicted with a socket open, and the next message reached a new instance with tags and attachment intact. Not run on Wrangler (no eviction control). celld documents that sockets may close when a cell moves between nodes; that is not tested. | -| Facets | Not tested in conformance v0 | Not covered by the current app or results. | +| Facets | Tested on Wrangler and celld | `ctx.facets.get` with a class taken from `ctx.exports` passed on Wrangler 4.150.0 and celld 0.6.2: state by name, isolation between facets, storage separate from the parent, and alarms refused. The native engine does not implement `ctx.facets`, so the check is skipped there. | | Durable Object migrations | Limited upstream support | celld 0.6.2 accepts `tag` and `new_sqlite_classes`; rename/delete/transfer migrations are rejected. | -| Agents SDK / PartyServer | Partial | A minimal `agents` 0.28.1 app was deployed through `sobjects deploy` and served by `sobjects up` behind TLS ingress (celld 0.6.2, SeaweedFS): routing, `setState`, `this.sql`, `schedule()` (including one pending across a node restart), and the WebSocket identity/state protocol matched `wrangler dev`. Callable RPC passes in the conformance suite on celld and the native engine (Agents SDK client protocol), but has not been exercised through `sobjects deploy`/`up`; chat agents, MCP, Workflows and the official samples have not been run through the CLI. PartyServer chat was tested only directly on celld in M0. See [M0 findings](conformance/m0-celld.md). | +| Agents SDK / PartyServer | Partial | A minimal `agents` 0.28.1 app was deployed through `sobjects deploy` and served by `sobjects up` behind TLS ingress (celld 0.6.2, SeaweedFS): routing, `setState`, `this.sql`, `schedule()` (including one pending across a node restart), and the WebSocket identity/state protocol matched `wrangler dev`. Callable RPC passes in the conformance suite on celld and the native engine (Agents SDK client protocol), and a delayed schedule now survives a process restart there, but neither has been exercised through `sobjects deploy`/`up`; chat agents, MCP, Workflows and the official samples have not been run through the CLI. PartyServer chat was tested only directly on celld in M0. See [M0 findings](conformance/m0-celld.md). | | Cloudflare-hosted production behavior | Not tested | Local Wrangler and celld results do not certify production Cloudflare behavior. | ## Bindings and topology @@ -26,7 +26,7 @@ This table distinguishes behavior exercised by the project from functionality de | Capability | Status | Notes | |---|---|---| | celld Durable Objects, KV, D1, R2, Queues, Workflows | Upstream-reported | Listed by celld 0.6.2; this conformance suite does not exercise every binding. Check celld's release documentation for exact feature limits. | -| Containers (`ctx.container`) and `@cloudflare/sandbox` 1.0 | Partial, tested once on celld with Docker | celld 0.6.2 runs Wrangler `containers` classes on a local Docker or Podman engine. A DO using stock `@cloudflare/sandbox` 1.0.1 (`Files.writeFile`/`readFile`, `ctx.container.exec`) worked with an image built `FROM alpine` plus `sandbox-shim` copied from `cloudflare/sandbox:1.0.1`, which is a tools-only image with no command. Gaps seen on macOS: `exec()` straight after `start()` fails with "No such container" while the container is still being created, where Cloudflare's own example calls them back to back; `enableInternet: false` is not enforced (celld logs a warning); `container.images` is undefined. Not tested: Linux, `S3Mount`, `DirectoryBackup`, sleep and restart. | +| Containers (`ctx.container`) and `@cloudflare/sandbox` 1.0 | Partial, one manual run on celld with Docker | celld 0.6.2 runs Wrangler `containers` classes on a local Docker or Podman engine. A DO using stock `@cloudflare/sandbox` 1.0.1 (`Files.writeFile`/`readFile`, `ctx.container.exec`) worked with an image built `FROM alpine` plus `sandbox-shim` copied from `cloudflare/sandbox:1.0.1`, which is a tools-only image with no command. That was a manual run on macOS through Docker Desktop, not an automated conformance case, and it exercises Docker's Linux VM rather than a Linux host. Gaps seen there: `exec()` straight after `start()` fails with "No such container" while the container is still being created, where Cloudflare's own example calls them back to back; `enableInternet: false` is not enforced (celld logs a warning); `container.images` is undefined. Not tested: a Linux host, `S3Mount`, `DirectoryBackup`, sleep and restart. | | Workers AI, Vectorize, Hyperdrive, Browser Rendering, Email Workers | Not provided by celld 0.6.2 | Serverless Objects does not implement replacements. | | Single-host `sobjects up` | Implemented and smoke-tested | The current product is a single-host operating layer by default. Keep operator/admin listeners on loopback. | | Multi-node object placement | Native engine only | `--node-name` shares one bucket prefix between nodes, with leases, takeover, drain and call forwarding ([details](native-engine.md#several-nodes)). celld runs one node per bucket prefix. | diff --git a/docs/conformance/results.md b/docs/conformance/results.md index 8790af2..8737f14 100644 --- a/docs/conformance/results.md +++ b/docs/conformance/results.md @@ -1,8 +1,8 @@ # Conformance v0 results -Recorded 19 Oct 2026 on macOS arm64 with Node.js 24.12.0, using the local +Recorded 19–29 Oct 2026 on macOS arm64 with Node.js 24.12.0, using the local Wrangler runner as the reference and celld's local development server. Each -runner completed all of its checks in one run: 16 on Wrangler (10 core, 6 Agents SDK) and 17 on celld (adding hibernation). +runner completed all of its checks in one run: 17 on Wrangler (11 core, 6 Agents SDK), 19 on celld (adding hibernation and facets) and 18 on the native engine (adding hibernation and a schedule across restart, without facets). - Wrangler: 4.150.0 (`wrangler dev --local`) - celld: 0.6.2 (`celld dev`) @@ -11,7 +11,7 @@ runner completed all of its checks in one run: 16 on Wrangler (10 core, 6 Agents - Command: `npm run test:wrangler --workspace=sobjects-conformance` and `npm run test:celld --workspace=sobjects-conformance` -| Area | Cloudflare | Wrangler 4.150.0 | celld 0.6.2 | native (in progress) | Notes | +| Area | Cloudflare | Wrangler 4.150.0 | celld 0.6.2 | native | Notes | |---|---:|---:|---:|---:|---| | Durable Object IDs | Pass | Pass | Pass | Pass | Deterministic/named IDs, unique IDs, string conversion and validation | | KV storage | Pass | Pass | Pass | Pass | Get/put/list/delete, ranges, structured-clone values | @@ -23,22 +23,25 @@ runner completed all of its checks in one run: 16 on Wrangler (10 core, 6 Agents | `deleteAll()` clears alarm | Pass | Pass | Pass | Pass | Requires the tested compatibility date, `2026-02-24` or later | | WebSocket behavior | Pass | Pass | Pass | Pass | Upgrade, echo, attachment, tags and auto-response | | WebSocket hibernation | Pass | Not run | Pass | Pass | With `CELLD_IDLE_EVICT_S=2`, celld evicted the object while a socket stayed open; the next message reached a new instance with the socket's tags and attachment. Wrangler's local runtime gives the runner no eviction control. | +| Facets | Not run | Pass | Pass | Not run | `ctx.facets.get` with a class from `ctx.exports`: state by name, isolation between facets, storage separate from the parent, and alarms refused. workerd and celld 0.6.2 pass; the native engine has no `ctx.facets`. | | Agents SDK state and SQL | Pass | Pass | Pass | Pass | `setState`/`this.state` and the `this.sql` tagged template | | Agents SDK schedules | Pass | Pass | Pass | Pass | Delayed and cron schedules, list, cancel; a delayed schedule runs its callback | +| Agents SDK schedule across restart | Not run | Not run | Pass | Pass | A delayed schedule armed before a process restart was still pending afterwards and fired | | Agents SDK addressing | Pass | Pass | Pass | Pass | `getAgentByName`, `this.name`, class name, `/agents//` routing | | Agents SDK client protocol | Pass | Pass | Pass | Pass | Identity and state frames, `@callable()` RPC over WebSocket, state broadcast, non-callable methods refused | -The Cloudflare column is from `npm run test:cloudflare` (20 Oct 2026): 17/17. The runner deployed both apps unchanged with `wrangler deploy` to a workers.dev subdomain on the free plan, ran every check against the deployment, and deleted the Workers. Cloudflare hibernated the object on its own during a 30-second idle period. There is no process to restart, so the alarm-across-restart check runs as plain alarm delivery there. +The Cloudflare column is from `npm run test:cloudflare` (20 Oct 2026): 17/17. The runner deployed both apps unchanged with `wrangler deploy` to a workers.dev subdomain on the free plan, ran every check against the deployment, and deleted the Workers. Cloudflare hibernated the object on its own during a 30-second idle period. There is no process to restart, so the alarm-across-restart check runs as plain alarm delivery there. The facets and schedule-across-restart checks were added after that run and have not been run on Cloudflare. -The native engine column is from `npm run test:native` on the same host (20 Oct 2026): 17/17, with `--idle-evict-seconds 2` for the hibernation check; see [the native engine](../native-engine.md). +The native engine column is from `npm run test:native` on the same host (29 Oct 2026): 18/18, with `--idle-evict-seconds 2` for the hibernation check; see [the native engine](../native-engine.md). + +## Platforms + +Every column above is one local run on macOS arm64. CI runs the Wrangler and native suites on Ubuntu x64 (Node 22) on every change, and builds the linux/amd64 Docker image and checks that `sobjects` and `celld` start in it; it does not run `test:celld` or `test:cloudflare`, and it records no results. Linux arm64 has no conformance evidence beyond the Compose stack on Docker Desktop. Treat the table as macOS arm64 evidence plus unrecorded Ubuntu x64 CI coverage, not as a cross-platform claim. ## Not covered -This v0 run does not test hibernation on Wrangler, the alarm-across-restart check on Cloudflare or Wrangler, sockets across a cell move between nodes, facets, all +This v0 run does not test hibernation on Wrangler, the alarm-across-restart check on Cloudflare or Wrangler, sockets across a cell move between nodes, all compatibility flags, PartyServer, or -Agents SDK chat agents, MCP, Workflows, streaming RPC and schedules across a -restart. These runners use `wrangler dev` and `celld dev` directly; they do not +Agents SDK chat agents, MCP, Workflows and streaming RPC. These runners use `wrangler dev` and `celld dev` directly; they do not go through `sobjects deploy`. Those remain separate -conformance and product-level gates. The results are from one local run per -target on one macOS arm64 host; repeat them on supported Linux platforms before -making broader platform claims. +conformance and product-level gates. diff --git a/docs/native-engine.md b/docs/native-engine.md index 6ff0fa3..81de518 100644 --- a/docs/native-engine.md +++ b/docs/native-engine.md @@ -23,7 +23,8 @@ The app's own code is bundled with esbuild, which handles TypeScript and `define | `vars`, `cloudflare:workers` (`DurableObject`, `WorkerEntrypoint`, `WorkflowEntrypoint`, `RpcTarget`, `env`, `exports`), `cloudflare:email` (`EmailMessage` only) | Yes | | WebSockets | Yes: `WebSocketPair`, `accept()`, event listeners, attachments, and a built-in RFC 6455 server (handshake, masking, fragmentation, ping/pong, close handshake) | | Hibernation API | Yes: `acceptWebSocket` with tags, `getWebSockets`, `getTags`, `setWebSocketAutoResponse` (answered without waking the object), and `webSocketMessage`/`webSocketClose`/`webSocketError` delivered through the object's input-gated queue. Sockets belong to the object's host, so an evicted object's hibernatable sockets stay open, and the next message wakes a new instance. | -| Agents SDK | Yes: the conformance Agents suite passes (state, SQL, schedules, addressing, `@callable()` RPC over WebSocket) | +| Agents SDK | Yes: the conformance Agents suite passes (state, SQL, schedules, addressing, `@callable()` RPC over WebSocket, and a delayed schedule that survives a process restart) | +| Facets (`ctx.facets`) | Not yet. The engine has no `ctx.facets`, so the conformance facet check is skipped on this target. | | KV, D1, R2, Queues, Workflows, service bindings, assets | Not yet. The engine refuses a config that declares them. | | Idle eviction | Yes: an object idle for `--idle-evict-seconds` (default 60; 0 never) loses its instance. Sockets accepted with `accept()` and listeners keep it in memory. An object with no sockets and no pending alarm also closes its database. | | Portability check | Yes: `sobjects build [--strict]` lists each Node.js built-in the app imports, with the files that import it, and marks it as supported on Cloudflare, a non-functional stub there, or blocked by a missing `nodejs_compat` flag or compatibility date. It also flags packages that ship compiled native addons. A portable app runs on Cloudflare, celld and the native engine; a native-only app runs only here. | @@ -185,4 +186,4 @@ See [benchmarks](benchmarks.md) for latency and throughput next to celld and Wra The conformance runner has a `native` target: `npm run test:native --workspace=sobjects-conformance`. -It passes all 17 checks, the same set celld passes: the core suite, including the alarm-across-restart and hibernation checks, plus the Agents SDK suite. The runner starts the engine with `--idle-evict-seconds 2`. CI runs it on every change. See [results](conformance/results.md). +It passes all 18 checks: the core suite, including the alarm-across-restart and hibernation checks, plus the Agents SDK suite, including a schedule that survives a process restart. The facet check is skipped here because the engine has no `ctx.facets`. The runner starts the engine with `--idle-evict-seconds 2`. CI runs it on every change. See [results](conformance/results.md). diff --git a/docs/porting-from-cloudflare.md b/docs/porting-from-cloudflare.md index 93e2e26..bca4623 100644 --- a/docs/porting-from-cloudflare.md +++ b/docs/porting-from-cloudflare.md @@ -54,7 +54,7 @@ Before switching traffic, check for: - Cloudflare-only configuration fields, deployment hooks, observability and source-map upload behavior. - Assumptions about production networking, service bindings, outbound connections, Cache, or global coordination. - Durable Object migration operations beyond adding SQLite classes. -- WebSocket hibernation, facets, cross-isolate RPC, or behavior across a cell move. Hibernation and the Agents SDK client protocol (including `@callable()` RPC over WebSocket) pass in conformance on celld and the native engine; facets and cell moves are not covered. +- WebSocket hibernation, facets, cross-isolate RPC, or behavior across a cell move. Hibernation and the Agents SDK client protocol (including `@callable()` RPC over WebSocket) pass in conformance on celld and the native engine; facets pass on Wrangler and celld but not on the native engine; cell moves are not covered. - Whether the app has been run through the actual `sobjects` CLI. A minimal Agents SDK app (state, SQL, schedules, WebSocket protocol) has run through `sobjects deploy` and `sobjects up`; the official samples, chat agents, MCP and Workflows have not. Callable RPC passes in the conformance suite but has not been exercised through `sobjects deploy`/`up`. Do not infer production Cloudflare behavior from local Wrangler results, or infer full celld compatibility from one passing sample. Record any mismatch as a conformance case and keep unsupported behavior visible. diff --git a/packages/conformance/agents-app/src/index.js b/packages/conformance/agents-app/src/index.js index c539a84..801f4f0 100644 --- a/packages/conformance/agents-app/src/index.js +++ b/packages/conformance/agents-app/src/index.js @@ -57,7 +57,7 @@ export class Probe extends Agent { } ticks() { - return { ticks: this.state.ticks, lastTick: this.state.lastTick ?? null }; + return { ticks: this.state.ticks, lastTick: this.state.lastTick ?? null, schedules: this.getSchedules().length }; } tick(payload) { @@ -86,9 +86,13 @@ export default { if (url.pathname === "/cases") return json(Object.keys(CASES)); if (url.pathname === "/schedule/arm") { const seconds = Number(url.searchParams.get("seconds") ?? 2); - return json({ pending: await (await probe(env, "fire")).arm(seconds) }); + const agent = url.searchParams.get("agent") ?? "fire"; + return json({ pending: await (await probe(env, agent)).arm(seconds) }); + } + if (url.pathname === "/schedule/status") { + const agent = url.searchParams.get("agent") ?? "fire"; + return json(await (await probe(env, agent)).ticks()); } - if (url.pathname === "/schedule/status") return json(await (await probe(env, "fire")).ticks()); if (url.pathname.startsWith("/case/")) { const name = url.pathname.slice("/case/".length); if (!CASES[name]) return json({ error: "unknown case" }, 404); diff --git a/packages/conformance/app/src/index.js b/packages/conformance/app/src/index.js index db28931..7308383 100644 --- a/packages/conformance/app/src/index.js +++ b/packages/conformance/app/src/index.js @@ -176,6 +176,56 @@ export class Gate extends DurableObject { } } +// Facets: a child object owned by a parent, created with ctx.facets.get(). +// The facet class is exported but not bound; the parent names it at startup. +export class Facet extends DurableObject { + async setValue(value) { + await this.ctx.storage.put("value", value); + return value; + } + + async getValue() { + return (await this.ctx.storage.get("value")) ?? null; + } + + async setAlarmAt(time) { + await this.ctx.storage.setAlarm(time); + } +} + +export class Facets extends DurableObject { + async run() { + await this.ctx.storage.deleteAll(); + // A facet class is reached through ctx.exports, which yields a loopback + // DurableObjectClass; the exported class itself is not one. + const facetClass = this.ctx.exports.Facet; + const first = this.ctx.facets.get("child", () => ({ class: facetClass })); + await first.setValue({ n: 1 }); + check("facet state", (await first.getValue())?.n === 1, await first.getValue()); + + // The same name resolves to the same facet, with its state intact. + const again = this.ctx.facets.get("child", () => ({ class: facetClass })); + check("facet identity", (await again.getValue())?.n === 1, await again.getValue()); + + // A different name is a different facet with its own storage. + const other = this.ctx.facets.get("other", () => ({ class: facetClass })); + check("facet isolation", (await other.getValue()) === null, await other.getValue()); + + // The facet's storage is separate from the parent's. + check("parent storage separate", (await this.ctx.storage.get("value")) === undefined); + + // Facets cannot set alarms. + let threw = false; + try { + await first.setAlarmAt(Date.now() + 60_000); + } catch { + threw = true; + } + check("facets cannot set alarms", threw); + return "ctx.facets.get, state by name, isolation, separate storage, no alarms"; + } +} + export class Sockets extends DurableObject { // A new value means the runtime constructed a new instance, e.g. after hibernation. instance = crypto.randomUUID(); @@ -293,11 +343,16 @@ function alarms(env, name) { return env.ALARMS.get(env.ALARMS.idFromName(name)); } +function facets(env) { + return env.FACETS.get(env.FACETS.idFromName("facets")); +} + export default { async fetch(request, env) { const url = new URL(request.url); if (url.pathname === "/cases") return json(Object.keys(CASES)); if (url.pathname === "/pitr") return json(await pointInTimeRecovery(env).then((detail) => ({ pass: true, detail }), (error) => ({ pass: false, detail: String(error?.message ?? error) }))); + if (url.pathname === "/facets") return json(await facets(env).run().then((detail) => ({ pass: true, detail }), (error) => ({ pass: false, detail: String(error?.message ?? error) }))); if (url.pathname === "/socket") { return env.SOCKETS.get(env.SOCKETS.idFromName("sockets")).fetch(request); } diff --git a/packages/conformance/app/wrangler.json b/packages/conformance/app/wrangler.json index d4cf656..1aebc7c 100644 --- a/packages/conformance/app/wrangler.json +++ b/packages/conformance/app/wrangler.json @@ -7,8 +7,9 @@ { "name": "STORAGE", "class_name": "Storage" }, { "name": "ALARMS", "class_name": "Alarms" }, { "name": "GATE", "class_name": "Gate" }, - { "name": "SOCKETS", "class_name": "Sockets" } + { "name": "SOCKETS", "class_name": "Sockets" }, + { "name": "FACETS", "class_name": "Facets" } ] }, - "migrations": [{ "tag": "v1", "new_sqlite_classes": ["Storage", "Alarms", "Gate", "Sockets"] }] + "migrations": [{ "tag": "v1", "new_sqlite_classes": ["Storage", "Alarms", "Gate", "Sockets", "Facets", "Facet"] }] } diff --git a/packages/conformance/soak/Dockerfile b/packages/conformance/soak/Dockerfile index 69104b5..40dd905 100644 --- a/packages/conformance/soak/Dockerfile +++ b/packages/conformance/soak/Dockerfile @@ -1,10 +1,14 @@ # The soak runner: the published serverless-objects CLI, SeaweedFS as the -# bucket, and soak.js driving load and faults. Build from this folder: -# docker build --build-arg SOBJECTS_VERSION=0.9.1 -t sobjects-soak . +# bucket, and soak.js driving load and faults. Build from this folder, passing +# the release under test explicitly: +# docker build --build-arg SOBJECTS_VERSION=$(npm view serverless-objects version) -t sobjects-soak . FROM chrislusf/seaweedfs@sha256:4e61d15fd35994cb1e43e1e553dff106794841fd9a99ade2fc8c8bfce4d7872d AS seaweedfs FROM node:22-bookworm-slim -ARG SOBJECTS_VERSION=0.9.1 +# No default on purpose: a soak must never silently test a stale release. +ARG SOBJECTS_VERSION +RUN test -n "$SOBJECTS_VERSION" \ + || (echo "SOBJECTS_VERSION is required: pass --build-arg SOBJECTS_VERSION=" >&2; exit 1) COPY --from=seaweedfs /usr/bin/weed /usr/local/bin/weed RUN npm install -g serverless-objects@${SOBJECTS_VERSION} && npm cache clean --force WORKDIR /soak/runner diff --git a/packages/conformance/soak/README.md b/packages/conformance/soak/README.md index 476c2bb..eac9827 100644 --- a/packages/conformance/soak/README.md +++ b/packages/conformance/soak/README.md @@ -26,7 +26,9 @@ Faults, one every ~45 minutes on average (weights in `soak.js`): Everything runs in one container: the engine, SeaweedFS as the bucket, and the load. The container needs no network (`--network none`) and publishes no ports. ```sh -docker build --build-arg SOBJECTS_VERSION=0.9.1 -t sobjects-soak packages/conformance/soak +# The release under test is required; there is no default, so a soak cannot +# silently run an old CLI. +docker build --build-arg SOBJECTS_VERSION=$(npm view serverless-objects version) -t sobjects-soak packages/conformance/soak # A small dedicated disk for the engine's data, so disk-full stays inside it: mkdir -p /opt/sobjects-soak/state /opt/sobjects-soak/data fallocate -l 2G /opt/sobjects-soak/data.img && mkfs.ext4 -q /opt/sobjects-soak/data.img diff --git a/packages/conformance/src/run.js b/packages/conformance/src/run.js index ea7e8eb..30be4cb 100644 --- a/packages/conformance/src/run.js +++ b/packages/conformance/src/run.js @@ -306,6 +306,44 @@ async function runPitrCheck(baseUrl) { return validateCaseResult("point-in-time-recovery", response, await response.json()); } +// Facets are part of the Durable Objects contract. workerd and celld 0.6.2 +// implement them; the native engine has no ctx.facets, so it skips this. +async function runFacetCheck(baseUrl) { + const response = await fetch(new URL("/facets", baseUrl)); + return validateCaseResult("facets", response, await response.json()); +} + +async function readAgentsScheduleStatus(baseUrl, agent) { + const response = await fetch(`${baseUrl}/schedule/status?agent=${encodeURIComponent(agent)}`, { signal: AbortSignal.timeout(5_000) }); + if (!response.ok) throw new Error(`/schedule/status returned HTTP ${response.status}`); + return response.json(); +} + +// A delayed schedule is stored with the agent, so it must survive a process +// restart and still fire afterwards. +async function runAgentsScheduleRestartCheck(baseUrl, restart) { + const agent = "restart"; + const response = await fetch(`${baseUrl}/schedule/arm?seconds=30&agent=${agent}`, { signal: AbortSignal.timeout(5_000) }); + if (!response.ok) throw new Error(`/schedule/arm returned HTTP ${response.status}`); + const before = await readAgentsScheduleStatus(baseUrl, agent); + if (before.ticks !== 0 || before.schedules < 1) throw new Error(`schedule was not armed: ${JSON.stringify(before)}`); + + await restart(); + + const afterRestart = await readAgentsScheduleStatus(baseUrl, agent); + if (afterRestart.ticks !== 0) throw new Error(`schedule fired during the restart: ${JSON.stringify(afterRestart)}`); + if (afterRestart.schedules < 1) throw new Error(`schedule was not restored after restart: ${JSON.stringify(afterRestart)}`); + + const deadline = Date.now() + 60_000; + let status = afterRestart; + while (Date.now() < deadline) { + status = await readAgentsScheduleStatus(baseUrl, agent); + if (status.ticks === 1 && status.lastTick === "fire") return { pass: true, detail: "a pending schedule survived a process restart and fired" }; + await new Promise((resolve) => setTimeout(resolve, 250)); + } + throw new Error(`Schedule did not fire after restart before timeout: ${JSON.stringify(status)}`); +} + // Deploys a suite's app to the Cloudflare account Wrangler is logged in to // and returns its workers.dev URL. async function deployToCloudflare(projectDir) { @@ -359,11 +397,15 @@ async function runSuite(suite, options, scratchDir) { await record("alarm-durability", () => runAlarmCheck(baseUrl, options.alarmDelayMs, options.restartAfterAlarm, restart)); await record("websockets", () => runWebSocketCheck(baseUrl)); if (options.target !== "wrangler") await record("websocket-hibernation", () => runHibernationCheck(baseUrl)); + // Facets exist in workerd and celld 0.6.2; the native engine has no + // ctx.facets yet, so it is the one target that skips this. + if (options.target !== "native") await record("facets", () => runFacetCheck(baseUrl)); // Point-in-time recovery needs the native engine's durable mode (a bucket). if (options.target === "native" && (options.nativeArgs ?? []).includes("durable")) await record("point-in-time-recovery", () => runPitrCheck(baseUrl)); } else { await record("client-protocol", () => runAgentsClientCheck(baseUrl)); await record("schedule-fires", () => runAgentsScheduleCheck(baseUrl)); + if (options.restartAfterAlarm) await record("schedule-across-restart", () => runAgentsScheduleRestartCheck(baseUrl, restart)); } return suite === "core" ? results : results.map((result) => ({ ...result, name: `${suite}/${result.name}` })); } finally { @@ -390,6 +432,7 @@ async function runCloudflareSuite(suite, options, projectDir) { await record("alarm-durability", () => runAlarmCheck(baseUrl, options.alarmDelayMs, false)); await record("websockets", () => runWebSocketCheck(baseUrl)); await record("websocket-hibernation", () => runHibernationCheck(baseUrl, 30_000)); + await record("facets", () => runFacetCheck(baseUrl)); await record("point-in-time-recovery", () => runPitrCheck(baseUrl)); } else { await record("client-protocol", () => runAgentsClientCheck(baseUrl)); diff --git a/packages/conformance/test/soak.test.js b/packages/conformance/test/soak.test.js index f77d314..9585240 100644 --- a/packages/conformance/test/soak.test.js +++ b/packages/conformance/test/soak.test.js @@ -1,7 +1,21 @@ import test from "node:test"; import assert from "node:assert/strict"; +import { readFile } from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; import { LedgerJournal, alarmGaps } from "../soak/journal.js"; +const SOAK_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "soak"); + +test("the soak image requires an explicit SOBJECTS_VERSION", async () => { + const dockerfile = await readFile(path.join(SOAK_DIR, "Dockerfile"), "utf8"); + const arg = /^ARG SOBJECTS_VERSION(.*)$/m.exec(dockerfile); + assert.ok(arg, "the Dockerfile declares ARG SOBJECTS_VERSION"); + // A default would let a bare build silently test an old release. + assert.equal(arg[1].trim(), "", "ARG SOBJECTS_VERSION must not have a default"); + assert.match(dockerfile, /test -n "\$SOBJECTS_VERSION"/, "the build fails when the version is missing"); +}); + test("an acknowledged append that is missing is a violation; unacknowledged ones are not", () => { const journal = new LedgerJournal(); for (let index = 0; index < 5; index += 1) {