From e6be57ce1379e02a6af37509a031134e07c1b27a Mon Sep 17 00:00:00 2001 From: Madraka <8898640+Madraka@users.noreply.github.com> Date: Sun, 29 Nov 2026 10:28:53 +0300 Subject: [PATCH 1/2] build(docker): pin the image's workerd with a lockfile Dependabot bumps weekly (#294) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The image's workerd was a version in a text file, installed with npm and no lockfile: no checksum pin, and nothing could see it to bump it. deploy/docker/workerd is now an npm package of its own, outside the pnpm workspace: package.json pins workerd exactly, package-lock.json holds the SHA-512 of the workerd package and every platform's binary. install.mjs installs it with npm ci --ignore-scripts, checks the platform package is the pinned version and copies its binary. Dependabot bumps it weekly (npm at /deploy/docker/workerd, workerd only), so version and checksums move in one PR; that PR runs docker.yml in full on the new binary: store conformance, the docker, Swarm and Helm smokes, the cluster failover test and Trivy. A scheduled workflow was not used: a PR opened with GITHUB_TOKEN starts no workflows. The Miniflare pin is untouched (ADR-0012). A workerd-no-tcmalloc pin behind the image's version now warns and leaves the fallback out instead of failing the build, so a bump is never blocked by the community build. ADR-0047 records the two pins; RFC-0047 §1 is amended; the guide, the image README and AGENTS.md follow. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com> --- .github/dependabot.yml | 10 +++ .github/workflows/docker.yml | 2 +- AGENTS.md | 2 +- deploy/docker/.dockerignore | 1 + deploy/docker/Dockerfile | 2 +- deploy/docker/README.md | 3 +- deploy/docker/install.mjs | 42 +++++++-- deploy/docker/workerd-no-tcmalloc | 7 +- deploy/docker/workerd-version | 1 - deploy/docker/workerd/package-lock.json | 113 ++++++++++++++++++++++++ deploy/docker/workerd/package.json | 8 ++ docs/adr/0047-image-workerd-pin.md | 30 +++++++ docs/adr/README.md | 1 + docs/guides/self-host.md | 2 + docs/rfcs/0047-self-host-on-workerd.md | 1 + 15 files changed, 208 insertions(+), 17 deletions(-) delete mode 100644 deploy/docker/workerd-version create mode 100644 deploy/docker/workerd/package-lock.json create mode 100644 deploy/docker/workerd/package.json create mode 100644 docs/adr/0047-image-workerd-pin.md diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 001cac71..23b067d4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -24,6 +24,16 @@ updates: # init and analyze must be the same release: CodeQL fails when they differ, so a PR that # bumps one alone can never pass (#270, #272). codeql-action: { patterns: ["github/codeql-action", "github/codeql-action/*"] } + # The self-host image's workerd (ADR-0047): the version and every platform's checksum in one + # weekly PR, which docker.yml gates (store conformance, the docker, Swarm and Helm smokes, the + # cluster failover test). Not the Miniflare pin of the test suites (ADR-0012), which lives in the + # root workspace. + - package-ecosystem: npm + directory: /deploy/docker/workerd + schedule: { interval: weekly } + allow: + - dependency-name: workerd + commit-message: { prefix: "build(docker)" } # The self-host image's base image and the compose file's Caddy (docs/guides/self-host.md). - package-ecosystem: docker directory: /deploy/docker diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 642a9e88..559803b3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,7 +1,7 @@ name: Docker image # The official self-host image, ghcr.io/cloudhal-dev/cloudhal (RFC-0047, docs/guides/self-host.md): -# the release bundle's site and admin Workers on a pinned workerd (deploy/docker/workerd-version), +# the release bundle's site and admin Workers on a pinned workerd (deploy/docker/workerd, bumped weekly by Dependabot: ADR-0047), # a cluster instance on an S3 store. A release image is built from the npm release and the GitHub # release's signed bundle, never from the tree, so it is exactly what was released. # Three jobs, so that no release tag moves before the gates pass (#166): diff --git a/AGENTS.md b/AGENTS.md index 30fe8251..a169893b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -33,7 +33,7 @@ node scripts/release-bundle.ts build|verify … # RFC-0046 release bundle: det - `packages/core-ts` — `SiteGraphStore` (CAS on `rev`, snapshots, diff, publish, rollback). Behavioural suite in `src/testing.ts` runs on sqlite and Miniflare D1. `./local` opens the offline store; `seedStarterSite` seeds a demo. `./surfaces` is RFC-0020's generative UI: the catalog (primitives + block types), eval-free surface checks, bindings, repairs, JSON Patch (`patchPage`), `catalogPrompt`; `./interop` converts A2UI v0.9 and json-render to and from surfaces; `./design` is RFC-0021's DESIGN.md lint and guidance. `./fields` is RFC-0041's typed custom fields (definition and value checks, `resolveFields`, `formatFieldValue`, the agents' JSON Schema, the conversion table); `src/fields-operations/` runs rename/retype/localize/remove. `search.ts` is RFC-0019's FTS5 site search (index written with the publish batch; articles, pages, terms and authors, RFC-0029); `search-provider.ts` is RFC-0029's `SearchProvider` (`fts5`, `memory`, `withFallback`), set with `SiteGraphStoreOptions.search`; `search-ai.ts` is the experimental Cloudflare AI Search provider (`hybridProvider`, `searchProviderFromEnv`, `cloudhal.json` `search`, docs/guides/search.md). - `packages/schedules` — RFC-0008: time model (only `temporal-polyfill/implementation`, `now` injected, never `Temporal.Now`), RRULE subset, release model (`rl1:`), automation/run state, taint and budgets, `runDue`; `./sql` is `SqlScheduleStore`, `./engine` the Temporal-free part core-ts and the site Worker use. Worker-safe; conformance suites in `src/testing.ts` on sqlite and Miniflare D1. - `packages/astro-renderer` — `GraphSource` (live/snapshot), `cloudhal()` integration (virtual config + dev route-cache watcher), `.astro` section components (`Surface.astro` for RFC-0020 surfaces; `./surfaces` renders them, `./kit` has the table of contents and reading time; `./fields` and `EntryFields.astro` render typed field values, RFC-0041). `./status-page` is RFC-0043's status pages (`statusPage(state, input) → Response`, served by the Site Worker entry before Astro and by `cloudhal dev` at `/__cloudhal/status/`; the optional `statusPage` theme hook; the catalog in `src/status-strings/` where only `en.ts` is hand-edited and the other languages come from `pnpm i18n:import`). Routes live in starters, not here. -- `packages/cli` — the `cloudhal` CLI (`init`, `dev`, `studio`, `mcp`, `deploy`, `push`, `pull`, `export`, `import`, …; every command is in `src/cli/help.ts`, which `cloudhal --help` prints and the docs site's CLI reference is generated from); TS bin run by Node 24 type stripping. `src/cli.ts` parses flags and dispatches through `COMMANDS`, built from `src/cli/commands-{local,remote,content,ops,site}.ts` (a new command is one handler plus one line in `src/cli/help.ts`). `src/archive/` is RFC-0039's `.cloudhal` container (tar, gzip, manifest, limits), read and written by `src/commands/export.ts` and `import*.ts` (`archive-bundle.ts`, `archive-reassemble.ts`); the starter demo archive `test/fixtures/site-archives/starter-blog.cloudhal` is written by `pnpm demo:archive`, and `pnpm check` fails when it is stale. E2E test spawns the bin (Astro disables dev middleware under `VITEST`). Cloudflare tests run both Workers on workerd via wrangler's `createTestHarness`; test files run serially (shared starter caches). `src/commands/deploy/release/` is RFC-0046 §11b's `deploy --release`: the signed key and yank lists (`trust.ts`, the yank memory in `~/.cloudhal/release-trust.json`), the release lookup and download, the theme check against the CLI's starter (`theme-check.ts`; recheck its build-input list on every Astro or Vite major), the build keys of `src/config-build-keys.ts`, extraction and the `no_bundle` wrangler configs; tests use `@cloudhal/release-verify`'s synthetic bundle (`test/fixtures/release-deploy.ts`), never the network. `src/selfhost/` is RFC-0047's self-host image on workerd (`cloudhal selfhost fetch|check|config|secrets|start`): the settings (`_FILE` secrets), the generated Cap'n Proto config (Durable Object `uniqueKey`s are constants, never change them), the bundle check, the Node-volume guard and the first site; `deploy/docker/workerd-version` pins workerd, `scripts/docker-smoke.ts` runs it on SeaweedFS. +- `packages/cli` — the `cloudhal` CLI (`init`, `dev`, `studio`, `mcp`, `deploy`, `push`, `pull`, `export`, `import`, …; every command is in `src/cli/help.ts`, which `cloudhal --help` prints and the docs site's CLI reference is generated from); TS bin run by Node 24 type stripping. `src/cli.ts` parses flags and dispatches through `COMMANDS`, built from `src/cli/commands-{local,remote,content,ops,site}.ts` (a new command is one handler plus one line in `src/cli/help.ts`). `src/archive/` is RFC-0039's `.cloudhal` container (tar, gzip, manifest, limits), read and written by `src/commands/export.ts` and `import*.ts` (`archive-bundle.ts`, `archive-reassemble.ts`); the starter demo archive `test/fixtures/site-archives/starter-blog.cloudhal` is written by `pnpm demo:archive`, and `pnpm check` fails when it is stale. E2E test spawns the bin (Astro disables dev middleware under `VITEST`). Cloudflare tests run both Workers on workerd via wrangler's `createTestHarness`; test files run serially (shared starter caches). `src/commands/deploy/release/` is RFC-0046 §11b's `deploy --release`: the signed key and yank lists (`trust.ts`, the yank memory in `~/.cloudhal/release-trust.json`), the release lookup and download, the theme check against the CLI's starter (`theme-check.ts`; recheck its build-input list on every Astro or Vite major), the build keys of `src/config-build-keys.ts`, extraction and the `no_bundle` wrangler configs; tests use `@cloudhal/release-verify`'s synthetic bundle (`test/fixtures/release-deploy.ts`), never the network. `src/selfhost/` is RFC-0047's self-host image on workerd (`cloudhal selfhost fetch|check|config|secrets|start`): the settings (`_FILE` secrets), the generated Cap'n Proto config (Durable Object `uniqueKey`s are constants, never change them), the bundle check, the Node-volume guard and the first site; `deploy/docker/workerd/` pins workerd (an npm lockfile Dependabot bumps weekly, ADR-0047; never the Miniflare pin), `scripts/docker-smoke.ts` runs it on SeaweedFS. - `packages/cloudflare` — the admin Worker (`createAdminWorker`); `./playground` is RFC-0036's playground Worker (`createPlaygroundWorker`, the `PlaygroundSite` Durable Object, signed session cookies). Generated entries must import `@cloudhal/cloudflare/workerd-prelude` first (ADR-0012). - `packages/agent-runtime` / `packages/mcp-server` — policy, skills, audit; MCP tools and transports (ADR-0011). `@cloudhal/mcp-server/render` is RFC-0021's `render_page` core: a small DevTools client, the in-page checks and limits; the CLI drives local Chrome with it (`render-chrome.ts`), the admin Worker Browser Rendering (`browser-render.ts`). - `starters/blog` — the theme boundary: `src/pages/[...path].astro`, `src/layouts`, `src/theme.ts`. diff --git a/deploy/docker/.dockerignore b/deploy/docker/.dockerignore index b295947a..d8fdcf21 100644 --- a/deploy/docker/.dockerignore +++ b/deploy/docker/.dockerignore @@ -6,3 +6,4 @@ Caddyfile .env.example .env .DS_Store +workerd/node_modules diff --git a/deploy/docker/Dockerfile b/deploy/docker/Dockerfile index cdca39fc..ff396b74 100644 --- a/deploy/docker/Dockerfile +++ b/deploy/docker/Dockerfile @@ -8,7 +8,7 @@ # # Built from the npm release and the GitHub release's signed bundle (`CLOUDHAL_VERSION`), or for # the nightly `edge` tag from packed tarballs in `tarballs/` and this ref's bundle in `bundle/` -# (.github/workflows/docker.yml). workerd's version is pinned in `workerd-version`. +# (.github/workflows/docker.yml). workerd is pinned, with every platform's checksum, in `workerd/` (ADR-0047). FROM node:24-bookworm-slim AS build ARG CLOUDHAL_VERSION="" diff --git a/deploy/docker/README.md b/deploy/docker/README.md index 774f2be2..c1e1763a 100644 --- a/deploy/docker/README.md +++ b/deploy/docker/README.md @@ -2,11 +2,12 @@ The official self-host image, `ghcr.io/cloudhal-dev/cloudhal`, built from each release ([RFC-0047](../../docs/rfcs/0047-self-host-on-workerd.md)). It runs the release bundle's site and admin Workers on a pinned workerd, as a cluster instance whose state lives in an S3 store. The guide is [docs/guides/self-host.md](../../docs/guides/self-host.md); this folder holds what it refers to: -- **`Dockerfile`:** two stages. The build stage (`node:24-bookworm-slim`) runs `install.mjs`, which installs `@cloudhal/cli` and workerd (`workerd-version`) and lays out the runtime. The final stage is `debian:bookworm-slim` with that runtime only: the `node` binary, the compiled `selfhost` entry (Node built-ins only), the workerd binary and the bundle. It is about 410 MB on disk and 135 MB to download. +- **`Dockerfile`:** two stages. The build stage (`node:24-bookworm-slim`) runs `install.mjs`, which installs `@cloudhal/cli` and workerd and lays out the runtime. The final stage is `debian:bookworm-slim` with that runtime only: the `node` binary, the compiled `selfhost` entry (Node built-ins only), the workerd binary and the bundle. It is about 410 MB on disk and 135 MB to download. - On linux-arm64, `workerd-no-tcmalloc` can pin a community build of workerd without tcmalloc, for 39-bit kernels such as Raspberry Pi OS's 4 KiB ones. The build checks its SHA-256, and the entrypoint takes it only where the official binary cannot start. - The release bundle lives under `/opt/cloudhal/bundle`. For a release it is downloaded and verified by `cloudhal selfhost fetch`; for edge it comes from `bundle/` (scripts/selfhost-edge-bundle.ts). - Runs as non-root with a read-only root, and `/data` and `/tmp` are the only writable paths. - Ports 8787 (Studio, the API, `/mcp`), 8788 (the site) and 7000 (the cluster). +- **`workerd/`:** the image's workerd, an npm package of its own. `package.json` pins the version, and `package-lock.json` holds the SHA-512 of every platform's binary, which `npm ci` checks at build. Dependabot bumps both weekly, and `docker.yml` gates the PR on the new binary (ADR-0047). It is separate from the Miniflare pin the test suites use (ADR-0012). - **`bin/entrypoint`:** `cloudhal-selfhost start` by default; `secrets`, `config` and `check` are the other `cloudhal-selfhost` commands (`bin/cloudhal-selfhost`). The CLI itself is not in the image. `start` does these steps: 1. reads the settings (`_FILE` secrets too); 2. refuses a volume of the Node image; diff --git a/deploy/docker/install.mjs b/deploy/docker/install.mjs index dd7e5fd4..f5367c91 100644 --- a/deploy/docker/install.mjs +++ b/deploy/docker/install.mjs @@ -1,6 +1,8 @@ /** - * The image's build stage (Dockerfile, RFC-0047 §9). It installs `@cloudhal/cli` and the pinned - * workerd with plain npm (npm checks each package against the registry's integrity hash), puts the + * The image's build stage (Dockerfile, RFC-0047 §9). It installs `@cloudhal/cli` with plain npm and + * the pinned workerd with `npm ci` from `workerd/package-lock.json`, which holds the SHA-512 of + * every platform's package (ADR-0047: Dependabot bumps the version and the checksums together, and + * npm refuses a tarball that does not match). It puts the * release bundle of the image's version under `/runtime/bundle` and checks it file by * file, then lays out `/runtime`, the only thing the last stage copies: * @@ -26,7 +28,11 @@ import path from "node:path"; const [ctx = "/ctx", target = "/opt/cloudhal"] = process.argv.slice(2); const version = process.env.CLOUDHAL_VERSION?.trim() || undefined; -const workerd = readFileSync(path.join(ctx, "workerd-version"), "utf8").trim(); +const workerdDir = path.join(ctx, "workerd"); +const workerd = JSON.parse(readFileSync(path.join(workerdDir, "package.json"), "utf8")).dependencies + .workerd; +if (!/^\d+\.\d{8}\.\d+$/.test(workerd)) + throw new Error(`workerd/package.json must pin an exact workerd version (got ${workerd})`); const index = path.join(ctx, "tarballs", "index.json"); const runtime = path.join(target, "runtime"); @@ -47,7 +53,7 @@ function specs() { } const all = specs(); -const dependencies = { "@cloudhal/cli": all["@cloudhal/cli"], workerd }; +const dependencies = { "@cloudhal/cli": all["@cloudhal/cli"] }; const overrides = Object.fromEntries( Object.entries(all).filter(([name]) => !(name in dependencies)), ); @@ -94,12 +100,26 @@ cpSync(path.join(target, "node_modules/@cloudhal/cli/dist/src/selfhost"), selfho }); writeFileSync(path.join(selfhost, "package.json"), '{ "type": "module" }\n'); -// 3. workerd: the platform binary itself, not npm's launcher +// 3. workerd: the platform binary itself, not npm's launcher, installed from the lockfile (its +// integrity hashes are the checksum pin; no install scripts run) const platform = { x64: "linux-64", arm64: "linux-arm64" }[process.arch]; if (!platform) throw new Error(`workerd has no Linux build for ${process.arch}`); +execFileSync( + "npm", + ["ci", "--omit=dev", "--ignore-scripts", "--no-audit", "--no-fund", "--loglevel=error"], + { cwd: workerdDir, stdio: "inherit" }, +); +const installed = JSON.parse( + readFileSync( + path.join(workerdDir, `node_modules/@cloudflare/workerd-${platform}/package.json`), + "utf8", + ), +).version; +if (installed !== workerd) + throw new Error(`workerd/package-lock.json installs ${installed}, package.json pins ${workerd}`); mkdirSync(path.join(runtime, "bin"), { recursive: true }); cpSync( - path.join(target, `node_modules/@cloudflare/workerd-${platform}/bin/workerd`), + path.join(workerdDir, `node_modules/@cloudflare/workerd-${platform}/bin/workerd`), path.join(runtime, "bin/workerd"), ); chmodSync(path.join(runtime, "bin/workerd"), 0o755); @@ -111,9 +131,13 @@ const pin = Object.fromEntries( .filter((l) => l.includes("=") && !l.startsWith("#")) .map((l) => [l.slice(0, l.indexOf("=")).trim(), l.slice(l.indexOf("=") + 1).trim()]), ); -if (process.arch === "arm64" && pin.version) { - if (pin.version !== workerd) - throw new Error(`workerd-no-tcmalloc pins ${pin.version}, but workerd-version is ${workerd}`); +// A weekly workerd bump (ADR-0047) does not wait for the community build: until one of the new +// version is pinned, the arm64 image carries no fallback, and a 39-bit kernel gets the message. +if (process.arch === "arm64" && pin.version && pin.version !== workerd) + console.warn( + `warning: workerd-no-tcmalloc pins ${pin.version}, not workerd ${workerd}: no fallback for 39-bit kernels in this image`, + ); +else if (process.arch === "arm64" && pin.version) { if (!/^[0-9a-f]{64}$/.test(pin.sha256 ?? "") || !pin.url?.startsWith("https://")) throw new Error("workerd-no-tcmalloc: version, sha256 and an https url are all required"); const res = await fetch(pin.url); diff --git a/deploy/docker/workerd-no-tcmalloc b/deploy/docker/workerd-no-tcmalloc index 0e47985e..faad6b6c 100644 --- a/deploy/docker/workerd-no-tcmalloc +++ b/deploy/docker/workerd-no-tcmalloc @@ -1,9 +1,10 @@ # The tcmalloc-free linux-arm64 workerd for 39-bit kernels (Raspberry Pi OS's 4 KiB kernels; # cloudflare/workerd#5020), from the community builds at github.com/pdragun/workerd-no-tcmalloc # (upstream source, `use_tcmalloc=False`). Used only where the official build cannot start, and -# only when its version equals workerd-version. Fill in all three lines when that release exists: -# the SHA-256 is checked at image build. Empty: the arm64 image carries no fallback, and a 39-bit -# kernel gets a message saying what to do. +# only when its version equals the image's workerd (workerd/package.json). Fill in all three lines +# when that release exists: the SHA-256 is checked at image build. Empty, or behind a weekly bump +# (ADR-0047): the arm64 image carries no fallback, and a 39-bit kernel gets a message saying what to +# do. version= sha256= url= diff --git a/deploy/docker/workerd-version b/deploy/docker/workerd-version deleted file mode 100644 index 826a4233..00000000 --- a/deploy/docker/workerd-version +++ /dev/null @@ -1 +0,0 @@ -1.20261122.2 diff --git a/deploy/docker/workerd/package-lock.json b/deploy/docker/workerd/package-lock.json new file mode 100644 index 00000000..8fd8bc55 --- /dev/null +++ b/deploy/docker/workerd/package-lock.json @@ -0,0 +1,113 @@ +{ + "name": "cloudhal-image-workerd", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "cloudhal-image-workerd", + "dependencies": { + "workerd": "1.20261122.2" + } + }, + "node_modules/@cloudflare/workerd-darwin-64": { + "version": "1.20261122.2", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20261122.2.tgz", + "integrity": "sha512-GcFbPmGweClEAGaeYKWn7kfpxxfqVVk9JPB83FzhskWNkjFKqwIN8EyTBNT1BeJWhjLXgj8cb6x7wQ3Oof2yBg==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-darwin-arm64": { + "version": "1.20261122.2", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20261122.2.tgz", + "integrity": "sha512-YMt0F9GUkhIMb++J+74Nn8S65Kid7+e7Xqqux1MYr8EM4CtYwmr74II1UnQ3b9KB98mvSHsnf6YMeuhJnxNX7g==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-64": { + "version": "1.20261122.2", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20261122.2.tgz", + "integrity": "sha512-c/EZvY2rYZkpv2+EfgeX0Q+tphdfi7EElprr3fMd2WI1B7G3ar9446nGwPBTFbJpfZbBUe9abLQv1Ez26ITzaQ==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-arm64": { + "version": "1.20261122.2", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20261122.2.tgz", + "integrity": "sha512-rflDpZqTdgzlvfY7KNyavxI5MQd3SOrwb2g6sMLZ7NFWjnEI6Ok+0mSTFA1UyEsjFidICWxwc6BjgXWbr5wQ9w==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-windows-64": { + "version": "1.20261122.2", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20261122.2.tgz", + "integrity": "sha512-p6VxvEgU+RirJrf9KeMOumvNXJ0/Ft726lW7vmUT+xekSTlv59DPSBDpwSc5kNXh49GzceCSO8OqKWZyxBv1Ew==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/workerd": { + "version": "1.20261122.2", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20261122.2.tgz", + "integrity": "sha512-OQf39kdnmUAoq/BTLVsXb2n5NlQoIIzbCPiO55xLBdAbOdtckIrjnouzTDw9GvnVsH6eBateHFrntbht7hQKRQ==", + "hasInstallScript": true, + "license": "Apache-2.0", + "bin": { + "workerd": "bin/workerd" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "@cloudflare/workerd-darwin-64": "1.20261122.2", + "@cloudflare/workerd-darwin-arm64": "1.20261122.2", + "@cloudflare/workerd-linux-64": "1.20261122.2", + "@cloudflare/workerd-linux-arm64": "1.20261122.2", + "@cloudflare/workerd-windows-64": "1.20261122.2" + } + } + } +} diff --git a/deploy/docker/workerd/package.json b/deploy/docker/workerd/package.json new file mode 100644 index 00000000..86393d0f --- /dev/null +++ b/deploy/docker/workerd/package.json @@ -0,0 +1,8 @@ +{ + "name": "cloudhal-image-workerd", + "private": true, + "description": "The self-host image's workerd (RFC-0047 §1, ADR-0047). Dependabot bumps it weekly; package-lock.json holds the checksum of every platform's binary. Never the Miniflare pin (ADR-0012).", + "dependencies": { + "workerd": "1.20261122.2" + } +} diff --git a/docs/adr/0047-image-workerd-pin.md b/docs/adr/0047-image-workerd-pin.md new file mode 100644 index 00000000..c4256833 --- /dev/null +++ b/docs/adr/0047-image-workerd-pin.md @@ -0,0 +1,30 @@ +# ADR-0047: The self-host image's workerd pin: an npm lockfile that Dependabot bumps weekly, gated on the image's smokes +- Status: Accepted +- Date: 2026-11-29 (#294; RFC-0047 §1 and §11, accepted 2026-11-23) +- Related: RFC-0047, ADR-0012 (the Miniflare 4 pin of the test suites), #290 (the cluster failover test), #263 +- Sources: [Dependabot options: `package-ecosystem`, `directory`, `allow`](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference) · [Triggering a workflow from a workflow: events made with `GITHUB_TOKEN` start no new runs](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/triggering-a-workflow#triggering-a-workflow-from-a-workflow) · [`npm ci`](https://docs.npmjs.com/cli/v11/commands/npm-ci) · [package-lock.json `integrity`](https://docs.npmjs.com/cli/v11/configuring-npm/package-lock-json) + +## Context +Cloudhal has two workerd pins, and they move for different reasons. +- **The test suites** run workerd through Miniflare 4.20260730.0. That pin is patched (#190) and stays until Miniflare 5 is stable (ADR-0012). +- **The self-host image** runs a workerd of its own (RFC-0047 §1). The cluster, D1, R2-on-S3 and OTLP features it needs are weeks old, so it has to follow workerd closely. RFC-0047 §11 asks for a weekly bump that lands only when the store conformance suite and the cluster smoke pass on the new binary. + +Until now the image's pin was a text file (`deploy/docker/workerd-version`). The build installed that version with `npm install` and no lockfile, so the binary was checked against whatever the registry answered that day, and no tool could see the pin to bump it. + +## Decision +1. **The pin is an npm package of its own:** `deploy/docker/workerd/package.json`, which depends on exactly one `workerd` version, plus its `package-lock.json`. + - The lockfile holds the SHA-512 `integrity` of the `workerd` package and of every platform's binary package (`@cloudflare/workerd-linux-64`, `-linux-arm64`, …). + - It is outside the pnpm workspace, so the monorepo's lockfile and its Miniflare pin never see it. +2. **The image installs from that lockfile.** `install.mjs` runs `npm ci --ignore-scripts` there, so npm refuses a tarball whose hash differs. It then checks that the installed platform package is the pinned version, and copies that platform's binary. +3. **Dependabot bumps it weekly.** An `npm` entry for `/deploy/docker/workerd` in `.github/dependabot.yml` allows only `workerd`. Each PR updates the version and every checksum together, in one commit. + - **Why not a scheduled workflow.** A PR it opens with `GITHUB_TOKEN` starts no workflows, so the gates would never run. Using an App or a personal token instead means a long-lived write credential for one file. Dependabot's PRs run CI like any other. +4. **The gate is `docker.yml` on the PR.** The PR touches `deploy/docker/**`, so it runs the full image build: store conformance (SeaweedFS, RustFS), the docker, Swarm and Helm (kind) smokes, the cluster failover test (#290) and Trivy, all on the new binary. + - A bump is merged only when that run is green. + - `main` has no ruleset today. Making "Build edge" a required check is an owner setting; until then, the PM merges. +5. **The Miniflare pin is untouched.** The root `npm` entry is unchanged, and ADR-0012's upgrade recipe still governs Miniflare. +6. **The tcmalloc-free arm64 build follows when it can.** `workerd-no-tcmalloc` is used only when its version equals the image's workerd. When a bump outruns the community build, the build warns and the arm64 image carries no fallback until a matching build is pinned. 39-bit kernels then get the message that says what to do. Before this change the build failed instead, which would have blocked every bump. + +## Consequences +- The image's workerd has a checksum pin for every platform, and it is reviewed in the same diff as the version. +- One Dependabot PR a week at most, and each one runs the image's whole gate (about 30–40 minutes of CI). +- A bump that breaks the cluster shows up as a red failover or smoke step on its own PR, never on `main`. diff --git a/docs/adr/README.md b/docs/adr/README.md index d48ae96e..b4480a19 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -63,3 +63,4 @@ One file per decision, numbered, immutable once accepted (write a new ADR to sup | [0044](0044-collections-stage-3.md) | Collections stage 3: JSON-LD presets (Event, JobPosting, Product, Recipe) mapped from fields through a closed table, expiry as a render-time gate (`unlist`/`hide`, no automation), listings filtered and sorted by field with one shared evaluator and no indexes yet, listing pages as ordinary pages and per-collection feeds through a middleware (RFC-0042) | | [0045](0045-mcp-authorization-server.md) | MCP authorization server: Better Auth `mcp()` + `jwt()` on the Studio database, issuer `/api/auth`, Ed25519 JWT access tokens (1 h, `aud` = `/mcp`) verified locally plus one `agent_grants` read per call, refresh rotation with a 30 s reuse window, consent on Studio's screen narrowed by the installation role, a token resolves to the same `Principal` as a key; no AS without a stable public origin (RFC-0044 Phase 2) | | [0046](0046-references-and-repeaters.md) | Collections stage 4: `reference` fields store a translation group id resolved per site and locale, `repeater` fields hold up to 50 flat items; an `entry_refs` index written in each entry's batch guards deletes, moves and group changes only while a published entry shows the reference, with every race closed by batch-time anchors and guards (RFC-0045) | +| [0047](0047-image-workerd-pin.md) | The self-host image's workerd: an npm package of its own in `deploy/docker/workerd` whose lockfile pins every platform's SHA-512, installed with `npm ci`; Dependabot bumps version and checksums weekly, gated by `docker.yml` (conformance, the docker, Swarm and Helm smokes, the failover test); never the Miniflare pin (RFC-0047 §1, §11) | diff --git a/docs/guides/self-host.md b/docs/guides/self-host.md index 98834613..7f8a44fa 100644 --- a/docs/guides/self-host.md +++ b/docs/guides/self-host.md @@ -176,6 +176,8 @@ docker compose pull && docker compose up -d Database migrations run when the admin Worker starts. With several instances, restart them one at a time. +The image's workerd is pinned with a checksum for each platform (`deploy/docker/workerd`). A weekly Dependabot PR moves it to the newest workerd. That PR merges only after the store conformance suite, the docker, Swarm and Helm smokes and the cluster failover test pass on the new binary (ADR-0047), so a release carries a workerd that passed all of them. + **From the Node image (0.10.x and older).** That image ran `cloudhal studio` on Node and a static site. The workerd image cannot open its volume, and it refuses to start on one. It names the way out: export the site with the old image, start the new stack on new volumes, and import the archive. ```bash diff --git a/docs/rfcs/0047-self-host-on-workerd.md b/docs/rfcs/0047-self-host-on-workerd.md index d29ad0bc..0262cdaf 100644 --- a/docs/rfcs/0047-self-host-on-workerd.md +++ b/docs/rfcs/0047-self-host-on-workerd.md @@ -49,6 +49,7 @@ The self-host image stops running `cloudhal studio` on Node and a static site re ### 1. Runtime - **The workerd binary.** One pinned build, `workerd@1.YYYYMMDD.N` from npm with its SHA-256 checked at image build. It is separate from the Miniflare 4 pin the test suites use (ADR-0012 addendum). An ADR records the two pins. + - *Amended 2026-11-29 (#294, ADR-0047):* the pin is `deploy/docker/workerd/package.json` with its `package-lock.json`. The lockfile holds every platform package's SHA-512, and the image installs it with `npm ci`. Dependabot bumps the version and the checksums together, weekly (§11). - **Config format.** workerd runs a generated Cap'n Proto config with `--experimental`. `wrangler.json` is not enough: in this release its fields are `$schema`, `name`, `main`, `compatibility_date`, `compatibility_flags`, `vars`, `durable_objects`, `exports`, `migrations` and `no_bundle`, plus `kv_namespaces`, `queues`, `triggers`, `workflows`, `d1_databases` and `assets` behind `--experimental`. There are no R2 buckets, no service bindings and no second Worker, and the admin Worker needs all three. - **The config generator** lives in `@cloudhal/cli` (`src/selfhost/workerd-config.ts`). It reads the bundle's `manifest.json` (`bindingTemplates`, `durableObjects`, `runtime`, `workers.*.modules`, `workers.admin.assets.config`) and the environment (§4), so the Cloudflare configs and the workerd config come from one description of the bindings. A test pins the generated config for the starter bundle. From f587c45b8df611676a9c7e0c680e30df3cfdeeb8 Mon Sep 17 00:00:00 2001 From: Madraka <8898640+Madraka@users.noreply.github.com> Date: Sun, 29 Nov 2026 10:29:55 +0300 Subject: [PATCH 2/2] docs(adr): ADR-0047 states why Build edge is not a required check Co-Authored-By: Claude Opus 5.5 Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com> --- docs/adr/0047-image-workerd-pin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/adr/0047-image-workerd-pin.md b/docs/adr/0047-image-workerd-pin.md index c4256833..d12fa5ef 100644 --- a/docs/adr/0047-image-workerd-pin.md +++ b/docs/adr/0047-image-workerd-pin.md @@ -20,7 +20,7 @@ Until now the image's pin was a text file (`deploy/docker/workerd-version`). The - **Why not a scheduled workflow.** A PR it opens with `GITHUB_TOKEN` starts no workflows, so the gates would never run. Using an App or a personal token instead means a long-lived write credential for one file. Dependabot's PRs run CI like any other. 4. **The gate is `docker.yml` on the PR.** The PR touches `deploy/docker/**`, so it runs the full image build: store conformance (SeaweedFS, RustFS), the docker, Swarm and Helm (kind) smokes, the cluster failover test (#290) and Trivy, all on the new binary. - A bump is merged only when that run is green. - - `main` has no ruleset today. Making "Build edge" a required check is an owner setting; until then, the PM merges. + - "Build edge" is deliberately not a required check of `main`'s ruleset. docker.yml runs only on PRs that touch its paths, and a required check that never reports would block every other PR. Bumps follow the same rule as every image PR: they merge on a green Build edge. 5. **The Miniflare pin is untouched.** The root `npm` entry is unchanged, and ADR-0012's upgrade recipe still governs Miniflare. 6. **The tcmalloc-free arm64 build follows when it can.** `workerd-no-tcmalloc` is used only when its version equals the image's workerd. When a bump outruns the community build, the build warns and the arm64 image carries no fallback until a matching build is pinned. 39-bit kernels then get the message that says what to do. Before this change the build failed instead, which would have blocked every bump.