From fd496b46a97c30f6d537f1a28dfe6e18cd9ee3af Mon Sep 17 00:00:00 2001 From: Madraka <8898640+Madraka@users.noreply.github.com> Date: Sun, 29 Nov 2026 14:17:46 +0300 Subject: [PATCH 1/2] feat(cli): RFC-0048 step 5, agent upload links on every host - CLOUDHAL_UPLOAD_SECRET: generated by `cloudhal deploy` into the 0600 secrets file and given to the admin Worker; the release manifest's SecretName gains it (additive contract change, TS and Rust regenerated, fixtures and the schema fingerprint updated). Optional on self-host (`_FILE`, generated by `selfhost secrets`, empty when unset so the preview secret signs; too short stops the image). - cloudhal.json media.agentUploads / media.agentUploadBytes (config-media.ts; deploy keys in the release key table) become the admin Worker's CLOUDHAL_AGENT_UPLOADS / CLOUDHAL_AGENT_UPLOAD_BYTES, passed through on self-host and read by `cloudhal studio`. - Studio Activity labels create_upload, complete_upload and asset.upload-received in every language (en by hand, the rest imported as drafts awaiting review). - docs/guides/agent-uploads.md (flow, settings, secret and rotation, proxy access logs and wrangler tail, body limits); self-host guide, Cloudflare README and the threat model's agent-upload rows updated (now mitigated); RFC-0048 implementation notes for step 5 (the eval task does not fit the Build eval and is left out). - Size baseline tightened (admin-worker, elevationTools, runTool). Refs #250 Co-Authored-By: Claude Opus 5.5 Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com> --- .changeset/rfc48-step5-hosts.md | 18 ++ apps/studio/src/i18n/ar.ts | 5 +- apps/studio/src/i18n/de.ts | 5 +- apps/studio/src/i18n/en.ts | 3 + apps/studio/src/i18n/es.ts | 5 +- apps/studio/src/i18n/fa.ts | 5 +- apps/studio/src/i18n/fr.ts | 5 +- apps/studio/src/i18n/he.ts | 5 +- apps/studio/src/i18n/hi.ts | 5 +- apps/studio/src/i18n/id.ts | 5 +- apps/studio/src/i18n/it.ts | 5 +- apps/studio/src/i18n/ja.ts | 5 +- apps/studio/src/i18n/ko.ts | 5 +- apps/studio/src/i18n/nl.ts | 5 +- apps/studio/src/i18n/pl.ts | 5 +- apps/studio/src/i18n/pt-BR.ts | 5 +- apps/studio/src/i18n/ru.ts | 5 +- apps/studio/src/i18n/tr.ts | 5 +- apps/studio/src/i18n/uk.ts | 5 +- apps/studio/src/i18n/zh-Hans.ts | 5 +- apps/studio/src/lib/activity.ts | 5 + .../src/generated/release_manifest.rs | 4 + deploy/docker/compose.yml | 2 + docs/guides/agent-uploads.md | 74 +++++++ docs/guides/self-host.md | 2 + docs/rfcs/0048-signed-agent-uploads.md | 7 + docs/security/threat-model.md | 8 +- packages/cli/src/cloudflare/admin.ts | 4 + packages/cli/src/cloudflare/config.ts | 6 + .../cli/src/commands/deploy/release/index.ts | 4 + packages/cli/src/commands/deploy/state.ts | 3 + packages/cli/src/commands/studio.ts | 3 +- packages/cli/src/config-build-keys.ts | 5 + packages/cli/src/config-media.ts | 58 ++++++ packages/cli/src/selfhost/secrets.ts | 4 +- packages/cli/src/selfhost/settings.ts | 22 +- packages/cli/test/config-media.test.ts | 65 ++++++ .../cli/test/deploy-workers-builds.test.ts | 1 + packages/cli/test/deploy.test.ts | 2 + packages/cli/test/selfhost.test.ts | 19 ++ packages/cloudflare/README.md | 2 + packages/cloudflare/src/admin-worker.ts | 6 +- packages/cloudflare/src/agent-uploads.ts | 28 +++ .../cloudflare/test/agent-uploads.test.ts | 15 ++ .../release-manifest/secret-name-unknown.json | 194 ++++++++++++++++++ .../release-manifest/admin-upload-secret.json | 191 +++++++++++++++++ .../schemas/release-manifest.schema.json | 3 +- .../src/generated/release-manifest.ts | 3 +- .../core-contracts/src/generated/schemas.ts | 3 +- .../src/generated/validators.js | 6 +- .../test/release-schemas.test.ts | 2 +- .../src/generated/release-manifest.ts | 3 +- .../src/generated/validators.js | 6 +- scripts/release-bundle/standard.ts | 1 + scripts/size-baseline.json | 8 +- 55 files changed, 838 insertions(+), 42 deletions(-) create mode 100644 .changeset/rfc48-step5-hosts.md create mode 100644 docs/guides/agent-uploads.md create mode 100644 packages/cli/src/config-media.ts create mode 100644 packages/cli/test/config-media.test.ts create mode 100644 packages/cloudflare/src/agent-uploads.ts create mode 100644 packages/cloudflare/test/agent-uploads.test.ts create mode 100644 packages/core-contracts/fixtures/invalid/release-manifest/secret-name-unknown.json create mode 100644 packages/core-contracts/fixtures/valid/release-manifest/admin-upload-secret.json diff --git a/.changeset/rfc48-step5-hosts.md b/.changeset/rfc48-step5-hosts.md new file mode 100644 index 00000000..42683602 --- /dev/null +++ b/.changeset/rfc48-step5-hosts.md @@ -0,0 +1,18 @@ +--- +"@cloudhal/core-contracts": minor +"@cloudhal/release-verify": patch +"@cloudhal/cli": minor +"@cloudhal/cloudflare": patch +--- + +RFC-0048 rollout step 5 finishes agents' signed upload links on every host. + +- **`CLOUDHAL_UPLOAD_SECRET`:** + - `cloudhal deploy` generates it once into `.cloudhal/deploy/secrets.json` (0600) and gives it to the admin Worker. It signs upload tickets and agents' upload links ahead of the preview secret, so it can rotate on its own. + - The release manifest's `SecretName` gains it, an additive contract change. + - On self-host it is optional, with `_FILE` supported. `cloudhal selfhost secrets` generates it for new installations; when unset, the preview secret signs; a value shorter than 32 characters stops the image at start. The compose file passes it through. +- **`cloudhal.json` `media.agentUploads: false`** turns the links off, and **`media.agentUploadBytes`** caps a file (25 MB by default, at most 100 MB). + - They become the admin Worker's vars `CLOUDHAL_AGENT_UPLOADS` and `CLOUDHAL_AGENT_UPLOAD_BYTES`. Self-host takes the same vars from its environment, and `cloudhal studio` reads them from the project. + - The release key table classes both as `deploy` keys, so `deploy --release` accepts any value. +- **Studio's Activity** labels `create_upload`, `complete_upload` and `asset.upload-received` in every language. Languages other than English are drafts awaiting review. +- **A guide**, `docs/guides/agent-uploads.md`, covers the flow, the settings, the secret and its rotation, keeping `?sig=` out of proxy access logs and `wrangler tail`, and body size limits. The self-host guide and the threat model now list the new settings and the mitigations. diff --git a/apps/studio/src/i18n/ar.ts b/apps/studio/src/i18n/ar.ts index edc7a967..e71c452c 100644 --- a/apps/studio/src/i18n/ar.ts +++ b/apps/studio/src/i18n/ar.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): ar core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 932d5c2ff7cb089d +// hash: a70edc6c7418610d import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1721,6 +1721,8 @@ export const messages: Messages = { retire_asset: "استبعد وسائط", restore_asset: "استعد وسائط", delete_asset: "احذف وسائط", + create_upload: "أنشئ رابط رفع", + complete_upload: "أكمل الرفع", assetUpload: "رفع ملف", assetUpdate: "تحديث تفاصيل ملف", assetRetire: "استبعاد ملف", @@ -1728,6 +1730,7 @@ export const messages: Messages = { assetDelete: "حذف ملف", assetPurge: "إزالة ملف نهائيًا", assetLiftPurge: "السماح بملف مجددًا", + assetUploadReceived: "استلام ملف رفعه وكيل", siteBuild: "بناء الموقع العام", list_sites: "اسرد المواقع", get_site: "احصل على موقع", diff --git a/apps/studio/src/i18n/de.ts b/apps/studio/src/i18n/de.ts index 62ea5547..70c4fca4 100644 --- a/apps/studio/src/i18n/de.ts +++ b/apps/studio/src/i18n/de.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): de core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 9ffa8eada36b8bde +// hash: 47220dd1907aa318 import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1812,6 +1812,8 @@ export const messages: Messages = { retire_asset: "Medien ausmustern", restore_asset: "Medien wiederherstellen", delete_asset: "Medien löschen", + create_upload: "Upload-Link erstellen", + complete_upload: "Upload abschließen", assetUpload: "Datei hochladen", assetUpdate: "Dateidetails aktualisieren", assetRetire: "Datei ausmustern", @@ -1819,6 +1821,7 @@ export const messages: Messages = { assetDelete: "Datei löschen", assetPurge: "Datei entfernen", assetLiftPurge: "Datei wieder zulassen", + assetUploadReceived: "Upload eines Agenten empfangen", siteBuild: "Öffentliche Website bauen", list_sites: "Websites auflisten", get_site: "Website abrufen", diff --git a/apps/studio/src/i18n/en.ts b/apps/studio/src/i18n/en.ts index d10fca2d..2a6e22ca 100644 --- a/apps/studio/src/i18n/en.ts +++ b/apps/studio/src/i18n/en.ts @@ -1690,6 +1690,8 @@ export const en = { retire_asset: "Retire media", restore_asset: "Restore media", delete_asset: "Delete media", + create_upload: "Create an upload link", + complete_upload: "Complete an upload", assetUpload: "Upload file", assetUpdate: "Update file details", assetRetire: "Retire file", @@ -1697,6 +1699,7 @@ export const en = { assetDelete: "Delete file", assetPurge: "Take down file", assetLiftPurge: "Allow file again", + assetUploadReceived: "Receive an agent's upload", siteBuild: "Build public site", list_sites: "List sites", get_site: "Get site", diff --git a/apps/studio/src/i18n/es.ts b/apps/studio/src/i18n/es.ts index 216c934c..f6be4f00 100644 --- a/apps/studio/src/i18n/es.ts +++ b/apps/studio/src/i18n/es.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): es core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: e3a82a20ba9c7394 +// hash: 5eed0b906145d7f8 import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1793,6 +1793,8 @@ export const messages: Messages = { retire_asset: "Retirar multimedia", restore_asset: "Restaurar multimedia", delete_asset: "Eliminar multimedia", + create_upload: "Crear un enlace de subida", + complete_upload: "Completar una subida", assetUpload: "Subir archivo", assetUpdate: "Actualizar detalles del archivo", assetRetire: "Retirar archivo", @@ -1800,6 +1802,7 @@ export const messages: Messages = { assetDelete: "Eliminar archivo", assetPurge: "Dar de baja archivo", assetLiftPurge: "Volver a permitir archivo", + assetUploadReceived: "Recibir la subida de un agente", siteBuild: "Compilar el sitio público", list_sites: "Listar sitios", get_site: "Obtener sitio", diff --git a/apps/studio/src/i18n/fa.ts b/apps/studio/src/i18n/fa.ts index 894c120f..4e6b24c8 100644 --- a/apps/studio/src/i18n/fa.ts +++ b/apps/studio/src/i18n/fa.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): fa core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: c529016053ea2797 +// hash: feb43475f2a70805 import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1762,6 +1762,8 @@ export const messages: Messages = { retire_asset: "بازنشسته کردن رسانه", restore_asset: "بازیابی رسانه", delete_asset: "حذف رسانه", + create_upload: "ایجاد پیوند بارگذاری", + complete_upload: "تکمیل بارگذاری", assetUpload: "بارگذاری فایل", assetUpdate: "به‌روزرسانی جزئیات فایل", assetRetire: "بازنشسته کردن فایل", @@ -1769,6 +1771,7 @@ export const messages: Messages = { assetDelete: "حذف فایل", assetPurge: "برداشتن فایل", assetLiftPurge: "مجاز کردن دوبارهٔ فایل", + assetUploadReceived: "دریافت بارگذاری یک عامل", siteBuild: "ساخت سایت عمومی", list_sites: "فهرست سایت‌ها", get_site: "دریافت سایت", diff --git a/apps/studio/src/i18n/fr.ts b/apps/studio/src/i18n/fr.ts index 29acce3a..f6437468 100644 --- a/apps/studio/src/i18n/fr.ts +++ b/apps/studio/src/i18n/fr.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): fr core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 20861edd90c3caa6 +// hash: ef3500e6232b8d7c import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1823,6 +1823,8 @@ export const messages: Messages = { retire_asset: "Retirer un média", restore_asset: "Restaurer un média", delete_asset: "Supprimer un média", + create_upload: "Créer un lien d’importation", + complete_upload: "Terminer une importation", assetUpload: "Importer un fichier", assetUpdate: "Mettre à jour les détails d’un fichier", assetRetire: "Retirer un fichier", @@ -1830,6 +1832,7 @@ export const messages: Messages = { assetDelete: "Supprimer un fichier", assetPurge: "Supprimer définitivement un fichier", assetLiftPurge: "Autoriser de nouveau un fichier", + assetUploadReceived: "Recevoir l’importation d’un agent", siteBuild: "Construire le site public", list_sites: "Lister les sites", get_site: "Obtenir un site", diff --git a/apps/studio/src/i18n/he.ts b/apps/studio/src/i18n/he.ts index 11b0a591..ea84ac94 100644 --- a/apps/studio/src/i18n/he.ts +++ b/apps/studio/src/i18n/he.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): he core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 4805bbf5f13324ab +// hash: 0aa923b6f7da8177 import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1719,6 +1719,8 @@ export const messages: Messages = { retire_asset: "הוצאת מדיה משימוש", restore_asset: "שחזור מדיה", delete_asset: "מחיקת מדיה", + create_upload: "יצירת קישור העלאה", + complete_upload: "השלמת העלאה", assetUpload: "העלאת קובץ", assetUpdate: "עדכון פרטי קובץ", assetRetire: "הוצאת קובץ משימוש", @@ -1726,6 +1728,7 @@ export const messages: Messages = { assetDelete: "מחיקת קובץ", assetPurge: "הסרת קובץ לצמיתות", assetLiftPurge: "אישור קובץ מחדש", + assetUploadReceived: "קבלת העלאה של סוכן", siteBuild: "בניית האתר הציבורי", list_sites: "הצגת אתרים", get_site: "קבלת אתר", diff --git a/apps/studio/src/i18n/hi.ts b/apps/studio/src/i18n/hi.ts index db51e1e9..ace95127 100644 --- a/apps/studio/src/i18n/hi.ts +++ b/apps/studio/src/i18n/hi.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): hi core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: fa69e9d41983b56b +// hash: b9b0e4614e8a072b import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1715,6 +1715,8 @@ export const messages: Messages = { retire_asset: "मीडिया सेवानिवृत्त करें", restore_asset: "मीडिया बहाल करें", delete_asset: "मीडिया हटाएँ", + create_upload: "अपलोड लिंक बनाएँ", + complete_upload: "अपलोड पूरा करें", assetUpload: "फ़ाइल अपलोड करें", assetUpdate: "फ़ाइल विवरण अपडेट करें", assetRetire: "फ़ाइल सेवानिवृत्त करें", @@ -1722,6 +1724,7 @@ export const messages: Messages = { assetDelete: "फ़ाइल हटाएँ", assetPurge: "फ़ाइल स्थायी रूप से हटाएँ", assetLiftPurge: "फ़ाइल की फिर से अनुमति दें", + assetUploadReceived: "एजेंट का अपलोड प्राप्त करें", siteBuild: "सार्वजनिक साइट बनाएँ", list_sites: "साइटों की सूची", get_site: "साइट प्राप्त करें", diff --git a/apps/studio/src/i18n/id.ts b/apps/studio/src/i18n/id.ts index b57b98af..43d02bf4 100644 --- a/apps/studio/src/i18n/id.ts +++ b/apps/studio/src/i18n/id.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): id core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 0434724f4464e35a +// hash: e08fab736b4c26e6 import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1788,6 +1788,8 @@ export const messages: Messages = { retire_asset: "Pensiunkan media", restore_asset: "Pulihkan media", delete_asset: "Hapus media", + create_upload: "Buat tautan unggah", + complete_upload: "Selesaikan unggahan", assetUpload: "Unggah file", assetUpdate: "Perbarui detail file", assetRetire: "Pensiunkan file", @@ -1795,6 +1797,7 @@ export const messages: Messages = { assetDelete: "Hapus file", assetPurge: "Turunkan file", assetLiftPurge: "Izinkan file lagi", + assetUploadReceived: "Terima unggahan agen", siteBuild: "Bangun situs publik", list_sites: "Daftar situs", get_site: "Ambil situs", diff --git a/apps/studio/src/i18n/it.ts b/apps/studio/src/i18n/it.ts index 2fef0625..a83445d4 100644 --- a/apps/studio/src/i18n/it.ts +++ b/apps/studio/src/i18n/it.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): it core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 2123cb52982613e5 +// hash: df6710ca32776fa7 import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1787,6 +1787,8 @@ export const messages: Messages = { retire_asset: "Ritira media", restore_asset: "Ripristina media", delete_asset: "Elimina media", + create_upload: "Crea un link di caricamento", + complete_upload: "Completa un caricamento", assetUpload: "Carica file", assetUpdate: "Aggiorna dettagli file", assetRetire: "Ritira file", @@ -1794,6 +1796,7 @@ export const messages: Messages = { assetDelete: "Elimina file", assetPurge: "Rimuovi file", assetLiftPurge: "Consenti di nuovo il file", + assetUploadReceived: "Ricevi il caricamento di un agente", siteBuild: "Costruisci il sito pubblico", list_sites: "Elenca siti", get_site: "Ottieni sito", diff --git a/apps/studio/src/i18n/ja.ts b/apps/studio/src/i18n/ja.ts index ecadfe29..1737140a 100644 --- a/apps/studio/src/i18n/ja.ts +++ b/apps/studio/src/i18n/ja.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): ja core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 999c4c4d57b285bd +// hash: e32a878816898b20 import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1771,6 +1771,8 @@ export const messages: Messages = { retire_asset: "メディアを廃止", restore_asset: "メディアを復元", delete_asset: "メディアを削除", + create_upload: "アップロードリンクを作成", + complete_upload: "アップロードを完了", assetUpload: "ファイルをアップロード", assetUpdate: "ファイルの詳細を更新", assetRetire: "ファイルを廃止", @@ -1778,6 +1780,7 @@ export const messages: Messages = { assetDelete: "ファイルを削除", assetPurge: "ファイルを取り下げ", assetLiftPurge: "ファイルを再び許可", + assetUploadReceived: "エージェントのアップロードを受信", siteBuild: "公開サイトをビルド", list_sites: "サイトを一覧", get_site: "サイトを取得", diff --git a/apps/studio/src/i18n/ko.ts b/apps/studio/src/i18n/ko.ts index 6c360dc2..0c6117e1 100644 --- a/apps/studio/src/i18n/ko.ts +++ b/apps/studio/src/i18n/ko.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): ko core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 7ae061ef97fdc239 +// hash: 51c0d77b439df7e0 import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1729,6 +1729,8 @@ export const messages: Messages = { retire_asset: "미디어 폐기", restore_asset: "미디어 복원", delete_asset: "미디어 삭제", + create_upload: "업로드 링크 만들기", + complete_upload: "업로드 완료", assetUpload: "파일 업로드", assetUpdate: "파일 정보 업데이트", assetRetire: "파일 폐기", @@ -1736,6 +1738,7 @@ export const messages: Messages = { assetDelete: "파일 삭제", assetPurge: "파일 게시 중단", assetLiftPurge: "파일 다시 허용", + assetUploadReceived: "에이전트 업로드 받기", siteBuild: "공개 사이트 빌드", list_sites: "사이트 목록", get_site: "사이트 가져오기", diff --git a/apps/studio/src/i18n/nl.ts b/apps/studio/src/i18n/nl.ts index 55c0b262..6e134c05 100644 --- a/apps/studio/src/i18n/nl.ts +++ b/apps/studio/src/i18n/nl.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): nl core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 1419c0749629e095 +// hash: 33bfaf19811dea4f import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1791,6 +1791,8 @@ export const messages: Messages = { retire_asset: "Media uit gebruik nemen", restore_asset: "Media herstellen", delete_asset: "Media verwijderen", + create_upload: "Uploadlink maken", + complete_upload: "Upload voltooien", assetUpload: "Bestand uploaden", assetUpdate: "Bestandsgegevens bijwerken", assetRetire: "Bestand uit gebruik nemen", @@ -1798,6 +1800,7 @@ export const messages: Messages = { assetDelete: "Bestand verwijderen", assetPurge: "Bestand definitief verwijderen", assetLiftPurge: "Bestand weer toestaan", + assetUploadReceived: "Upload van een agent ontvangen", siteBuild: "Openbare site bouwen", list_sites: "Sites weergeven", get_site: "Site ophalen", diff --git a/apps/studio/src/i18n/pl.ts b/apps/studio/src/i18n/pl.ts index 9d9394c8..1c67b98e 100644 --- a/apps/studio/src/i18n/pl.ts +++ b/apps/studio/src/i18n/pl.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): pl core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: f564b5672582ca70 +// hash: 2c8d317f73079741 import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1769,6 +1769,8 @@ export const messages: Messages = { retire_asset: "Wycofanie multimediów", restore_asset: "Przywrócenie multimediów", delete_asset: "Usunięcie multimediów", + create_upload: "Utworzenie linku do przesłania", + complete_upload: "Dokończenie przesłania", assetUpload: "Przesłanie pliku", assetUpdate: "Aktualizacja szczegółów pliku", assetRetire: "Wycofanie pliku", @@ -1776,6 +1778,7 @@ export const messages: Messages = { assetDelete: "Usunięcie pliku", assetPurge: "Usunięcie pliku na żądanie", assetLiftPurge: "Ponowne zezwolenie na plik", + assetUploadReceived: "Odbiór pliku przesłanego przez agenta", siteBuild: "Zbuduj stronę publiczną", list_sites: "Lista witryn", get_site: "Odczyt witryny", diff --git a/apps/studio/src/i18n/pt-BR.ts b/apps/studio/src/i18n/pt-BR.ts index eb6c67de..901aeeb4 100644 --- a/apps/studio/src/i18n/pt-BR.ts +++ b/apps/studio/src/i18n/pt-BR.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): pt-BR core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 16177ae399e761fe +// hash: 642880354c5726bf import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1773,6 +1773,8 @@ export const messages: Messages = { retire_asset: "Aposentar mídia", restore_asset: "Restaurar mídia", delete_asset: "Excluir mídia", + create_upload: "Criar link de envio", + complete_upload: "Concluir envio", assetUpload: "Enviar arquivo", assetUpdate: "Atualizar detalhes do arquivo", assetRetire: "Aposentar arquivo", @@ -1780,6 +1782,7 @@ export const messages: Messages = { assetDelete: "Excluir arquivo", assetPurge: "Retirar arquivo do ar", assetLiftPurge: "Permitir arquivo de novo", + assetUploadReceived: "Receber envio de um agente", siteBuild: "Gerar o site público", list_sites: "Listar sites", get_site: "Obter site", diff --git a/apps/studio/src/i18n/ru.ts b/apps/studio/src/i18n/ru.ts index 970f1d46..fa06507f 100644 --- a/apps/studio/src/i18n/ru.ts +++ b/apps/studio/src/i18n/ru.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): ru core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 1ba47ca5fca71886 +// hash: 08e85bb8a2be351a import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1796,6 +1796,8 @@ export const messages: Messages = { retire_asset: "Вывести медиафайл", restore_asset: "Восстановить медиафайл", delete_asset: "Удалить медиафайл", + create_upload: "Создать ссылку для загрузки", + complete_upload: "Завершить загрузку", assetUpload: "Загрузка файла", assetUpdate: "Изменение сведений о файле", assetRetire: "Вывод файла", @@ -1803,6 +1805,7 @@ export const messages: Messages = { assetDelete: "Удаление файла", assetPurge: "Изъятие файла", assetLiftPurge: "Повторное разрешение файла", + assetUploadReceived: "Получение файла, загруженного агентом", siteBuild: "Собрать публичный сайт", list_sites: "Список сайтов", get_site: "Получить сайт", diff --git a/apps/studio/src/i18n/tr.ts b/apps/studio/src/i18n/tr.ts index dee116a5..d1b1feaf 100644 --- a/apps/studio/src/i18n/tr.ts +++ b/apps/studio/src/i18n/tr.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): tr core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 978c0d1c76712b9d +// hash: d31762a58b102802 import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1767,6 +1767,8 @@ export const messages: Messages = { retire_asset: "Medyayı emekliye ayır", restore_asset: "Medyayı geri getir", delete_asset: "Medyayı sil", + create_upload: "Yükleme bağlantısı oluştur", + complete_upload: "Yüklemeyi tamamla", assetUpload: "Dosya yükle", assetUpdate: "Dosya ayrıntılarını güncelle", assetRetire: "Dosyayı emekliye ayır", @@ -1774,6 +1776,7 @@ export const messages: Messages = { assetDelete: "Dosyayı sil", assetPurge: "Dosyayı yayından kaldır", assetLiftPurge: "Dosyaya yeniden izin ver", + assetUploadReceived: "Bir agent'ın yüklemesini al", siteBuild: "Herkese açık siteyi derle", list_sites: "Siteleri listele", get_site: "Siteyi oku", diff --git a/apps/studio/src/i18n/uk.ts b/apps/studio/src/i18n/uk.ts index 846af6d6..dec95097 100644 --- a/apps/studio/src/i18n/uk.ts +++ b/apps/studio/src/i18n/uk.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): uk core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 65ee31cd1d26e6a5 +// hash: f7e1ab254206962c import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1776,6 +1776,8 @@ export const messages: Messages = { retire_asset: "Вивести медіа з ужитку", restore_asset: "Відновити медіа", delete_asset: "Видалити медіа", + create_upload: "Створити посилання для завантаження", + complete_upload: "Завершити завантаження", assetUpload: "Завантажити файл", assetUpdate: "Оновити дані файлу", assetRetire: "Вивести файл з ужитку", @@ -1783,6 +1785,7 @@ export const messages: Messages = { assetDelete: "Видалити файл", assetPurge: "Вилучити файл", assetLiftPurge: "Знову дозволити файл", + assetUploadReceived: "Отримати файл, завантажений агентом", siteBuild: "Зібрати публічний сайт", list_sites: "Список сайтів", get_site: "Отримати сайт", diff --git a/apps/studio/src/i18n/zh-Hans.ts b/apps/studio/src/i18n/zh-Hans.ts index dcdb6471..fbc5af5f 100644 --- a/apps/studio/src/i18n/zh-Hans.ts +++ b/apps/studio/src/i18n/zh-Hans.ts @@ -1,6 +1,6 @@ // Generated by `pnpm i18n:import` (ADR-0034): zh-Hans core messages. // Do not edit: change the translation file and import it; only English is edited here. -// hash: 7378b5add2c8834a +// hash: 58db5ec0bc2cc626 import type { Messages } from "./en.ts"; export const messages: Messages = { @@ -1660,6 +1660,8 @@ export const messages: Messages = { retire_asset: "停用媒体", restore_asset: "恢复媒体", delete_asset: "删除媒体", + create_upload: "创建上传链接", + complete_upload: "完成上传", assetUpload: "上传文件", assetUpdate: "更新文件详情", assetRetire: "停用文件", @@ -1667,6 +1669,7 @@ export const messages: Messages = { assetDelete: "删除文件", assetPurge: "下架文件", assetLiftPurge: "重新允许文件", + assetUploadReceived: "接收智能体的上传", siteBuild: "构建公开网站", list_sites: "列出站点", get_site: "获取站点", diff --git a/apps/studio/src/lib/activity.ts b/apps/studio/src/lib/activity.ts index 5b63086d..395ce995 100644 --- a/apps/studio/src/lib/activity.ts +++ b/apps/studio/src/lib/activity.ts @@ -59,6 +59,9 @@ export const KNOWN_TOOLS = [ "retire_asset", "restore_asset", "delete_asset", + // RFC-0048 agents' upload links + "create_upload", + "complete_upload", // RFC-0007 reader comments "list_comments", "get_comment_thread", @@ -143,6 +146,8 @@ export const ASSET_EVENTS = { "asset.delete": "assetDelete", "asset.purge": "assetPurge", "asset.lift-purge": "assetLiftPurge", + // RFC-0048: an agent's upload link received its file (the PUT, before complete_upload). + "asset.upload-received": "assetUploadReceived", } as const; export type AssetEvent = keyof typeof ASSET_EVENTS; diff --git a/crates/cloudhal-schema/src/generated/release_manifest.rs b/crates/cloudhal-schema/src/generated/release_manifest.rs index 3b98726b..354b468b 100644 --- a/crates/cloudhal-schema/src/generated/release_manifest.rs +++ b/crates/cloudhal-schema/src/generated/release_manifest.rs @@ -1492,6 +1492,8 @@ pub enum SecretName { CloudhalSetupToken, #[serde(rename = "CLOUDHAL_COMMENTS_KEY")] CloudhalCommentsKey, + #[serde(rename = "CLOUDHAL_UPLOAD_SECRET")] + CloudhalUploadSecret, } impl ::std::fmt::Display for SecretName { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { @@ -1503,6 +1505,7 @@ impl ::std::fmt::Display for SecretName { Self::CloudhalDeployToken => f.write_str("CLOUDHAL_DEPLOY_TOKEN"), Self::CloudhalSetupToken => f.write_str("CLOUDHAL_SETUP_TOKEN"), Self::CloudhalCommentsKey => f.write_str("CLOUDHAL_COMMENTS_KEY"), + Self::CloudhalUploadSecret => f.write_str("CLOUDHAL_UPLOAD_SECRET"), } } } @@ -1517,6 +1520,7 @@ impl ::std::str::FromStr for SecretName { "CLOUDHAL_DEPLOY_TOKEN" => Ok(Self::CloudhalDeployToken), "CLOUDHAL_SETUP_TOKEN" => Ok(Self::CloudhalSetupToken), "CLOUDHAL_COMMENTS_KEY" => Ok(Self::CloudhalCommentsKey), + "CLOUDHAL_UPLOAD_SECRET" => Ok(Self::CloudhalUploadSecret), _ => Err("invalid value".into()), } } diff --git a/deploy/docker/compose.yml b/deploy/docker/compose.yml index a53d275e..9fbd7f1f 100644 --- a/deploy/docker/compose.yml +++ b/deploy/docker/compose.yml @@ -49,6 +49,8 @@ services: CLOUDHAL_DEPLOY_TOKEN: ${CLOUDHAL_DEPLOY_TOKEN:?} CLOUDHAL_SETUP_TOKEN: ${CLOUDHAL_SETUP_TOKEN:?} CLOUDHAL_COMMENTS_KEY: ${CLOUDHAL_COMMENTS_KEY:?} + # Optional (RFC-0048): signs upload links; without it the preview secret does. + CLOUDHAL_UPLOAD_SECRET: ${CLOUDHAL_UPLOAD_SECRET:-} # The origin browsers open Studio at; required behind a proxy (CLOUDHAL_BEHIND_PROXY=1, the # caddy profile), whose X-Forwarded-For last hop is then taken as the client's address. CLOUDHAL_BASE_URL: ${CLOUDHAL_BASE_URL:-} diff --git a/docs/guides/agent-uploads.md b/docs/guides/agent-uploads.md new file mode 100644 index 00000000..0763bed2 --- /dev/null +++ b/docs/guides/agent-uploads.md @@ -0,0 +1,74 @@ +# Agent uploads: a guide for operators and agent builders + +An agent that has a file on disk and a shell can add it to a site's media library without sending the bytes through the conversation: + +1. **`create_upload`** declares the file: its exact size, type and SHA-256, plus the alt text and other fields the asset should get. The answer is a short-lived PUT link and a ready `curl` line. +2. The agent's shell **PUTs the file** to that link. +3. **`complete_upload`** turns the received bytes into an asset, which answers as `upload_asset` does. + +`upload_asset` (base64, at most 4 MB) stays for small files and for agents without a shell. The design and its reasons are in [RFC-0048](../rfcs/0048-signed-agent-uploads.md) and [ADR-0048](../adr/0048-signed-agent-uploads.md). + +## What a link allows +- **One file.** The link is bound to the site, the upload, the method (`PUT`), the exact size, the declared type and the exact SHA-256. Anyone who holds the link can upload only that file, and needs its bytes to do so. +- **Once.** A second PUT answers `410 upload_used`. A PUT the server refuses (wrong size, type or hash) can be repeated with the right file, up to three attempts in all. +- **For a short time.** The PUT must **start** within 10 minutes of `create_upload`. The received bytes must be completed within 60 minutes. After that they are collected like any unused file, 24 hours later. +- **Nothing else.** The PUT never creates, changes or publishes anything. The asset is created only by `complete_upload`, under the same key, scope (`asset:upload`), mode, approval, daily limit and site quota as `upload_asset`. In `manual` mode a person approves the file once, at `create_upload`. The prompt names its size, type and the start of its SHA-256. + +## For agents and agent builders +Hash the file first: + +| System | Command | +|---|---| +| macOS | `shasum -a 256 photo.webp` | +| Linux | `sha256sum photo.webp` | +| PowerShell | `Get-FileHash -Algorithm SHA256 photo.webp` | + +Then call `create_upload` with `bytes` (the file's size in bytes), `mediaType` and `sha256`. Run the `curl` line it returns, with the file's path in place of its name: + +```bash +curl --fail-with-body -X PUT -H 'content-type: image/webp' --upload-file ./photo.webp 'https://studio.example.com/api/sites/site_…/assets/agent-uploads/upl_…?sig=…' +``` + +Finally call `complete_upload` with the `uploadId`. If the library already holds the same bytes, `create_upload` answers `status: "existing"` with that asset and no link, so there is nothing to send. + +- **Check first.** `get_mode` → `uploads` says whether this server hands out links (`signedUrl`), the cap per file (`maxBytes`) and how long a link lasts (`linkSeconds`). +- **Keep the link private.** Treat the link like a password for that one file: do not paste it into chats, tickets or logs. A leaked, unused link lets someone else burn its three attempts; the agent then calls `create_upload` again. +- **Refusals** carry a `details.reason` and the next step: `upload_cap`, `unsupported_type`, `too_many_uploads`, `upload_pending`, `upload_failed`, `upload_expired` and `signed_upload_unsupported`, among others. + +## For operators + +### Settings +| Where | Setting | Default | +|---|---|---| +| `cloudhal.json` | `"media": { "agentUploads": false }` turns links off | on | +| `cloudhal.json` | `"media": { "agentUploadBytes": 52428800 }` sets the cap per file, at most 100 MB and each type's own cap | 25 MB | +| self-host | `CLOUDHAL_AGENT_UPLOADS=off`, `CLOUDHAL_AGENT_UPLOAD_BYTES=` | on, 25 MB | +| both | at most 10 open uploads per agent key and 50 per site; per key per 24 hours, 100 files and 500 MB (open uploads count) | fixed | + +`cloudhal deploy` writes the `cloudhal.json` settings into the admin Worker's vars (`CLOUDHAL_AGENT_UPLOADS`, `CLOUDHAL_AGENT_UPLOAD_BYTES`). `cloudhal studio` reads them from the project. Stdio `cloudhal mcp` never hands out links: it has no HTTP listener for the PUT. + +### The signing secret +Links are signed with HMAC-SHA-256 under `CLOUDHAL_UPLOAD_SECRET` (at least 32 characters). When it is not set, the preview secret is used instead, then the MCP state key. + +- **Cloudflare.** `cloudhal deploy` generates the secret once into `.cloudhal/deploy/secrets.json` (mode 0600; never commit it) and gives it to the admin Worker as a secret. It is never printed or written into a config. Older deployments get it on their next deploy. +- **Self-host.** It is optional. `cloudhal selfhost secrets` generates it for new installations. Existing ones may add `CLOUDHAL_UPLOAD_SECRET` or `CLOUDHAL_UPLOAD_SECRET_FILE` (Docker and Kubernetes secrets), or leave it unset and keep using the preview secret. A value shorter than 32 characters stops the image at start with a message. +- **Rotation.** Change the secret and redeploy (or restart). The only casualty is links that were not used yet: they answer `403 bad_signature`, and the agent calls `create_upload` again. Bytes that were already received stay completable. + +### Logs: keep the query string out +The link's credential is its `?sig=` query parameter. + +- **Cloudflare.** Workers Logs and traces drop query strings (`redact_query_string`, set by `cloudhal deploy`). +- **Cloudhal itself.** It logs no request URLs, and its audit rows never hold the link. +- **Anything you put in front of Cloudhal can still log it:** + - **Reverse proxies and ingress controllers** log the full request line by default. That includes ingress-nginx, nginx, Traefik, Envoy-based gateways, HAProxy, and load balancers' access logs. Strip the query string from their access log format (for nginx, log `$uri` instead of `$request` or `$request_uri`), or exclude the path `/api/sites/*/assets/agent-uploads/*` from access logs. The `caddy` profile of the compose file configures no access log. + - **`wrangler tail`** streams live requests to whoever runs it. Whether `redact_query_string` applies to tail sessions is not verified. Treat a tail session's output as containing links, and do not paste it anywhere. + - **CI logs and shell history** of the agent's machine hold the `curl` line. Links expire within 10 minutes and work once, but keep such logs private. + +### Body size limits +The PUT goes through the admin Worker (Cloudflare and self-host alike) to the media store, which stays private. + +- **Cloudflare.** Request bodies are limited by the zone's plan: 100 MB on Free and Pro, 200 MB on Business ([Workers limits](https://developers.cloudflare.com/workers/platform/limits/)). +- **Self-host.** A reverse proxy in front must accept bodies up to the agent cap. Many default to 1 MB (nginx `client_max_body_size`, ingress-nginx `nginx.ingress.kubernetes.io/proxy-body-size`). + +### Turning it off +Set `"media": { "agentUploads": false }` and deploy again (self-host: `CLOUDHAL_AGENT_UPLOADS=off` and restart). `create_upload` then answers `signed_upload_unsupported`, and agents fall back to `upload_asset`. Open uploads expire within the hour, and bytes already received are either completed or collected. diff --git a/docs/guides/self-host.md b/docs/guides/self-host.md index 71c1c8ad..0259bad0 100644 --- a/docs/guides/self-host.md +++ b/docs/guides/self-host.md @@ -108,6 +108,8 @@ location / { | `CLOUDHAL_BASE_URL`, `CLOUDHAL_BEHIND_PROXY` | As above. | | `CLOUDHAL_SITE_NAME` | The name of the site the first start creates. | | `CLOUDHAL_AUTOMATIONS` | `off` turns scheduled automations off. | +| `CLOUDHAL_UPLOAD_SECRET` | Optional, at least 32 characters (`_FILE` works too): signs agents' upload links ([agent uploads](agent-uploads.md)). Unset, the preview secret signs them. | +| `CLOUDHAL_AGENT_UPLOADS`, `CLOUDHAL_AGENT_UPLOAD_BYTES` | `off` turns agents' upload links off; a cap per file in bytes (default 25 MB, at most 100 MB). | | `CLOUDHAL_SMTP_URL` | The SMTP server for invites and password resets ([mail](#mail)): `smtp://user:password@host:587` (STARTTLS) or `smtps://…:465`. `_FILE` works too. Unset, mail is off. | | `CLOUDHAL_MAIL_FROM`, `CLOUDHAL_MAIL_FROM_NAME` | The one sender address mail goes out from, and its display name. The address is required with `CLOUDHAL_SMTP_URL`. | | `CLOUDHAL_SMTP_CA_FILE` | PEM certificates to trust besides the browser CAs, for a relay with a private CA. | diff --git a/docs/rfcs/0048-signed-agent-uploads.md b/docs/rfcs/0048-signed-agent-uploads.md index 813ee6e2..12a3587a 100644 --- a/docs/rfcs/0048-signed-agent-uploads.md +++ b/docs/rfcs/0048-signed-agent-uploads.md @@ -434,3 +434,10 @@ The RFC-0005 I15 amendment (under "Compatibility & migration") is accepted with 4. **No `outside_run` check of its own.** Inside an automation run, `complete_upload` is a write like `upload_asset`: the run's budget and taint rules apply to it as they do to any write. 5. **The hints live in `packages/mcp-server/src/upload-hints.ts`**, as §5.3 says. The store's invariant codes are answered with existing tool codes plus `details.reason`. 6. **Where a link points.** It uses the deployment's configured origin (`ApiDeps.studioOrigin`, which `cloudhal studio --base-url` sets), else the origin of the `/mcp` request. + +**Rollout step 5 (hosts).** +1. **`CLOUDHAL_UPLOAD_SECRET` is an admin Worker secret of the release manifest.** RFC-0046's `SecretName` gains it, an additive contract change, regenerated for TypeScript and Rust. `cloudhal deploy` generates it into the 0600 secrets file, and an existing project gets it on its next deploy. +2. **Self-host keeps it optional.** The image does not require it, so existing installations start unchanged. `cloudhal selfhost secrets` generates it for new ones. `_FILE` works. Unset, workerd receives an empty value and the preview secret signs. A value shorter than 32 characters stops the image at start. +3. **`cloudhal.json` `media.agentUploads` and `media.agentUploadBytes`** are read by `config-media.ts`, without taking `media` over from the starter. They are `deploy` keys in the release key table, and the admin Worker receives them as the vars `CLOUDHAL_AGENT_UPLOADS` and `CLOUDHAL_AGENT_UPLOAD_BYTES`. Self-host passes the same vars through, and `cloudhal studio` reads the file. Helm and Swarm are unchanged: operators add the optional secret through `_FILE` or the environment. +4. **Studio labels** `create_upload`, `complete_upload` and the audit event `asset.upload-received` in every language. The translations are drafts awaiting review. +5. **The eval task is not added.** The build eval runs Workers AI models through Build chat's page-building turn, which has neither the MCP upload tools nor a shell. A "cover from disk" task needs an agent harness with a shell and an MCP client, which this repo does not have yet. The API's end-to-end test (`agent-uploads-auth.test.ts`) runs the same flow without a model. diff --git a/docs/security/threat-model.md b/docs/security/threat-model.md index e2866be6..b146d51b 100644 --- a/docs/security/threat-model.md +++ b/docs/security/threat-model.md @@ -12,7 +12,7 @@ Staff roles are named sets of scopes (RFC-0005, ADR-0018). A person's role is re | Editor | Session cookie | Content, pages, taxonomies, redirects, publish, rollback, all Activity; invites Contributors and Authors | | Author | Session cookie | Own articles in any status; publishes own-only change sets (anything wider becomes a request an Editor decides) | | Contributor | Session cookie | Own never-published drafts (draft/review); proposes tags; never publishes | -| Agent | API key (`x-api-key` or `Authorization: Bearer`) with explicit scopes | MCP tools only (plus, once RFC-0048 ships, one PUT per upload link those tools mint), within its scopes narrowed to its creator's current role; publish/rollback/delete wait for a person | +| Agent | API key (`x-api-key` or `Authorization: Bearer`) with explicit scopes | MCP tools only, plus one PUT per upload link those tools mint (RFC-0048), within its scopes narrowed to its creator's current role; publish/rollback/delete wait for a person | | Local developer's agent | `cloudhal mcp` over stdio | All scopes on the local project; gated tools ask in the MCP client | | Automation key | API key (`x-api-key` or `Authorization: Bearer`) minted for one automation by the person who created it (RFC-0008) | An agent key that works only inside its automation's run windows (outside them only `begin_run`, `get_mode` and `pause_automation` answer); narrowed to its owner's current role, capped by the automation's mode cap, never `bypass`; within budgets; read, label and hide only once its run reads visitor-supplied text | | Scheduler | System actor (`sys_scheduler`) inside the admin Worker or the Node process; no credential | Publishes releases on behalf of the person who approved them, runs built-in jobs, opens and closes run windows (RFC-0008) | @@ -85,11 +85,11 @@ Schedules add the first actions Cloudhal takes when nobody is at the keyboard: r | **Tenant isolation** | REST takes the site from the route after the scope check; the scheduler takes it from the stored release or automation; an automation key's run is bound to its automation's site. | MCP tools take `siteId` from their arguments, like every MCP tool (roles are deployment-wide). | ## Agent uploads (RFC-0048) -Agent upload links let an agent send a file's bytes with a plain PUT instead of base64 inside `upload_asset`. `create_upload` (a governed MCP call) mints the link and `complete_upload` creates the asset; the PUT on `…/assets/agent-uploads/:uploadId` only carries bytes. It is the one route with the `upload-link` requirement (RFC-0005 I15 as amended, [ADR-0048](../adr/0048-signed-agent-uploads.md)). This table is the accepted design (2026-11-29); rows become "Mitigated" as RFC-0048's rollout steps 2–5 land and are reviewed against the code. +Agent upload links let an agent send a file's bytes with a plain PUT instead of base64 inside `upload_asset`. `create_upload` (a governed MCP call) mints the link and `complete_upload` creates the asset; the PUT on `…/assets/agent-uploads/:uploadId` only carries bytes. It is the one route with the `upload-link` requirement (RFC-0005 I15 as amended, [ADR-0048](../adr/0048-signed-agent-uploads.md)). "Mitigated" is what the code does as of 2026-11-29 (rollout steps 2–5: the store, the route, the MCP tools, the hosts); "Residual" is what remains. Operators: [agent uploads guide](../guides/agent-uploads.md). -| Threat | Mitigation (designed) | Residual | +| Threat | Mitigated | Residual | |---|---|---| -| **A leaked link** (chat transcript, shell history, CI log, proxy log) | Bound to the exact SHA-256, size, type, site and actor; single use; 10 minutes to start the PUT. Whoever holds it can upload only the declared file, and needs its bytes to do so. Our request logs redact `sig`, and audit rows never hold the link. | Someone who sees the link before it is used can burn its 3 attempts with wrong bytes, a denial of service on one upload; the agent calls `create_upload` again (in `manual` mode a person approves again). | +| **A leaked link** (chat transcript, shell history, CI log, proxy log) | Bound to the exact SHA-256, size, type, site and actor; single use; 10 minutes to start the PUT. Whoever holds it can upload only the declared file, and needs its bytes to do so. Our request logs redact `sig`, and audit rows never hold the link. | Someone who sees the link before it is used can burn its 3 attempts with wrong bytes, a denial of service on one upload; the agent calls `create_upload` again (in `manual` mode a person approves again). Logs outside Cloudhal (an operator's reverse proxy or ingress access log, `wrangler tail`) may record the query string; the guide says how to keep it out. | | **Replay** | The row is claimed by CAS before any byte is read; `received` and `completed` rows refuse further PUTs (`410 upload_used`). `complete_upload` is idempotent (a second call returns the same asset, no second snapshot). A link replayed against another site or upload fails the signature and the row check. | None known. | | **Content-type confusion** | The declared type must be an agent type (`MEDIA_TYPES` without `peopleOnly`: no SVG; HTML is not in the table). `Content-Type` must equal the declared type; the sniffed type must too (`415 type_mismatch`). The served type comes from the table with RFC-0004's `nosniff`, disposition and CSP headers. | Polyglot files, as today; the separate media origin with `nosniff` contains them. | | **Oversize** | Refused at `create_upload` above the cap (25 MB default, operator setting up to 100 MB). `Content-Length` must equal `bytes`, and the read stops at `bytes`. On Cloudflare the plan's body limit also applies at the edge. | None. | diff --git a/packages/cli/src/cloudflare/admin.ts b/packages/cli/src/cloudflare/admin.ts index de6f6a19..45ab03b7 100644 --- a/packages/cli/src/cloudflare/admin.ts +++ b/packages/cli/src/cloudflare/admin.ts @@ -2,9 +2,11 @@ * Prepares the admin Worker for wrangler: `/.cloudhal/deploy/admin/` gets an entry that * bundles the project's skills, and a wrangler config pointing at the built Studio. */ + import { mkdir, writeFile } from "node:fs/promises"; import path from "node:path"; import { readSkillSources } from "@cloudhal/agent-runtime"; +import { readAgentUploads } from "../config-media.ts"; import { type AnalyticsDeployment, adminWorkerConfig, @@ -129,6 +131,7 @@ export async function prepareAdminWorker(options: { ); const configPath = path.join(dir, "wrangler.jsonc"); const existing = await readExistingIds(configPath); + const uploads = await readAgentUploads(options.projectDir); await writeWranglerConfig( configPath, adminWorkerConfig({ @@ -149,6 +152,7 @@ export async function prepareAdminWorker(options: { ...(options.browser ? { browser: true } : {}), ...(options.observability ? { observability: options.observability } : {}), ...(options.placement ? { placement: options.placement } : {}), + ...(uploads ? { uploads } : {}), }), "Cloudhal admin Worker (API, auth, MCP, Studio)", ); diff --git a/packages/cli/src/cloudflare/config.ts b/packages/cli/src/cloudflare/config.ts index 114884df..a42b53cd 100644 --- a/packages/cli/src/cloudflare/config.ts +++ b/packages/cli/src/cloudflare/config.ts @@ -25,8 +25,10 @@ * each tick for the account's Workers plan and `CLOUDHAL_AUTOMATIONS` is the deployment's * automations switch (§8.2, §11.6); both are always written, so a deploy never drops them. */ + import { readFile, writeFile } from "node:fs/promises"; import path from "node:path"; +import { type AgentUploadsConfig, agentUploadVars } from "../config-media.ts"; import { type SearchDeployment, searchBinding, searchBuckets, searchVars } from "./search.ts"; @@ -321,6 +323,8 @@ export function adminWorkerConfig( observability?: ObservabilityDeployment; /** Smart Placement: run next to D1 rather than next to the person (default: off). */ placement?: "smart"; + /** RFC-0048: `cloudhal.json` `media.agentUploads` and `agentUploadBytes`. */ + uploads?: AgentUploadsConfig; }, ) { const names = workerNames(n); @@ -359,6 +363,8 @@ export function adminWorkerConfig( CLOUDHAL_AUTOMATIONS: s.automations ? "on" : "off", // RFC-0029 §3: publishes mirror into the search bucket here. ...searchVars(n.search), + // RFC-0048: agents' upload links off, or their cap per file. + ...agentUploadVars(n.uploads), ...(n.mail ? { CLOUDHAL_MAIL_FROM: n.mail.from, diff --git a/packages/cli/src/commands/deploy/release/index.ts b/packages/cli/src/commands/deploy/release/index.ts index 660b00b8..03ff0439 100644 --- a/packages/cli/src/commands/deploy/release/index.ts +++ b/packages/cli/src/commands/deploy/release/index.ts @@ -16,6 +16,7 @@ * Nothing is written outside `.cloudhal/deploy/`, and nothing is uploaded, before step 5 passes. * `--dry-run` stops after step 6. */ + import { mkdir } from "node:fs/promises"; import path from "node:path"; import { @@ -32,6 +33,7 @@ import { type SchedulerTicker, } from "../../../cloudflare/config.ts"; import { readProjectConfig } from "../../../config.ts"; +import { readAgentUploads } from "../../../config-media.ts"; import { deploySecrets, finishDeploy } from "../finish.ts"; import type { DeployOptions, DeployResult } from "../options.ts"; import { @@ -209,6 +211,7 @@ export async function deployRelease(options: DeployOptions): Promise writeReleaseConfigs({ diff --git a/packages/cli/src/commands/deploy/state.ts b/packages/cli/src/commands/deploy/state.ts index 8d133281..2fc601bb 100644 --- a/packages/cli/src/commands/deploy/state.ts +++ b/packages/cli/src/commands/deploy/state.ts @@ -12,6 +12,9 @@ export const SECRET_KEYS = [ "CLOUDHAL_SETUP_TOKEN", // RFC-0007: proof-of-work MACs, email encryption and hashes, stored secrets; both Workers. "CLOUDHAL_COMMENTS_KEY", + // RFC-0048 §2.2: signs upload tickets and agents' upload links (admin Worker only), so the + // upload key rotates without breaking preview links. + "CLOUDHAL_UPLOAD_SECRET", ] as const; export type DeploySecrets = Record<(typeof SECRET_KEYS)[number], string>; /** The secrets the site Worker has too, with the same values as the admin Worker's. */ diff --git a/packages/cli/src/commands/studio.ts b/packages/cli/src/commands/studio.ts index 213106a8..26630942 100644 --- a/packages/cli/src/commands/studio.ts +++ b/packages/cli/src/commands/studio.ts @@ -16,6 +16,7 @@ import { SqlScheduleStore } from "@cloudhal/schedules/sql"; import { assetDir } from "../assets.ts"; import { loadBlockRegistry, loadThemeDesign, loadThemeSettings } from "../blocks.ts"; import { readProjectConfig } from "../config.ts"; +import { readAgentUploads } from "../config-media.ts"; import { localRender } from "../render-chrome.ts"; import { localAnalytics, startLocalRollups } from "./analytics.ts"; import { localComments } from "./comments-local.ts"; @@ -185,7 +186,7 @@ export async function studio(options: StudioOptions): Promise { audit: new AuditLog(local.sql), approvals: new ApprovalStore(local.sql), skills: skillsDir ? await loadSkills(skillsDir) : [], - media: { fetchTransport: nodeTransport() }, + media: { fetchTransport: nodeTransport(), ...(await readAgentUploads(options.projectDir)) }, // RFC-0021 §4: render_page with the local Chrome, when there is one. render: localRender(), }, diff --git a/packages/cli/src/config-build-keys.ts b/packages/cli/src/config-build-keys.ts index 3479f43b..feef53dd 100644 --- a/packages/cli/src/config-build-keys.ts +++ b/packages/cli/src/config-build-keys.ts @@ -23,6 +23,9 @@ export type FeatureClass = { readonly build: true; readonly runtimeWith: "mediaT /** `cloudhal.json` `media`, read only by the starter's `astro.config.mjs` (RFC-0004 §7.5). */ export interface MediaConfig { readonly transform?: "cdn-cgi" | "none"; + /** RFC-0048 (`config-media.ts`): agents' upload links off, and their cap per file. */ + readonly agentUploads?: false; + readonly agentUploadBytes?: number; } type Mixed = "analytics" | "comments"; @@ -64,6 +67,8 @@ export const CONFIG_KEY_CLASSES: ConfigKeyTable = { search: "deploy", // only searchDeploymentOf media: { transform: { build: true, runtimeWith: "mediaTransformVar" }, + agentUploads: "deploy", // the admin Worker's CLOUDHAL_AGENT_UPLOADS + agentUploadBytes: "deploy", // CLOUDHAL_AGENT_UPLOAD_BYTES }, }; diff --git a/packages/cli/src/config-media.ts b/packages/cli/src/config-media.ts new file mode 100644 index 00000000..2cb32832 --- /dev/null +++ b/packages/cli/src/config-media.ts @@ -0,0 +1,58 @@ +/** + * RFC-0048 §3.3 and "Capability flag": the two `cloudhal.json` `media` keys of agents' upload + * links, read leniently (a value of the wrong type is left out, like the rest of the file). + * `media` stays the starter's key (`OWN_KEYS` keeps it as written); this module only reads it. + * + * - `media.agentUploads: false` turns the links off (`get_mode.uploads.signedUrl` false); + * - `media.agentUploadBytes`: the cap per file, 1 byte to 100 MB (default 25 MB). + * + * On Cloudflare they reach the admin Worker as the vars `CLOUDHAL_AGENT_UPLOADS` and + * `CLOUDHAL_AGENT_UPLOAD_BYTES`; on self-host the operator sets those vars; `cloudhal studio` reads + * them from the project directly. + */ +import { readFile } from "node:fs/promises"; +import path from "node:path"; +import { CONFIG_FILE } from "./config.ts"; + +export interface AgentUploadsConfig { + readonly agentUploads?: false; + readonly agentUploadBytes?: number; +} + +const MAX_BYTES = 100 * 1024 * 1024; + +/** The keys from a parsed `cloudhal.json`; undefined when neither is set (validly). */ +export function parseAgentUploads(raw: unknown): AgentUploadsConfig | undefined { + const media = (raw as { media?: unknown } | undefined)?.media; + if (!media || typeof media !== "object") return undefined; + const m = media as Record; + const bytes = m.agentUploadBytes; + const out: AgentUploadsConfig = { + ...(m.agentUploads === false ? { agentUploads: false as const } : {}), + ...(typeof bytes === "number" && Number.isInteger(bytes) && bytes >= 1 && bytes <= MAX_BYTES + ? { agentUploadBytes: bytes } + : {}), + }; + return Object.keys(out).length > 0 ? out : undefined; +} + +/** The project's settings; undefined without a readable `cloudhal.json` or without the keys. */ +export async function readAgentUploads( + projectDir: string, +): Promise { + try { + return parseAgentUploads( + JSON.parse(await readFile(path.join(projectDir, CONFIG_FILE), "utf8")), + ); + } catch { + return undefined; + } +} + +/** The admin Worker's vars for them (none when unset). */ +export function agentUploadVars(c: AgentUploadsConfig | undefined): Record { + return { + ...(c?.agentUploads === false ? { CLOUDHAL_AGENT_UPLOADS: "off" } : {}), + ...(c?.agentUploadBytes ? { CLOUDHAL_AGENT_UPLOAD_BYTES: String(c.agentUploadBytes) } : {}), + }; +} diff --git a/packages/cli/src/selfhost/secrets.ts b/packages/cli/src/selfhost/secrets.ts index 94b73cd6..292a98ae 100644 --- a/packages/cli/src/selfhost/secrets.ts +++ b/packages/cli/src/selfhost/secrets.ts @@ -5,7 +5,7 @@ * never written; run it once per installation and keep the output with the installation. */ import { randomBytes } from "node:crypto"; -import { REQUIRED_SECRETS } from "./settings.ts"; +import { OPTIONAL_SECRETS, REQUIRED_SECRETS } from "./settings.ts"; const ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; @@ -23,7 +23,7 @@ export function secretsEnv(random: (n: number) => Uint8Array = randomBytes): str "# every instance of this installation needs the same values.", `CLOUDHAL_SITE_ID=${newSiteId(random)}`, `CLOUDHAL_CLUSTER_KEY=${hex()}`, - ...REQUIRED_SECRETS.map((name) => `${name}=${hex()}`), + ...[...REQUIRED_SECRETS, ...OPTIONAL_SECRETS].map((name) => `${name}=${hex()}`), "# The S3 store's credentials: the compose file's SeaweedFS takes these; for another store", "# (AWS S3, GCS, R2, RustFS) put its own here and set CLOUDHAL_S3_ENDPOINT.", `AWS_ACCESS_KEY_ID=cloudhal${Buffer.from(random(8)).toString("hex")}`, diff --git a/packages/cli/src/selfhost/settings.ts b/packages/cli/src/selfhost/settings.ts index 8a88a6ba..67f4c713 100644 --- a/packages/cli/src/selfhost/settings.ts +++ b/packages/cli/src/selfhost/settings.ts @@ -22,6 +22,12 @@ export const REQUIRED_SECRETS = [ "CLOUDHAL_COMMENTS_KEY", ] as const; +/** + * Secrets the manifest lists that an installation may leave unset (RFC-0048 §2.2: the upload + * signing key, else the preview secret). Unset, workerd gets an empty value for the binding. + */ +export const OPTIONAL_SECRETS = ["CLOUDHAL_UPLOAD_SECRET"] as const; + /** Read through `_FILE` too, but not handed to the Workers (workerd's own S3 client reads them). */ const STORE_SECRETS = ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"] as const; @@ -63,7 +69,14 @@ export interface SelfhostSettings { export type Env = Readonly>; const SITE_ID = /^site_[A-Za-z0-9]{6,32}$/; -const PASSED_VARS = ["CLOUDHAL_AUTOMATIONS", "CLOUDHAL_TICK_BUDGET", "CLOUDHAL_COMMENTS_AVAILABLE"]; +const PASSED_VARS = [ + "CLOUDHAL_AUTOMATIONS", + "CLOUDHAL_TICK_BUDGET", + "CLOUDHAL_COMMENTS_AVAILABLE", + // RFC-0048: agents' upload links off, or their cap per file. + "CLOUDHAL_AGENT_UPLOADS", + "CLOUDHAL_AGENT_UPLOAD_BYTES", +]; /** * `env` with every `_FILE` of a secret resolved into ``. A name set both ways is an @@ -76,6 +89,7 @@ export function resolveSecretFiles( const out: Record = { ...env }; for (const name of [ ...REQUIRED_SECRETS, + ...OPTIONAL_SECRETS, ...STORE_SECRETS, "CLOUDHAL_CLUSTER_KEY", "CLOUDHAL_SITE_ID", @@ -96,6 +110,7 @@ export function resolveSecretFiles( out[name] = value.endsWith("\n") ? value.slice(0, -1) : value; delete out[`${name}_FILE`]; } + for (const name of OPTIONAL_SECRETS) out[name] ??= ""; return out; } @@ -114,6 +129,11 @@ function problems(env: Env): string[] { const out: string[] = []; for (const name of REQUIRED_SECRETS) if (!env[name]) out.push(`${name} (or ${name}_FILE) is not set`); + for (const name of OPTIONAL_SECRETS) + if (env[name] && (env[name] as string).length < 32) + out.push( + `${name}: at least 32 characters when set (openssl rand -hex 32), or leave it unset`, + ); const key = env.CLOUDHAL_CLUSTER_KEY ?? ""; if (key.length < 32) out.push("CLOUDHAL_CLUSTER_KEY: at least 32 characters (openssl rand -hex 32)"); diff --git a/packages/cli/test/config-media.test.ts b/packages/cli/test/config-media.test.ts new file mode 100644 index 00000000..48c2cf5e --- /dev/null +++ b/packages/cli/test/config-media.test.ts @@ -0,0 +1,65 @@ +/** + * RFC-0048: `cloudhal.json` `media.agentUploads` and `media.agentUploadBytes` are read leniently, + * become the admin Worker's vars, and are deploy-time keys (a release bundle never refuses them). + */ +import { mkdtemp, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import { describe, expect, it } from "vitest"; +import { adminWorkerConfig } from "../src/cloudflare/config.ts"; +import { buildKeyProblems } from "../src/config-build-keys.ts"; +import { agentUploadVars, parseAgentUploads, readAgentUploads } from "../src/config-media.ts"; + +const names = { name: "news", databaseName: "news-db", bucketName: "news-files" }; +const admin = { ...names, studioDir: "studio", main: "./worker.ts" }; + +describe("cloudhal.json media: agent upload links", () => { + it("reads the two keys leniently and leaves the starter's keys alone", () => { + expect( + parseAgentUploads({ media: { agentUploads: false, agentUploadBytes: 1_000_000 } }), + ).toEqual({ agentUploads: false, agentUploadBytes: 1_000_000 }); + expect(parseAgentUploads({ media: { transform: "none" } })).toBeUndefined(); + expect(parseAgentUploads({ media: { agentUploads: true } })).toBeUndefined(); + expect(parseAgentUploads({ media: { agentUploadBytes: 200 * 1024 * 1024 } })).toBeUndefined(); + expect(parseAgentUploads({ media: { agentUploadBytes: 1.5 } })).toBeUndefined(); + expect(parseAgentUploads({})).toBeUndefined(); + }); + + it("reads the project's file, and nothing without one", async () => { + const dir = await mkdtemp(path.join(tmpdir(), "cloudhal-media-")); + try { + expect(await readAgentUploads(dir)).toBeUndefined(); + await writeFile( + path.join(dir, "cloudhal.json"), + JSON.stringify({ siteId: "site_abcdefgh", media: { agentUploadBytes: 5_000_000 } }), + ); + expect(await readAgentUploads(dir)).toEqual({ agentUploadBytes: 5_000_000 }); + } finally { + await rm(dir, { recursive: true, force: true }); + } + }); + + it("become the admin Worker's vars, and only when set", () => { + expect(agentUploadVars(undefined)).toEqual({}); + const vars = adminWorkerConfig({ + ...admin, + uploads: { agentUploads: false, agentUploadBytes: 1_000_000 }, + }).vars as Record; + expect(vars).toMatchObject({ + CLOUDHAL_AGENT_UPLOADS: "off", + CLOUDHAL_AGENT_UPLOAD_BYTES: "1000000", + }); + const none = adminWorkerConfig(admin).vars as Record; + expect(none).not.toHaveProperty("CLOUDHAL_AGENT_UPLOADS"); + expect(none).not.toHaveProperty("CLOUDHAL_AGENT_UPLOAD_BYTES"); + }); + + it("are deploy keys: a release bundle takes any value", () => { + expect( + buildKeyProblems( + { siteId: "site_abcdefgh", media: { agentUploads: false, agentUploadBytes: 1000 } }, + {}, + ), + ).toEqual([]); + }); +}); diff --git a/packages/cli/test/deploy-workers-builds.test.ts b/packages/cli/test/deploy-workers-builds.test.ts index 5fc096cb..31519777 100644 --- a/packages/cli/test/deploy-workers-builds.test.ts +++ b/packages/cli/test/deploy-workers-builds.test.ts @@ -189,6 +189,7 @@ describe("cloudhal deploy in Workers Builds", () => { "CLOUDHAL_PREVIEW_SECRET", "CLOUDHAL_PURGE_TOKEN", "CLOUDHAL_SETUP_TOKEN", + "CLOUDHAL_UPLOAD_SECRET", "MCP_STATE_KEY", ], }); diff --git a/packages/cli/test/deploy.test.ts b/packages/cli/test/deploy.test.ts index 26e1d086..e425aa7b 100644 --- a/packages/cli/test/deploy.test.ts +++ b/packages/cli/test/deploy.test.ts @@ -167,6 +167,7 @@ describe("cloudhal deploy", () => { "CLOUDHAL_PREVIEW_SECRET", "CLOUDHAL_PURGE_TOKEN", "CLOUDHAL_SETUP_TOKEN", + "CLOUDHAL_UPLOAD_SECRET", "MCP_STATE_KEY", ]); for (const v of Object.values(secrets)) expect(v.length).toBeGreaterThanOrEqual(32); @@ -355,6 +356,7 @@ describe("cloudhal deploy", () => { "CLOUDHAL_PREVIEW_SECRET", "CLOUDHAL_PURGE_TOKEN", "CLOUDHAL_SETUP_TOKEN", + "CLOUDHAL_UPLOAD_SECRET", "MCP_STATE_KEY", ], ]); diff --git a/packages/cli/test/selfhost.test.ts b/packages/cli/test/selfhost.test.ts index e22788fa..78bbb8e7 100644 --- a/packages/cli/test/selfhost.test.ts +++ b/packages/cli/test/selfhost.test.ts @@ -103,6 +103,25 @@ describe("selfhost settings", () => { /AWS_SECRET_ACCESS_KEY_FILE: cannot read/, ); }); + + it("takes the optional CLOUDHAL_UPLOAD_SECRET (RFC-0048) from _FILE, as empty when unset", () => { + expect(ENV.CLOUDHAL_UPLOAD_SECRET).toMatch(/^[0-9a-f]{64}$/); // `secrets` generates it + const { CLOUDHAL_UPLOAD_SECRET: _u, ...without } = ENV; + const unset = resolveSecretFiles(without); + expect(unset.CLOUDHAL_UPLOAD_SECRET).toBe(""); + expect(() => readSettings(unset)).not.toThrow(); + const fromFile = resolveSecretFiles( + { ...without, CLOUDHAL_UPLOAD_SECRET_FILE: "/run/secrets/upload" }, + () => `${"u".repeat(40)}\n`, + ); + expect(fromFile.CLOUDHAL_UPLOAD_SECRET).toBe("u".repeat(40)); + expect(() => readSettings({ ...ENV, CLOUDHAL_UPLOAD_SECRET: "short" })).toThrow( + /CLOUDHAL_UPLOAD_SECRET: at least 32 characters/, + ); + expect(readSettings({ ...ENV, CLOUDHAL_AGENT_UPLOADS: "off" }).adminVars).toMatchObject({ + CLOUDHAL_AGENT_UPLOADS: "off", + }); + }); }); async function extracted() { diff --git a/packages/cloudflare/README.md b/packages/cloudflare/README.md index ca81e012..d558854b 100644 --- a/packages/cloudflare/README.md +++ b/packages/cloudflare/README.md @@ -18,6 +18,8 @@ export default createAdminWorker({ skills }); | `BETTER_AUTH_SECRET`, `MCP_STATE_KEY` | sessions; signed approval state | | `CLOUDHAL_PREVIEW_SECRET`, `CLOUDHAL_PURGE_TOKEN` | shared with the site Worker | | `CLOUDHAL_DEPLOY_TOKEN` | `cloudhal push` / `pull` | +| `CLOUDHAL_UPLOAD_SECRET` | signs upload tickets and agents' upload links (RFC-0048; the preview secret without it) | +| `CLOUDHAL_AGENT_UPLOADS`, `CLOUDHAL_AGENT_UPLOAD_BYTES` | `off` turns agents' upload links off; their cap per file in bytes | | `CLOUDHAL_SIGNUP` | `first-user` (default — only the first account, the owner, can sign up), `closed` or `open` | The site Worker itself is the project's Astro build (`@cloudhal/astro-renderer/cloudflare-entry`). Both are deployed, configured and tested by `@cloudhal/cli` (`cloudhal deploy`, `test/cloudflare*.test.ts` on workerd). diff --git a/packages/cloudflare/src/admin-worker.ts b/packages/cloudflare/src/admin-worker.ts index 0facee22..5fc1210f 100644 --- a/packages/cloudflare/src/admin-worker.ts +++ b/packages/cloudflare/src/admin-worker.ts @@ -65,6 +65,7 @@ import { SqlScheduleStore } from "@cloudhal/schedules/sql"; import { migrate, migrations, type SqlDriver } from "@cloudhal/storage"; import type { D1Driver } from "@cloudhal/storage/d1"; import { R2BlobStore } from "@cloudhal/storage/r2"; +import { agentUploadMedia } from "./agent-uploads.ts"; import { adminRender, type DevtoolsBinding } from "./browser-cdp.ts"; import type { BrowserBinding } from "./browser-render.ts"; import { type BuildRoomsEnv, buildRoomClass, createDurableBuildHub } from "./build-rooms.ts"; @@ -100,6 +101,9 @@ export interface AdminEnv extends CommentsEnv, SchedulerEnv, MailEnv, BuildRooms CLOUDHAL_PREVIEW_SECRET?: string; /** RFC-0048 §2.2: the upload signing key (≥ 32 chars); the preview secret otherwise. */ CLOUDHAL_UPLOAD_SECRET?: string; + /** RFC-0048: `off` turns agents' upload links off; a cap per file in bytes. */ + CLOUDHAL_AGENT_UPLOADS?: string; + CLOUDHAL_AGENT_UPLOAD_BYTES?: string; CLOUDHAL_PURGE_TOKEN?: string; CLOUDHAL_DEPLOY_TOKEN?: string; /** One-time token the first account must present (see `cloudhal deploy` output). */ @@ -515,7 +519,7 @@ export function createAdminWorker(options: AdminWorkerOptions = {}) { oauth: auth.oauth && { issuer: auth.oauth.issuer, resource: auth.oauth.resource }, // fetch_asset_url never reaches this Worker's own host (Studio, API, purge); each site's // domains are refused too. Workers cannot pin DNS: see `workersTransport` (RFC-0004 §5.7). - media: { blockedHosts: [url.hostname] }, + media: { blockedHosts: [url.hostname], ...agentUploadMedia(env) }, // RFC-0021 §4: render_page opens the preview link in Browser Rendering or a sidecar. ...adminRender(env), }, diff --git a/packages/cloudflare/src/agent-uploads.ts b/packages/cloudflare/src/agent-uploads.ts new file mode 100644 index 00000000..8a36a0f4 --- /dev/null +++ b/packages/cloudflare/src/agent-uploads.ts @@ -0,0 +1,28 @@ +/** + * RFC-0048: the admin Worker's settings for agents' upload links, from its vars (written by + * `cloudhal deploy` from `cloudhal.json` `media`, or set by a self-host operator): + * `CLOUDHAL_AGENT_UPLOADS=off` turns them off, `CLOUDHAL_AGENT_UPLOAD_BYTES` caps a file (1 byte to + * 100 MB; default 25 MB). Anything else is ignored. + */ +export interface AgentUploadsEnv { + CLOUDHAL_AGENT_UPLOADS?: string; + CLOUDHAL_AGENT_UPLOAD_BYTES?: string; +} + +const MAX_BYTES = 100 * 1024 * 1024; + +/** The MCP media options they set (`MediaToolOptions.agentUploads`, `agentUploadBytes`). */ +export function agentUploadMedia(env: AgentUploadsEnv): { + agentUploads?: false; + agentUploadBytes?: number; +} { + const bytes = Number(env.CLOUDHAL_AGENT_UPLOAD_BYTES); + return { + ...(env.CLOUDHAL_AGENT_UPLOADS?.trim().toLowerCase() === "off" + ? { agentUploads: false as const } + : {}), + ...(Number.isInteger(bytes) && bytes >= 1 && bytes <= MAX_BYTES + ? { agentUploadBytes: bytes } + : {}), + }; +} diff --git a/packages/cloudflare/test/agent-uploads.test.ts b/packages/cloudflare/test/agent-uploads.test.ts new file mode 100644 index 00000000..45fbda5b --- /dev/null +++ b/packages/cloudflare/test/agent-uploads.test.ts @@ -0,0 +1,15 @@ +import { describe, expect, it } from "vitest"; +import { agentUploadMedia } from "../src/agent-uploads.ts"; + +describe("RFC-0048: the admin Worker's upload-link vars", () => { + it("turns links off with `off`, takes a cap of 1 byte to 100 MB, and ignores anything else", () => { + expect(agentUploadMedia({})).toEqual({}); + expect(agentUploadMedia({ CLOUDHAL_AGENT_UPLOADS: " OFF " })).toEqual({ agentUploads: false }); + expect(agentUploadMedia({ CLOUDHAL_AGENT_UPLOADS: "on" })).toEqual({}); + expect(agentUploadMedia({ CLOUDHAL_AGENT_UPLOAD_BYTES: "1000000" })).toEqual({ + agentUploadBytes: 1_000_000, + }); + for (const bad of ["0", "-1", "1.5", "lots", String(101 * 1024 * 1024)]) + expect(agentUploadMedia({ CLOUDHAL_AGENT_UPLOAD_BYTES: bad })).toEqual({}); + }); +}); diff --git a/packages/core-contracts/fixtures/invalid/release-manifest/secret-name-unknown.json b/packages/core-contracts/fixtures/invalid/release-manifest/secret-name-unknown.json new file mode 100644 index 00000000..e5978480 --- /dev/null +++ b/packages/core-contracts/fixtures/invalid/release-manifest/secret-name-unknown.json @@ -0,0 +1,194 @@ +{ + "reason": "a Worker secret outside SecretName (RFC-0046; RFC-0048 added CLOUDHAL_UPLOAD_SECRET)", + "data": { + "schemaVersion": 1, + "format": "cloudhal.release-manifest@1", + "version": "0.6.3", + "channel": "stable", + "securityRelease": false, + "commit": "e433958d370ef64c6c21063c150bb8cd085404eb", + "createdAt": "2026-11-08T10:00:00Z", + "contracts": { + "schemaVersion": 1 + }, + "levels": { + "schedules": 2, + "gates": 1 + }, + "migrations": { + "first": "0001_init", + "last": "0042_comments", + "count": 42, + "names": ["0001_init", "0042_comments"], + "compatibleWithPrevious": true + }, + "durableObjects": { + "bindings": [ + { + "name": "SCHEDULER", + "className": "Scheduler", + "migration": "v1" + } + ], + "lifecycleChange": false + }, + "runtime": { + "compatibilityDate": "2026-10-01", + "compatibilityFlags": ["nodejs_compat"] + }, + "toolchain": { + "wrangler": "4.158.0", + "node": "24.15.0" + }, + "theme": { + "name": "default", + "version": "0.6.3", + "blockTypes": ["hero", "richText"], + "settingsSha256": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", + "designSha256": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + }, + "skills": [ + { + "name": "cloudhal-site", + "sha256": "1111111111111111111111111111111111111111111111111111111111111111" + } + ], + "workers": { + "site": { + "mainModule": "index.js", + "modules": [ + { + "path": "index.js", + "type": "esm", + "bytes": 1024, + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + } + ], + "assets": { + "count": 1, + "bytes": 512, + "files": [ + { + "path": "/index.html", + "bytes": 512, + "sha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + "assetHash": "dddddddddddddddddddddddddddddddd", + "contentType": "text/html" + } + ], + "headers": "/*\n x-content-type-options: nosniff\n", + "config": { + "not_found_handling": "404-page", + "run_worker_first": ["/api/*"] + } + }, + "bindingTemplate": "site" + }, + "admin": { + "mainModule": "index.js", + "modules": [ + { + "path": "index.js", + "type": "esm", + "bytes": 2048, + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + } + ], + "assets": { + "count": 1, + "bytes": 512, + "files": [ + { + "path": "/index.html", + "bytes": 512, + "sha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + "assetHash": "dddddddddddddddddddddddddddddddd", + "contentType": "text/html" + } + ], + "headers": "/*\n x-content-type-options: nosniff\n", + "config": { + "not_found_handling": "404-page", + "run_worker_first": ["/api/*"] + } + }, + "bindingTemplate": "admin" + } + }, + "bindingTemplates": { + "site": { + "bindings": [ + { + "name": "DB", + "type": "d1", + "required": true + }, + { + "name": "BLOBS", + "type": "r2_bucket", + "required": true, + "aliases": ["MEDIA"] + } + ], + "vars": ["CLOUDHAL_SCHEDULER"], + "secrets": ["CLOUDHAL_PREVIEW_SECRET", "CLOUDHAL_PURGE_TOKEN", "CLOUDHAL_COMMENTS_KEY"], + "cache": true + }, + "admin": { + "bindings": [ + { + "name": "DB", + "type": "d1", + "required": true + }, + { + "name": "BLOBS", + "type": "r2_bucket", + "required": true, + "aliases": ["MEDIA"] + } + ], + "vars": ["CLOUDHAL_SCHEDULER"], + "secrets": [ + "BETTER_AUTH_SECRET", + "MCP_STATE_KEY", + "CLOUDHAL_PREVIEW_SECRET", + "CLOUDHAL_PURGE_TOKEN", + "CLOUDHAL_DEPLOY_TOKEN", + "CLOUDHAL_SETUP_TOKEN", + "CLOUDHAL_COMMENTS_KEY", + "CLOUDHAL_SOMETHING_ELSE" + ], + "cache": true + } + }, + "requiredScopes": [ + "account-settings.read", + "workers-scripts.admin", + "d1.write", + "workers-r2.write" + ], + "optionalScopes": ["account-analytics.read"], + "requiredCapabilities": ["account", "workers", "d1", "r2"], + "optionalCapabilities": ["analytics", "domains"], + "starter": { + "kind": "bundle", + "path": "starter/site.json", + "bytes": 4096, + "sha256": "2222222222222222222222222222222222222222222222222222222222222222", + "siteId": "site_01JC0FXR3Z8K2M4N6P8Q" + }, + "features": { + "adminSitesAcceptsSiteId": true, + "healthReportsVersion": true, + "mediaTransformVar": false, + "futureFlag": true + }, + "planVersion": 1, + "signing": { + "keyId": "cloudhal-release-2026", + "algorithm": "Ed25519", + "signature": "manifest.sig" + } + } +} diff --git a/packages/core-contracts/fixtures/valid/release-manifest/admin-upload-secret.json b/packages/core-contracts/fixtures/valid/release-manifest/admin-upload-secret.json new file mode 100644 index 00000000..e8dda252 --- /dev/null +++ b/packages/core-contracts/fixtures/valid/release-manifest/admin-upload-secret.json @@ -0,0 +1,191 @@ +{ + "schemaVersion": 1, + "format": "cloudhal.release-manifest@1", + "version": "0.6.3", + "channel": "stable", + "securityRelease": false, + "commit": "e433958d370ef64c6c21063c150bb8cd085404eb", + "createdAt": "2026-11-08T10:00:00Z", + "contracts": { + "schemaVersion": 1 + }, + "levels": { + "schedules": 2, + "gates": 1 + }, + "migrations": { + "first": "0001_init", + "last": "0042_comments", + "count": 42, + "names": ["0001_init", "0042_comments"], + "compatibleWithPrevious": true + }, + "durableObjects": { + "bindings": [ + { + "name": "SCHEDULER", + "className": "Scheduler", + "migration": "v1" + } + ], + "lifecycleChange": false + }, + "runtime": { + "compatibilityDate": "2026-10-01", + "compatibilityFlags": ["nodejs_compat"] + }, + "toolchain": { + "wrangler": "4.158.0", + "node": "24.15.0" + }, + "theme": { + "name": "default", + "version": "0.6.3", + "blockTypes": ["hero", "richText"], + "settingsSha256": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", + "designSha256": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + }, + "skills": [ + { + "name": "cloudhal-site", + "sha256": "1111111111111111111111111111111111111111111111111111111111111111" + } + ], + "workers": { + "site": { + "mainModule": "index.js", + "modules": [ + { + "path": "index.js", + "type": "esm", + "bytes": 1024, + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + } + ], + "assets": { + "count": 1, + "bytes": 512, + "files": [ + { + "path": "/index.html", + "bytes": 512, + "sha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + "assetHash": "dddddddddddddddddddddddddddddddd", + "contentType": "text/html" + } + ], + "headers": "/*\n x-content-type-options: nosniff\n", + "config": { + "not_found_handling": "404-page", + "run_worker_first": ["/api/*"] + } + }, + "bindingTemplate": "site" + }, + "admin": { + "mainModule": "index.js", + "modules": [ + { + "path": "index.js", + "type": "esm", + "bytes": 2048, + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + } + ], + "assets": { + "count": 1, + "bytes": 512, + "files": [ + { + "path": "/index.html", + "bytes": 512, + "sha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + "assetHash": "dddddddddddddddddddddddddddddddd", + "contentType": "text/html" + } + ], + "headers": "/*\n x-content-type-options: nosniff\n", + "config": { + "not_found_handling": "404-page", + "run_worker_first": ["/api/*"] + } + }, + "bindingTemplate": "admin" + } + }, + "bindingTemplates": { + "site": { + "bindings": [ + { + "name": "DB", + "type": "d1", + "required": true + }, + { + "name": "BLOBS", + "type": "r2_bucket", + "required": true, + "aliases": ["MEDIA"] + } + ], + "vars": ["CLOUDHAL_SCHEDULER"], + "secrets": ["CLOUDHAL_PREVIEW_SECRET", "CLOUDHAL_PURGE_TOKEN", "CLOUDHAL_COMMENTS_KEY"], + "cache": true + }, + "admin": { + "bindings": [ + { + "name": "DB", + "type": "d1", + "required": true + }, + { + "name": "BLOBS", + "type": "r2_bucket", + "required": true, + "aliases": ["MEDIA"] + } + ], + "vars": ["CLOUDHAL_SCHEDULER"], + "secrets": [ + "BETTER_AUTH_SECRET", + "MCP_STATE_KEY", + "CLOUDHAL_PREVIEW_SECRET", + "CLOUDHAL_PURGE_TOKEN", + "CLOUDHAL_DEPLOY_TOKEN", + "CLOUDHAL_SETUP_TOKEN", + "CLOUDHAL_COMMENTS_KEY", + "CLOUDHAL_UPLOAD_SECRET" + ], + "cache": true + } + }, + "requiredScopes": [ + "account-settings.read", + "workers-scripts.admin", + "d1.write", + "workers-r2.write" + ], + "optionalScopes": ["account-analytics.read"], + "requiredCapabilities": ["account", "workers", "d1", "r2"], + "optionalCapabilities": ["analytics", "domains"], + "starter": { + "kind": "bundle", + "path": "starter/site.json", + "bytes": 4096, + "sha256": "2222222222222222222222222222222222222222222222222222222222222222", + "siteId": "site_01JC0FXR3Z8K2M4N6P8Q" + }, + "features": { + "adminSitesAcceptsSiteId": true, + "healthReportsVersion": true, + "mediaTransformVar": false, + "futureFlag": true + }, + "planVersion": 1, + "signing": { + "keyId": "cloudhal-release-2026", + "algorithm": "Ed25519", + "signature": "manifest.sig" + } +} diff --git a/packages/core-contracts/schemas/release-manifest.schema.json b/packages/core-contracts/schemas/release-manifest.schema.json index 3298f19e..84df139d 100644 --- a/packages/core-contracts/schemas/release-manifest.schema.json +++ b/packages/core-contracts/schemas/release-manifest.schema.json @@ -387,7 +387,8 @@ "CLOUDHAL_PURGE_TOKEN", "CLOUDHAL_DEPLOY_TOKEN", "CLOUDHAL_SETUP_TOKEN", - "CLOUDHAL_COMMENTS_KEY" + "CLOUDHAL_COMMENTS_KEY", + "CLOUDHAL_UPLOAD_SECRET" ] }, "WorkerArtifact": { diff --git a/packages/core-contracts/src/generated/release-manifest.ts b/packages/core-contracts/src/generated/release-manifest.ts index e0e49fb5..ae16eb5b 100644 --- a/packages/core-contracts/src/generated/release-manifest.ts +++ b/packages/core-contracts/src/generated/release-manifest.ts @@ -50,7 +50,8 @@ export type SecretName = | "CLOUDHAL_PURGE_TOKEN" | "CLOUDHAL_DEPLOY_TOKEN" | "CLOUDHAL_SETUP_TOKEN" - | "CLOUDHAL_COMMENTS_KEY"; + | "CLOUDHAL_COMMENTS_KEY" + | "CLOUDHAL_UPLOAD_SECRET"; /** * This interface was referenced by `ReleaseManifest`'s JSON-Schema * via the `definition` "ScopeId". diff --git a/packages/core-contracts/src/generated/schemas.ts b/packages/core-contracts/src/generated/schemas.ts index 21bda1c8..c9fd7c1c 100644 --- a/packages/core-contracts/src/generated/schemas.ts +++ b/packages/core-contracts/src/generated/schemas.ts @@ -9210,7 +9210,8 @@ export const ReleaseManifestSchema = { "CLOUDHAL_PURGE_TOKEN", "CLOUDHAL_DEPLOY_TOKEN", "CLOUDHAL_SETUP_TOKEN", - "CLOUDHAL_COMMENTS_KEY" + "CLOUDHAL_COMMENTS_KEY", + "CLOUDHAL_UPLOAD_SECRET" ] }, "Sha256Hex": { diff --git a/packages/core-contracts/src/generated/validators.js b/packages/core-contracts/src/generated/validators.js index 7819b739..e04526b4 100644 --- a/packages/core-contracts/src/generated/validators.js +++ b/packages/core-contracts/src/generated/validators.js @@ -43769,7 +43769,7 @@ return errors === 0; validate242.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; export const validateReleaseManifest = validate245; -const schema576 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cloudhal.dev/schemas/v1/release-manifest.schema.json","title":"ReleaseManifest","description":"cloudhal.release-manifest@1 (RFC-0046): the manifest of one Cloudhal release bundle, published as the release asset manifest.json next to the gzip tarball cloudhal-release-.tar.gz. A project release is signed through release-statement.json, which pins this file's SHA-256 and size (signing.signature = release-statement.sig); the legacy form manifest.sig, a raw 64-byte Ed25519 signature over these exact bytes, is for development keys only. It describes every built Worker module and static asset by size and SHA-256, the binding templates, feature levels, migration range and rollback facts a remote deployer needs to install, update or refuse a version without running a build. Portable on purpose: it references common only for SchemaVersion and Timestamp; every other definition is local.","type":"object","additionalProperties":false,"required":["schemaVersion","format","version","channel","securityRelease","commit","createdAt","contracts","levels","migrations","durableObjects","runtime","toolchain","theme","skills","workers","bindingTemplates","requiredScopes","optionalScopes","requiredCapabilities","optionalCapabilities","starter","features","planVersion","signing"],"properties":{"schemaVersion":{"$ref":"#/$defs/SchemaVersion"},"format":{"type":"string","enum":["cloudhal.release-manifest@1"]},"version":{"$ref":"#/$defs/CloudhalVersion"},"channel":{"type":"string","enum":["stable","next"]},"securityRelease":{"type":"boolean"},"commit":{"type":"string","pattern":"^[0-9a-f]{40}$"},"createdAt":{"$ref":"#/$defs/Timestamp"},"contracts":{"type":"object","additionalProperties":false,"required":["schemaVersion"],"properties":{"schemaVersion":{"type":"integer","enum":[1]}}},"levels":{"type":"object","additionalProperties":false,"required":["schedules","gates"],"properties":{"schedules":{"type":"integer","minimum":0},"gates":{"type":"integer","minimum":0}}},"migrations":{"type":"object","additionalProperties":false,"required":["first","last","count","names","compatibleWithPrevious"],"properties":{"first":{"$ref":"#/$defs/MigrationName"},"last":{"$ref":"#/$defs/MigrationName"},"count":{"type":"integer","minimum":1},"names":{"type":"array","minItems":1,"uniqueItems":true,"items":{"$ref":"#/$defs/MigrationName"}},"compatibleWithPrevious":{"type":"boolean"}}},"durableObjects":{"type":"object","additionalProperties":false,"required":["bindings","lifecycleChange"],"properties":{"bindings":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","className","migration"],"properties":{"name":{"$ref":"#/$defs/BindingName"},"className":{"type":"string","pattern":"^[A-Z][A-Za-z0-9]*$"},"migration":{"type":"string","pattern":"^v[1-9][0-9]*$"}}}},"lifecycleChange":{"type":"boolean"}}},"runtime":{"type":"object","additionalProperties":false,"required":["compatibilityDate","compatibilityFlags"],"properties":{"compatibilityDate":{"type":"string","pattern":"^[0-9]{4}-[0-9]{2}-[0-9]{2}$"},"compatibilityFlags":{"type":"array","uniqueItems":true,"items":{"type":"string","pattern":"^[a-z0-9_]+$"}}}},"toolchain":{"type":"object","additionalProperties":{"type":"string","maxLength":64}},"theme":{"type":"object","additionalProperties":false,"required":["name","version","blockTypes","settingsSha256","designSha256"],"properties":{"name":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$"},"version":{"type":"string","maxLength":64},"blockTypes":{"type":"array","uniqueItems":true,"items":{"type":"string"}},"settingsSha256":{"$ref":"#/$defs/Sha256Hex"},"designSha256":{"$ref":"#/$defs/Sha256Hex"}}},"skills":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","sha256"],"properties":{"name":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$"},"sha256":{"$ref":"#/$defs/Sha256Hex"}}}},"workers":{"type":"object","additionalProperties":false,"required":["site","admin"],"properties":{"site":{"$ref":"#/$defs/WorkerArtifact"},"admin":{"$ref":"#/$defs/WorkerArtifact"}}},"bindingTemplates":{"type":"object","additionalProperties":false,"required":["site","admin"],"properties":{"site":{"$ref":"#/$defs/BindingTemplate"},"admin":{"$ref":"#/$defs/BindingTemplate"}}},"requiredScopes":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/ScopeId"}},"optionalScopes":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/ScopeId"}},"requiredCapabilities":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/Capability"}},"optionalCapabilities":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/Capability"}},"starter":{"oneOf":[{"type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"type":"string","enum":["admin-api"]}}},{"type":"object","additionalProperties":false,"required":["kind","path","bytes","sha256","siteId"],"properties":{"kind":{"type":"string","enum":["bundle"]},"path":{"type":"string","pattern":"^starter/[A-Za-z0-9._-]+$"},"bytes":{"type":"integer","minimum":1},"sha256":{"$ref":"#/$defs/Sha256Hex"},"siteId":{"$ref":"#/$defs/SiteId"}}}]},"features":{"type":"object","additionalProperties":{"type":"boolean"},"required":["adminSitesAcceptsSiteId","healthReportsVersion","mediaTransformVar"],"properties":{"adminSitesAcceptsSiteId":{"type":"boolean"},"healthReportsVersion":{"type":"boolean"},"mediaTransformVar":{"type":"boolean"}}},"planVersion":{"type":"integer","minimum":1},"signing":{"type":"object","additionalProperties":false,"required":["keyId","algorithm","signature"],"properties":{"keyId":{"type":"string","pattern":"^[a-z0-9][a-z0-9-]{2,63}$"},"algorithm":{"type":"string","enum":["Ed25519"]},"signature":{"type":"string","enum":["manifest.sig","release-statement.sig"]}}}},"$defs":{"BindingName":{"type":"string","pattern":"^[A-Z][A-Z0-9_]*(_\\*)?$"},"BindingTemplate":{"type":"object","additionalProperties":false,"required":["bindings","vars","secrets"],"properties":{"bindings":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","type","required"],"properties":{"name":{"$ref":"#/$defs/BindingName"},"type":{"type":"string","enum":["d1","r2_bucket","assets","service","durable_object_namespace","analytics_engine","analytics_sql","ratelimit","ai_search","send_email","ai","browser"]},"required":{"type":"boolean"},"aliases":{"type":"array","items":{"$ref":"#/$defs/BindingName"}}}}},"vars":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/BindingName"}},"secrets":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/SecretName"}},"cache":{"type":"boolean"},"cron":{"type":"string","pattern":"^[0-9*/,\\- ]+$"}}},"Capability":{"type":"string","enum":["account","workers","d1","r2","analytics","domains"]},"CloudhalVersion":{"type":"string","pattern":"^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?$"},"MigrationName":{"type":"string","pattern":"^[0-9]{4}_[a-z0-9_]+$"},"SchemaVersion":{"type":"integer","description":"Version of this contract. Readers reject unknown versions; migrations move documents forward one version at a time.","enum":[1]},"ScopeId":{"type":"string","pattern":"^[a-z0-9-]+(\\.[a-z0-9-]+)+$"},"SecretName":{"type":"string","enum":["BETTER_AUTH_SECRET","MCP_STATE_KEY","CLOUDHAL_PREVIEW_SECRET","CLOUDHAL_PURGE_TOKEN","CLOUDHAL_DEPLOY_TOKEN","CLOUDHAL_SETUP_TOKEN","CLOUDHAL_COMMENTS_KEY"]},"Sha256Hex":{"type":"string","pattern":"^[0-9a-f]{64}$"},"SiteId":{"type":"string","pattern":"^site_[A-Za-z0-9]{6,32}$"},"Timestamp":{"type":"string","description":"RFC 3339 / ISO 8601 instant in UTC.","format":"date-time"},"WorkerArtifact":{"type":"object","additionalProperties":false,"required":["mainModule","modules","assets"],"properties":{"mainModule":{"type":"string","pattern":"^[A-Za-z0-9._/-]+$"},"modules":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["path","type","bytes","sha256"],"properties":{"path":{"type":"string","pattern":"^[A-Za-z0-9._-]+(/[A-Za-z0-9._-]+)*$"},"type":{"type":"string","enum":["esm","cjs","wasm","text","data"]},"bytes":{"type":"integer","minimum":1},"sha256":{"$ref":"#/$defs/Sha256Hex"}}}},"assets":{"type":"object","additionalProperties":false,"required":["count","bytes","files","headers"],"properties":{"count":{"type":"integer","minimum":0,"maximum":20000},"bytes":{"type":"integer","minimum":0},"files":{"type":"array","maxItems":20000,"items":{"type":"object","additionalProperties":false,"required":["path","bytes","sha256","assetHash","contentType"],"properties":{"path":{"type":"string","pattern":"^/[^\\s]*$","maxLength":1024},"bytes":{"type":"integer","minimum":0,"maximum":26214400},"sha256":{"$ref":"#/$defs/Sha256Hex"},"assetHash":{"type":"string","pattern":"^[0-9a-f]{32}$"},"contentType":{"type":"string","maxLength":128}}}},"headers":{"type":"string","maxLength":100000},"config":{"type":"object","additionalProperties":false,"properties":{"not_found_handling":{"type":"string","enum":["none","404-page","single-page-application"]},"run_worker_first":{"type":"array","items":{"type":"string","pattern":"^/"}}}}}},"bindingTemplate":{"type":"string","enum":["site","admin"]}}}}}; +const schema576 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cloudhal.dev/schemas/v1/release-manifest.schema.json","title":"ReleaseManifest","description":"cloudhal.release-manifest@1 (RFC-0046): the manifest of one Cloudhal release bundle, published as the release asset manifest.json next to the gzip tarball cloudhal-release-.tar.gz. A project release is signed through release-statement.json, which pins this file's SHA-256 and size (signing.signature = release-statement.sig); the legacy form manifest.sig, a raw 64-byte Ed25519 signature over these exact bytes, is for development keys only. It describes every built Worker module and static asset by size and SHA-256, the binding templates, feature levels, migration range and rollback facts a remote deployer needs to install, update or refuse a version without running a build. Portable on purpose: it references common only for SchemaVersion and Timestamp; every other definition is local.","type":"object","additionalProperties":false,"required":["schemaVersion","format","version","channel","securityRelease","commit","createdAt","contracts","levels","migrations","durableObjects","runtime","toolchain","theme","skills","workers","bindingTemplates","requiredScopes","optionalScopes","requiredCapabilities","optionalCapabilities","starter","features","planVersion","signing"],"properties":{"schemaVersion":{"$ref":"#/$defs/SchemaVersion"},"format":{"type":"string","enum":["cloudhal.release-manifest@1"]},"version":{"$ref":"#/$defs/CloudhalVersion"},"channel":{"type":"string","enum":["stable","next"]},"securityRelease":{"type":"boolean"},"commit":{"type":"string","pattern":"^[0-9a-f]{40}$"},"createdAt":{"$ref":"#/$defs/Timestamp"},"contracts":{"type":"object","additionalProperties":false,"required":["schemaVersion"],"properties":{"schemaVersion":{"type":"integer","enum":[1]}}},"levels":{"type":"object","additionalProperties":false,"required":["schedules","gates"],"properties":{"schedules":{"type":"integer","minimum":0},"gates":{"type":"integer","minimum":0}}},"migrations":{"type":"object","additionalProperties":false,"required":["first","last","count","names","compatibleWithPrevious"],"properties":{"first":{"$ref":"#/$defs/MigrationName"},"last":{"$ref":"#/$defs/MigrationName"},"count":{"type":"integer","minimum":1},"names":{"type":"array","minItems":1,"uniqueItems":true,"items":{"$ref":"#/$defs/MigrationName"}},"compatibleWithPrevious":{"type":"boolean"}}},"durableObjects":{"type":"object","additionalProperties":false,"required":["bindings","lifecycleChange"],"properties":{"bindings":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","className","migration"],"properties":{"name":{"$ref":"#/$defs/BindingName"},"className":{"type":"string","pattern":"^[A-Z][A-Za-z0-9]*$"},"migration":{"type":"string","pattern":"^v[1-9][0-9]*$"}}}},"lifecycleChange":{"type":"boolean"}}},"runtime":{"type":"object","additionalProperties":false,"required":["compatibilityDate","compatibilityFlags"],"properties":{"compatibilityDate":{"type":"string","pattern":"^[0-9]{4}-[0-9]{2}-[0-9]{2}$"},"compatibilityFlags":{"type":"array","uniqueItems":true,"items":{"type":"string","pattern":"^[a-z0-9_]+$"}}}},"toolchain":{"type":"object","additionalProperties":{"type":"string","maxLength":64}},"theme":{"type":"object","additionalProperties":false,"required":["name","version","blockTypes","settingsSha256","designSha256"],"properties":{"name":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$"},"version":{"type":"string","maxLength":64},"blockTypes":{"type":"array","uniqueItems":true,"items":{"type":"string"}},"settingsSha256":{"$ref":"#/$defs/Sha256Hex"},"designSha256":{"$ref":"#/$defs/Sha256Hex"}}},"skills":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","sha256"],"properties":{"name":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$"},"sha256":{"$ref":"#/$defs/Sha256Hex"}}}},"workers":{"type":"object","additionalProperties":false,"required":["site","admin"],"properties":{"site":{"$ref":"#/$defs/WorkerArtifact"},"admin":{"$ref":"#/$defs/WorkerArtifact"}}},"bindingTemplates":{"type":"object","additionalProperties":false,"required":["site","admin"],"properties":{"site":{"$ref":"#/$defs/BindingTemplate"},"admin":{"$ref":"#/$defs/BindingTemplate"}}},"requiredScopes":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/ScopeId"}},"optionalScopes":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/ScopeId"}},"requiredCapabilities":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/Capability"}},"optionalCapabilities":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/Capability"}},"starter":{"oneOf":[{"type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"type":"string","enum":["admin-api"]}}},{"type":"object","additionalProperties":false,"required":["kind","path","bytes","sha256","siteId"],"properties":{"kind":{"type":"string","enum":["bundle"]},"path":{"type":"string","pattern":"^starter/[A-Za-z0-9._-]+$"},"bytes":{"type":"integer","minimum":1},"sha256":{"$ref":"#/$defs/Sha256Hex"},"siteId":{"$ref":"#/$defs/SiteId"}}}]},"features":{"type":"object","additionalProperties":{"type":"boolean"},"required":["adminSitesAcceptsSiteId","healthReportsVersion","mediaTransformVar"],"properties":{"adminSitesAcceptsSiteId":{"type":"boolean"},"healthReportsVersion":{"type":"boolean"},"mediaTransformVar":{"type":"boolean"}}},"planVersion":{"type":"integer","minimum":1},"signing":{"type":"object","additionalProperties":false,"required":["keyId","algorithm","signature"],"properties":{"keyId":{"type":"string","pattern":"^[a-z0-9][a-z0-9-]{2,63}$"},"algorithm":{"type":"string","enum":["Ed25519"]},"signature":{"type":"string","enum":["manifest.sig","release-statement.sig"]}}}},"$defs":{"BindingName":{"type":"string","pattern":"^[A-Z][A-Z0-9_]*(_\\*)?$"},"BindingTemplate":{"type":"object","additionalProperties":false,"required":["bindings","vars","secrets"],"properties":{"bindings":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","type","required"],"properties":{"name":{"$ref":"#/$defs/BindingName"},"type":{"type":"string","enum":["d1","r2_bucket","assets","service","durable_object_namespace","analytics_engine","analytics_sql","ratelimit","ai_search","send_email","ai","browser"]},"required":{"type":"boolean"},"aliases":{"type":"array","items":{"$ref":"#/$defs/BindingName"}}}}},"vars":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/BindingName"}},"secrets":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/SecretName"}},"cache":{"type":"boolean"},"cron":{"type":"string","pattern":"^[0-9*/,\\- ]+$"}}},"Capability":{"type":"string","enum":["account","workers","d1","r2","analytics","domains"]},"CloudhalVersion":{"type":"string","pattern":"^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?$"},"MigrationName":{"type":"string","pattern":"^[0-9]{4}_[a-z0-9_]+$"},"SchemaVersion":{"type":"integer","description":"Version of this contract. Readers reject unknown versions; migrations move documents forward one version at a time.","enum":[1]},"ScopeId":{"type":"string","pattern":"^[a-z0-9-]+(\\.[a-z0-9-]+)+$"},"SecretName":{"type":"string","enum":["BETTER_AUTH_SECRET","MCP_STATE_KEY","CLOUDHAL_PREVIEW_SECRET","CLOUDHAL_PURGE_TOKEN","CLOUDHAL_DEPLOY_TOKEN","CLOUDHAL_SETUP_TOKEN","CLOUDHAL_COMMENTS_KEY","CLOUDHAL_UPLOAD_SECRET"]},"Sha256Hex":{"type":"string","pattern":"^[0-9a-f]{64}$"},"SiteId":{"type":"string","pattern":"^site_[A-Za-z0-9]{6,32}$"},"Timestamp":{"type":"string","description":"RFC 3339 / ISO 8601 instant in UTC.","format":"date-time"},"WorkerArtifact":{"type":"object","additionalProperties":false,"required":["mainModule","modules","assets"],"properties":{"mainModule":{"type":"string","pattern":"^[A-Za-z0-9._/-]+$"},"modules":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["path","type","bytes","sha256"],"properties":{"path":{"type":"string","pattern":"^[A-Za-z0-9._-]+(/[A-Za-z0-9._-]+)*$"},"type":{"type":"string","enum":["esm","cjs","wasm","text","data"]},"bytes":{"type":"integer","minimum":1},"sha256":{"$ref":"#/$defs/Sha256Hex"}}}},"assets":{"type":"object","additionalProperties":false,"required":["count","bytes","files","headers"],"properties":{"count":{"type":"integer","minimum":0,"maximum":20000},"bytes":{"type":"integer","minimum":0},"files":{"type":"array","maxItems":20000,"items":{"type":"object","additionalProperties":false,"required":["path","bytes","sha256","assetHash","contentType"],"properties":{"path":{"type":"string","pattern":"^/[^\\s]*$","maxLength":1024},"bytes":{"type":"integer","minimum":0,"maximum":26214400},"sha256":{"$ref":"#/$defs/Sha256Hex"},"assetHash":{"type":"string","pattern":"^[0-9a-f]{32}$"},"contentType":{"type":"string","maxLength":128}}}},"headers":{"type":"string","maxLength":100000},"config":{"type":"object","additionalProperties":false,"properties":{"not_found_handling":{"type":"string","enum":["none","404-page","single-page-application"]},"run_worker_first":{"type":"array","items":{"type":"string","pattern":"^/"}}}}}},"bindingTemplate":{"type":"string","enum":["site","admin"]}}}}}; const schema577 = {"type":"integer","description":"Version of this contract. Readers reject unknown versions; migrations move documents forward one version at a time.","enum":[1]}; const schema578 = {"type":"string","pattern":"^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?$"}; const schema579 = {"type":"string","description":"RFC 3339 / ISO 8601 instant in UTC.","format":"date-time"}; @@ -44599,7 +44599,7 @@ return errors === 0; validate246.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; const schema590 = {"type":"object","additionalProperties":false,"required":["bindings","vars","secrets"],"properties":{"bindings":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","type","required"],"properties":{"name":{"$ref":"#/$defs/BindingName"},"type":{"type":"string","enum":["d1","r2_bucket","assets","service","durable_object_namespace","analytics_engine","analytics_sql","ratelimit","ai_search","send_email","ai","browser"]},"required":{"type":"boolean"},"aliases":{"type":"array","items":{"$ref":"#/$defs/BindingName"}}}}},"vars":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/BindingName"}},"secrets":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/SecretName"}},"cache":{"type":"boolean"},"cron":{"type":"string","pattern":"^[0-9*/,\\- ]+$"}}}; -const schema594 = {"type":"string","enum":["BETTER_AUTH_SECRET","MCP_STATE_KEY","CLOUDHAL_PREVIEW_SECRET","CLOUDHAL_PURGE_TOKEN","CLOUDHAL_DEPLOY_TOKEN","CLOUDHAL_SETUP_TOKEN","CLOUDHAL_COMMENTS_KEY"]}; +const schema594 = {"type":"string","enum":["BETTER_AUTH_SECRET","MCP_STATE_KEY","CLOUDHAL_PREVIEW_SECRET","CLOUDHAL_PURGE_TOKEN","CLOUDHAL_DEPLOY_TOKEN","CLOUDHAL_SETUP_TOKEN","CLOUDHAL_COMMENTS_KEY","CLOUDHAL_UPLOAD_SECRET"]}; const pattern332 = new RegExp("^[0-9*/,\\- ]+$", "u"); function validate249(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ @@ -44906,7 +44906,7 @@ vErrors.push(err22); } errors++; } -if(!(((((((data10 === "BETTER_AUTH_SECRET") || (data10 === "MCP_STATE_KEY")) || (data10 === "CLOUDHAL_PREVIEW_SECRET")) || (data10 === "CLOUDHAL_PURGE_TOKEN")) || (data10 === "CLOUDHAL_DEPLOY_TOKEN")) || (data10 === "CLOUDHAL_SETUP_TOKEN")) || (data10 === "CLOUDHAL_COMMENTS_KEY"))){ +if(!((((((((data10 === "BETTER_AUTH_SECRET") || (data10 === "MCP_STATE_KEY")) || (data10 === "CLOUDHAL_PREVIEW_SECRET")) || (data10 === "CLOUDHAL_PURGE_TOKEN")) || (data10 === "CLOUDHAL_DEPLOY_TOKEN")) || (data10 === "CLOUDHAL_SETUP_TOKEN")) || (data10 === "CLOUDHAL_COMMENTS_KEY")) || (data10 === "CLOUDHAL_UPLOAD_SECRET"))){ const err23 = {instancePath:instancePath+"/secrets/" + i4,schemaPath:"#/$defs/SecretName/enum",keyword:"enum",params:{allowedValues: schema594.enum},message:"must be equal to one of the allowed values"}; if(vErrors === null){ vErrors = [err23]; diff --git a/packages/core-contracts/test/release-schemas.test.ts b/packages/core-contracts/test/release-schemas.test.ts index 2ef6f496..2aab8c5f 100644 --- a/packages/core-contracts/test/release-schemas.test.ts +++ b/packages/core-contracts/test/release-schemas.test.ts @@ -22,7 +22,7 @@ import { isValid } from "../src/validate.ts"; /** Shared with every portable copy of the two roots; update all of them in the same change. */ export const RELEASE_SCHEMA_FINGERPRINTS = { - "release-manifest": "620fa5848e9bd82f885cd72f7fba65529050bc23b3ccf6ec1ef1860dd2aa60aa", + "release-manifest": "a31080365d4be1bd64c25be9d371a25364737829bb79320d8607ca02f0dafad4", "release-statement": "462eab7d3ca77f0cd2107d533c8f3e8ac201db65e8162cac6ff2b7ab96a38e59", } as const; diff --git a/packages/release-verify/src/generated/release-manifest.ts b/packages/release-verify/src/generated/release-manifest.ts index b79dffa5..6528e389 100644 --- a/packages/release-verify/src/generated/release-manifest.ts +++ b/packages/release-verify/src/generated/release-manifest.ts @@ -56,7 +56,8 @@ export type SecretName = | "CLOUDHAL_PURGE_TOKEN" | "CLOUDHAL_DEPLOY_TOKEN" | "CLOUDHAL_SETUP_TOKEN" - | "CLOUDHAL_COMMENTS_KEY"; + | "CLOUDHAL_COMMENTS_KEY" + | "CLOUDHAL_UPLOAD_SECRET"; /** * This interface was referenced by `ReleaseManifest`'s JSON-Schema * via the `definition` "ScopeId". diff --git a/packages/release-verify/src/generated/validators.js b/packages/release-verify/src/generated/validators.js index 50d116af..9414ddc4 100644 --- a/packages/release-verify/src/generated/validators.js +++ b/packages/release-verify/src/generated/validators.js @@ -10,7 +10,7 @@ import __req1 from "ajv/dist/runtime/ucs2length.js"; import __req2 from "ajv-formats/dist/formats.js"; "use strict"; export const validateReleaseManifest = validate20; -const schema31 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cloudhal.dev/schemas/v1/release-manifest.schema.json","title":"ReleaseManifest","description":"cloudhal.release-manifest@1 (RFC-0046): the manifest of one Cloudhal release bundle, published as the release asset manifest.json next to the gzip tarball cloudhal-release-.tar.gz. A project release is signed through release-statement.json, which pins this file's SHA-256 and size (signing.signature = release-statement.sig); the legacy form manifest.sig, a raw 64-byte Ed25519 signature over these exact bytes, is for development keys only. It describes every built Worker module and static asset by size and SHA-256, the binding templates, feature levels, migration range and rollback facts a remote deployer needs to install, update or refuse a version without running a build. Portable on purpose: it references common only for SchemaVersion and Timestamp; every other definition is local.","type":"object","additionalProperties":false,"required":["schemaVersion","format","version","channel","securityRelease","commit","createdAt","contracts","levels","migrations","durableObjects","runtime","toolchain","theme","skills","workers","bindingTemplates","requiredScopes","optionalScopes","requiredCapabilities","optionalCapabilities","starter","features","planVersion","signing"],"properties":{"schemaVersion":{"$ref":"#/$defs/SchemaVersion"},"format":{"type":"string","enum":["cloudhal.release-manifest@1"]},"version":{"$ref":"#/$defs/CloudhalVersion"},"channel":{"type":"string","enum":["stable","next"]},"securityRelease":{"type":"boolean"},"commit":{"type":"string","pattern":"^[0-9a-f]{40}$"},"createdAt":{"$ref":"#/$defs/Timestamp"},"contracts":{"type":"object","additionalProperties":false,"required":["schemaVersion"],"properties":{"schemaVersion":{"type":"integer","enum":[1]}}},"levels":{"type":"object","additionalProperties":false,"required":["schedules","gates"],"properties":{"schedules":{"type":"integer","minimum":0},"gates":{"type":"integer","minimum":0}}},"migrations":{"type":"object","additionalProperties":false,"required":["first","last","count","names","compatibleWithPrevious"],"properties":{"first":{"$ref":"#/$defs/MigrationName"},"last":{"$ref":"#/$defs/MigrationName"},"count":{"type":"integer","minimum":1},"names":{"type":"array","minItems":1,"uniqueItems":true,"items":{"$ref":"#/$defs/MigrationName"}},"compatibleWithPrevious":{"type":"boolean"}}},"durableObjects":{"type":"object","additionalProperties":false,"required":["bindings","lifecycleChange"],"properties":{"bindings":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","className","migration"],"properties":{"name":{"$ref":"#/$defs/BindingName"},"className":{"type":"string","pattern":"^[A-Z][A-Za-z0-9]*$"},"migration":{"type":"string","pattern":"^v[1-9][0-9]*$"}}}},"lifecycleChange":{"type":"boolean"}}},"runtime":{"type":"object","additionalProperties":false,"required":["compatibilityDate","compatibilityFlags"],"properties":{"compatibilityDate":{"type":"string","pattern":"^[0-9]{4}-[0-9]{2}-[0-9]{2}$"},"compatibilityFlags":{"type":"array","uniqueItems":true,"items":{"type":"string","pattern":"^[a-z0-9_]+$"}}}},"toolchain":{"type":"object","additionalProperties":{"type":"string","maxLength":64}},"theme":{"type":"object","additionalProperties":false,"required":["name","version","blockTypes","settingsSha256","designSha256"],"properties":{"name":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$"},"version":{"type":"string","maxLength":64},"blockTypes":{"type":"array","uniqueItems":true,"items":{"type":"string"}},"settingsSha256":{"$ref":"#/$defs/Sha256Hex"},"designSha256":{"$ref":"#/$defs/Sha256Hex"}}},"skills":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","sha256"],"properties":{"name":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$"},"sha256":{"$ref":"#/$defs/Sha256Hex"}}}},"workers":{"type":"object","additionalProperties":false,"required":["site","admin"],"properties":{"site":{"$ref":"#/$defs/WorkerArtifact"},"admin":{"$ref":"#/$defs/WorkerArtifact"}}},"bindingTemplates":{"type":"object","additionalProperties":false,"required":["site","admin"],"properties":{"site":{"$ref":"#/$defs/BindingTemplate"},"admin":{"$ref":"#/$defs/BindingTemplate"}}},"requiredScopes":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/ScopeId"}},"optionalScopes":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/ScopeId"}},"requiredCapabilities":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/Capability"}},"optionalCapabilities":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/Capability"}},"starter":{"oneOf":[{"type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"type":"string","enum":["admin-api"]}}},{"type":"object","additionalProperties":false,"required":["kind","path","bytes","sha256","siteId"],"properties":{"kind":{"type":"string","enum":["bundle"]},"path":{"type":"string","pattern":"^starter/[A-Za-z0-9._-]+$"},"bytes":{"type":"integer","minimum":1},"sha256":{"$ref":"#/$defs/Sha256Hex"},"siteId":{"$ref":"#/$defs/SiteId"}}}]},"features":{"type":"object","additionalProperties":{"type":"boolean"},"required":["adminSitesAcceptsSiteId","healthReportsVersion","mediaTransformVar"],"properties":{"adminSitesAcceptsSiteId":{"type":"boolean"},"healthReportsVersion":{"type":"boolean"},"mediaTransformVar":{"type":"boolean"}}},"planVersion":{"type":"integer","minimum":1},"signing":{"type":"object","additionalProperties":false,"required":["keyId","algorithm","signature"],"properties":{"keyId":{"type":"string","pattern":"^[a-z0-9][a-z0-9-]{2,63}$"},"algorithm":{"type":"string","enum":["Ed25519"]},"signature":{"type":"string","enum":["manifest.sig","release-statement.sig"]}}}},"$defs":{"BindingName":{"type":"string","pattern":"^[A-Z][A-Z0-9_]*(_\\*)?$"},"BindingTemplate":{"type":"object","additionalProperties":false,"required":["bindings","vars","secrets"],"properties":{"bindings":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","type","required"],"properties":{"name":{"$ref":"#/$defs/BindingName"},"type":{"type":"string","enum":["d1","r2_bucket","assets","service","durable_object_namespace","analytics_engine","analytics_sql","ratelimit","ai_search","send_email","ai","browser"]},"required":{"type":"boolean"},"aliases":{"type":"array","items":{"$ref":"#/$defs/BindingName"}}}}},"vars":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/BindingName"}},"secrets":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/SecretName"}},"cache":{"type":"boolean"},"cron":{"type":"string","pattern":"^[0-9*/,\\- ]+$"}}},"Capability":{"type":"string","enum":["account","workers","d1","r2","analytics","domains"]},"CloudhalVersion":{"type":"string","pattern":"^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?$"},"MigrationName":{"type":"string","pattern":"^[0-9]{4}_[a-z0-9_]+$"},"SchemaVersion":{"type":"integer","description":"Version of this contract. Readers reject unknown versions; migrations move documents forward one version at a time.","enum":[1]},"ScopeId":{"type":"string","pattern":"^[a-z0-9-]+(\\.[a-z0-9-]+)+$"},"SecretName":{"type":"string","enum":["BETTER_AUTH_SECRET","MCP_STATE_KEY","CLOUDHAL_PREVIEW_SECRET","CLOUDHAL_PURGE_TOKEN","CLOUDHAL_DEPLOY_TOKEN","CLOUDHAL_SETUP_TOKEN","CLOUDHAL_COMMENTS_KEY"]},"Sha256Hex":{"type":"string","pattern":"^[0-9a-f]{64}$"},"SiteId":{"type":"string","pattern":"^site_[A-Za-z0-9]{6,32}$"},"Timestamp":{"type":"string","description":"RFC 3339 / ISO 8601 instant in UTC.","format":"date-time"},"WorkerArtifact":{"type":"object","additionalProperties":false,"required":["mainModule","modules","assets"],"properties":{"mainModule":{"type":"string","pattern":"^[A-Za-z0-9._/-]+$"},"modules":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["path","type","bytes","sha256"],"properties":{"path":{"type":"string","pattern":"^[A-Za-z0-9._-]+(/[A-Za-z0-9._-]+)*$"},"type":{"type":"string","enum":["esm","cjs","wasm","text","data"]},"bytes":{"type":"integer","minimum":1},"sha256":{"$ref":"#/$defs/Sha256Hex"}}}},"assets":{"type":"object","additionalProperties":false,"required":["count","bytes","files","headers"],"properties":{"count":{"type":"integer","minimum":0,"maximum":20000},"bytes":{"type":"integer","minimum":0},"files":{"type":"array","maxItems":20000,"items":{"type":"object","additionalProperties":false,"required":["path","bytes","sha256","assetHash","contentType"],"properties":{"path":{"type":"string","pattern":"^/[^\\s]*$","maxLength":1024},"bytes":{"type":"integer","minimum":0,"maximum":26214400},"sha256":{"$ref":"#/$defs/Sha256Hex"},"assetHash":{"type":"string","pattern":"^[0-9a-f]{32}$"},"contentType":{"type":"string","maxLength":128}}}},"headers":{"type":"string","maxLength":100000},"config":{"type":"object","additionalProperties":false,"properties":{"not_found_handling":{"type":"string","enum":["none","404-page","single-page-application"]},"run_worker_first":{"type":"array","items":{"type":"string","pattern":"^/"}}}}}},"bindingTemplate":{"type":"string","enum":["site","admin"]}}}}}; +const schema31 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cloudhal.dev/schemas/v1/release-manifest.schema.json","title":"ReleaseManifest","description":"cloudhal.release-manifest@1 (RFC-0046): the manifest of one Cloudhal release bundle, published as the release asset manifest.json next to the gzip tarball cloudhal-release-.tar.gz. A project release is signed through release-statement.json, which pins this file's SHA-256 and size (signing.signature = release-statement.sig); the legacy form manifest.sig, a raw 64-byte Ed25519 signature over these exact bytes, is for development keys only. It describes every built Worker module and static asset by size and SHA-256, the binding templates, feature levels, migration range and rollback facts a remote deployer needs to install, update or refuse a version without running a build. Portable on purpose: it references common only for SchemaVersion and Timestamp; every other definition is local.","type":"object","additionalProperties":false,"required":["schemaVersion","format","version","channel","securityRelease","commit","createdAt","contracts","levels","migrations","durableObjects","runtime","toolchain","theme","skills","workers","bindingTemplates","requiredScopes","optionalScopes","requiredCapabilities","optionalCapabilities","starter","features","planVersion","signing"],"properties":{"schemaVersion":{"$ref":"#/$defs/SchemaVersion"},"format":{"type":"string","enum":["cloudhal.release-manifest@1"]},"version":{"$ref":"#/$defs/CloudhalVersion"},"channel":{"type":"string","enum":["stable","next"]},"securityRelease":{"type":"boolean"},"commit":{"type":"string","pattern":"^[0-9a-f]{40}$"},"createdAt":{"$ref":"#/$defs/Timestamp"},"contracts":{"type":"object","additionalProperties":false,"required":["schemaVersion"],"properties":{"schemaVersion":{"type":"integer","enum":[1]}}},"levels":{"type":"object","additionalProperties":false,"required":["schedules","gates"],"properties":{"schedules":{"type":"integer","minimum":0},"gates":{"type":"integer","minimum":0}}},"migrations":{"type":"object","additionalProperties":false,"required":["first","last","count","names","compatibleWithPrevious"],"properties":{"first":{"$ref":"#/$defs/MigrationName"},"last":{"$ref":"#/$defs/MigrationName"},"count":{"type":"integer","minimum":1},"names":{"type":"array","minItems":1,"uniqueItems":true,"items":{"$ref":"#/$defs/MigrationName"}},"compatibleWithPrevious":{"type":"boolean"}}},"durableObjects":{"type":"object","additionalProperties":false,"required":["bindings","lifecycleChange"],"properties":{"bindings":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","className","migration"],"properties":{"name":{"$ref":"#/$defs/BindingName"},"className":{"type":"string","pattern":"^[A-Z][A-Za-z0-9]*$"},"migration":{"type":"string","pattern":"^v[1-9][0-9]*$"}}}},"lifecycleChange":{"type":"boolean"}}},"runtime":{"type":"object","additionalProperties":false,"required":["compatibilityDate","compatibilityFlags"],"properties":{"compatibilityDate":{"type":"string","pattern":"^[0-9]{4}-[0-9]{2}-[0-9]{2}$"},"compatibilityFlags":{"type":"array","uniqueItems":true,"items":{"type":"string","pattern":"^[a-z0-9_]+$"}}}},"toolchain":{"type":"object","additionalProperties":{"type":"string","maxLength":64}},"theme":{"type":"object","additionalProperties":false,"required":["name","version","blockTypes","settingsSha256","designSha256"],"properties":{"name":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$"},"version":{"type":"string","maxLength":64},"blockTypes":{"type":"array","uniqueItems":true,"items":{"type":"string"}},"settingsSha256":{"$ref":"#/$defs/Sha256Hex"},"designSha256":{"$ref":"#/$defs/Sha256Hex"}}},"skills":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","sha256"],"properties":{"name":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,63}$"},"sha256":{"$ref":"#/$defs/Sha256Hex"}}}},"workers":{"type":"object","additionalProperties":false,"required":["site","admin"],"properties":{"site":{"$ref":"#/$defs/WorkerArtifact"},"admin":{"$ref":"#/$defs/WorkerArtifact"}}},"bindingTemplates":{"type":"object","additionalProperties":false,"required":["site","admin"],"properties":{"site":{"$ref":"#/$defs/BindingTemplate"},"admin":{"$ref":"#/$defs/BindingTemplate"}}},"requiredScopes":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/ScopeId"}},"optionalScopes":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/ScopeId"}},"requiredCapabilities":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/Capability"}},"optionalCapabilities":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/Capability"}},"starter":{"oneOf":[{"type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"type":"string","enum":["admin-api"]}}},{"type":"object","additionalProperties":false,"required":["kind","path","bytes","sha256","siteId"],"properties":{"kind":{"type":"string","enum":["bundle"]},"path":{"type":"string","pattern":"^starter/[A-Za-z0-9._-]+$"},"bytes":{"type":"integer","minimum":1},"sha256":{"$ref":"#/$defs/Sha256Hex"},"siteId":{"$ref":"#/$defs/SiteId"}}}]},"features":{"type":"object","additionalProperties":{"type":"boolean"},"required":["adminSitesAcceptsSiteId","healthReportsVersion","mediaTransformVar"],"properties":{"adminSitesAcceptsSiteId":{"type":"boolean"},"healthReportsVersion":{"type":"boolean"},"mediaTransformVar":{"type":"boolean"}}},"planVersion":{"type":"integer","minimum":1},"signing":{"type":"object","additionalProperties":false,"required":["keyId","algorithm","signature"],"properties":{"keyId":{"type":"string","pattern":"^[a-z0-9][a-z0-9-]{2,63}$"},"algorithm":{"type":"string","enum":["Ed25519"]},"signature":{"type":"string","enum":["manifest.sig","release-statement.sig"]}}}},"$defs":{"BindingName":{"type":"string","pattern":"^[A-Z][A-Z0-9_]*(_\\*)?$"},"BindingTemplate":{"type":"object","additionalProperties":false,"required":["bindings","vars","secrets"],"properties":{"bindings":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","type","required"],"properties":{"name":{"$ref":"#/$defs/BindingName"},"type":{"type":"string","enum":["d1","r2_bucket","assets","service","durable_object_namespace","analytics_engine","analytics_sql","ratelimit","ai_search","send_email","ai","browser"]},"required":{"type":"boolean"},"aliases":{"type":"array","items":{"$ref":"#/$defs/BindingName"}}}}},"vars":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/BindingName"}},"secrets":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/SecretName"}},"cache":{"type":"boolean"},"cron":{"type":"string","pattern":"^[0-9*/,\\- ]+$"}}},"Capability":{"type":"string","enum":["account","workers","d1","r2","analytics","domains"]},"CloudhalVersion":{"type":"string","pattern":"^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?$"},"MigrationName":{"type":"string","pattern":"^[0-9]{4}_[a-z0-9_]+$"},"SchemaVersion":{"type":"integer","description":"Version of this contract. Readers reject unknown versions; migrations move documents forward one version at a time.","enum":[1]},"ScopeId":{"type":"string","pattern":"^[a-z0-9-]+(\\.[a-z0-9-]+)+$"},"SecretName":{"type":"string","enum":["BETTER_AUTH_SECRET","MCP_STATE_KEY","CLOUDHAL_PREVIEW_SECRET","CLOUDHAL_PURGE_TOKEN","CLOUDHAL_DEPLOY_TOKEN","CLOUDHAL_SETUP_TOKEN","CLOUDHAL_COMMENTS_KEY","CLOUDHAL_UPLOAD_SECRET"]},"Sha256Hex":{"type":"string","pattern":"^[0-9a-f]{64}$"},"SiteId":{"type":"string","pattern":"^site_[A-Za-z0-9]{6,32}$"},"Timestamp":{"type":"string","description":"RFC 3339 / ISO 8601 instant in UTC.","format":"date-time"},"WorkerArtifact":{"type":"object","additionalProperties":false,"required":["mainModule","modules","assets"],"properties":{"mainModule":{"type":"string","pattern":"^[A-Za-z0-9._/-]+$"},"modules":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["path","type","bytes","sha256"],"properties":{"path":{"type":"string","pattern":"^[A-Za-z0-9._-]+(/[A-Za-z0-9._-]+)*$"},"type":{"type":"string","enum":["esm","cjs","wasm","text","data"]},"bytes":{"type":"integer","minimum":1},"sha256":{"$ref":"#/$defs/Sha256Hex"}}}},"assets":{"type":"object","additionalProperties":false,"required":["count","bytes","files","headers"],"properties":{"count":{"type":"integer","minimum":0,"maximum":20000},"bytes":{"type":"integer","minimum":0},"files":{"type":"array","maxItems":20000,"items":{"type":"object","additionalProperties":false,"required":["path","bytes","sha256","assetHash","contentType"],"properties":{"path":{"type":"string","pattern":"^/[^\\s]*$","maxLength":1024},"bytes":{"type":"integer","minimum":0,"maximum":26214400},"sha256":{"$ref":"#/$defs/Sha256Hex"},"assetHash":{"type":"string","pattern":"^[0-9a-f]{32}$"},"contentType":{"type":"string","maxLength":128}}}},"headers":{"type":"string","maxLength":100000},"config":{"type":"object","additionalProperties":false,"properties":{"not_found_handling":{"type":"string","enum":["none","404-page","single-page-application"]},"run_worker_first":{"type":"array","items":{"type":"string","pattern":"^/"}}}}}},"bindingTemplate":{"type":"string","enum":["site","admin"]}}}}}; const schema32 = {"type":"integer","description":"Version of this contract. Readers reject unknown versions; migrations move documents forward one version at a time.","enum":[1]}; const schema33 = {"type":"string","pattern":"^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?$"}; const schema34 = {"type":"string","description":"RFC 3339 / ISO 8601 instant in UTC.","format":"date-time"}; @@ -845,7 +845,7 @@ return errors === 0; validate21.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; const schema45 = {"type":"object","additionalProperties":false,"required":["bindings","vars","secrets"],"properties":{"bindings":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","type","required"],"properties":{"name":{"$ref":"#/$defs/BindingName"},"type":{"type":"string","enum":["d1","r2_bucket","assets","service","durable_object_namespace","analytics_engine","analytics_sql","ratelimit","ai_search","send_email","ai","browser"]},"required":{"type":"boolean"},"aliases":{"type":"array","items":{"$ref":"#/$defs/BindingName"}}}}},"vars":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/BindingName"}},"secrets":{"type":"array","uniqueItems":true,"items":{"$ref":"#/$defs/SecretName"}},"cache":{"type":"boolean"},"cron":{"type":"string","pattern":"^[0-9*/,\\- ]+$"}}}; -const schema49 = {"type":"string","enum":["BETTER_AUTH_SECRET","MCP_STATE_KEY","CLOUDHAL_PREVIEW_SECRET","CLOUDHAL_PURGE_TOKEN","CLOUDHAL_DEPLOY_TOKEN","CLOUDHAL_SETUP_TOKEN","CLOUDHAL_COMMENTS_KEY"]}; +const schema49 = {"type":"string","enum":["BETTER_AUTH_SECRET","MCP_STATE_KEY","CLOUDHAL_PREVIEW_SECRET","CLOUDHAL_PURGE_TOKEN","CLOUDHAL_DEPLOY_TOKEN","CLOUDHAL_SETUP_TOKEN","CLOUDHAL_COMMENTS_KEY","CLOUDHAL_UPLOAD_SECRET"]}; const pattern29 = new RegExp("^[0-9*/,\\- ]+$", "u"); function validate24(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){ @@ -1152,7 +1152,7 @@ vErrors.push(err22); } errors++; } -if(!(((((((data10 === "BETTER_AUTH_SECRET") || (data10 === "MCP_STATE_KEY")) || (data10 === "CLOUDHAL_PREVIEW_SECRET")) || (data10 === "CLOUDHAL_PURGE_TOKEN")) || (data10 === "CLOUDHAL_DEPLOY_TOKEN")) || (data10 === "CLOUDHAL_SETUP_TOKEN")) || (data10 === "CLOUDHAL_COMMENTS_KEY"))){ +if(!((((((((data10 === "BETTER_AUTH_SECRET") || (data10 === "MCP_STATE_KEY")) || (data10 === "CLOUDHAL_PREVIEW_SECRET")) || (data10 === "CLOUDHAL_PURGE_TOKEN")) || (data10 === "CLOUDHAL_DEPLOY_TOKEN")) || (data10 === "CLOUDHAL_SETUP_TOKEN")) || (data10 === "CLOUDHAL_COMMENTS_KEY")) || (data10 === "CLOUDHAL_UPLOAD_SECRET"))){ const err23 = {instancePath:instancePath+"/secrets/" + i4,schemaPath:"#/$defs/SecretName/enum",keyword:"enum",params:{allowedValues: schema49.enum},message:"must be equal to one of the allowed values"}; if(vErrors === null){ vErrors = [err23]; diff --git a/scripts/release-bundle/standard.ts b/scripts/release-bundle/standard.ts index a3bb1c71..830a48d6 100644 --- a/scripts/release-bundle/standard.ts +++ b/scripts/release-bundle/standard.ts @@ -31,6 +31,7 @@ export const ADMIN_SECRETS = [ "CLOUDHAL_DEPLOY_TOKEN", "CLOUDHAL_SETUP_TOKEN", "CLOUDHAL_COMMENTS_KEY", + "CLOUDHAL_UPLOAD_SECRET", ] as const; /** The site Worker's secrets (`SITE_SECRET_KEYS`). */ export const SITE_SECRETS = [ diff --git a/scripts/size-baseline.json b/scripts/size-baseline.json index db9f92d4..e332ff77 100644 --- a/scripts/size-baseline.json +++ b/scripts/size-baseline.json @@ -369,10 +369,10 @@ "params": 5 }, "packages/cloudflare/src/admin-worker.ts::createAdminWorker": { - "lines": 248 + "lines": 247 }, "packages/cloudflare/src/admin-worker.ts::createAdminWorker>fetch": { - "lines": 190 + "lines": 189 }, "packages/comments/src/client/comments.browser.js::enhance": { "lines": 205 @@ -480,7 +480,7 @@ "lines": 177 }, "packages/mcp-server/src/elevation-tools.ts::elevationTools": { - "lines": 228 + "lines": 223 }, "packages/mcp-server/src/menu-tools.ts::baseMenu": { "params": 6 @@ -519,7 +519,7 @@ "params": 6 }, "packages/mcp-server/src/tools.ts::runTool": { - "lines": 244 + "lines": 217 }, "packages/schedules/src/builtins.ts::createBuiltinRunner": { "lines": 249 From 18a36bbdbfc1c6935be865d08ac20141a1d3a91d Mon Sep 17 00:00:00 2001 From: Madraka <8898640+Madraka@users.noreply.github.com> Date: Sun, 29 Nov 2026 14:19:41 +0300 Subject: [PATCH 2/2] docs: RFC-0048 step 5, verifiers before 0.12 refuse 0.12+ manifests The release manifest's SecretName gains CLOUDHAL_UPLOAD_SECRET: an older @cloudhal/release-verify (or a portable schema copy) rejects a 0.12+ manifest, while the new schema still verifies older bundles. Said in the changeset and as an amendment to RFC-0046's header and compatibility notes. Refs #250 Co-Authored-By: Claude Opus 5.5 Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com> --- .changeset/rfc48-step5-hosts.md | 1 + docs/rfcs/0046-release-bundles.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.changeset/rfc48-step5-hosts.md b/.changeset/rfc48-step5-hosts.md index 42683602..855fb8ad 100644 --- a/.changeset/rfc48-step5-hosts.md +++ b/.changeset/rfc48-step5-hosts.md @@ -7,6 +7,7 @@ RFC-0048 rollout step 5 finishes agents' signed upload links on every host. +- **Compatibility (`@cloudhal/release-verify`, `@cloudhal/core-contracts`):** verifiers before 0.12 refuse 0.12+ manifests; update the verifier with the CLI. The release manifest's `SecretName` gains `CLOUDHAL_UPLOAD_SECRET`, which 0.12+ manifests list for the admin Worker, and an older verifier rejects the unknown value. The new schema still verifies older bundles. Portable copies of the schema need the new `release-manifest` fingerprint (RFC-0046, amended). - **`CLOUDHAL_UPLOAD_SECRET`:** - `cloudhal deploy` generates it once into `.cloudhal/deploy/secrets.json` (0600) and gives it to the admin Worker. It signs upload tickets and agents' upload links ahead of the preview secret, so it can rotate on its own. - The release manifest's `SecretName` gains it, an additive contract change. diff --git a/docs/rfcs/0046-release-bundles.md b/docs/rfcs/0046-release-bundles.md index 282f9276..96e92137 100644 --- a/docs/rfcs/0046-release-bundles.md +++ b/docs/rfcs/0046-release-bundles.md @@ -1,6 +1,7 @@ # RFC-0046: Signed release bundles - Status: Proposed +- Amendment (2026-11-29, RFC-0048 step 5): `SecretName` gains `CLOUDHAL_UPLOAD_SECRET`. Verifiers before 0.12 refuse 0.12+ manifests; update the verifier with the CLI. See "Compatibility & migration". - Author: Halil (Madraka), drafted with Claude · Date: 2026-11-12 - Related: - ADR-0001 / ADR-0008 (the contract pipeline, precompiled validators), ADR-0012 (the site and admin Workers), ADR-0013 (npm packaging: one version for the fixed group), ADR-0037 (`cloudhal.dev/schemas/v1` permanent URLs). @@ -495,6 +496,7 @@ Today `cloudhal deploy` builds the site with Astro and the admin Worker with wra - **Releases:** `v0.8.0` and older have no bundle and never will (immutable); a consumer treats them as unbundled. The first bundled version is the next one. - **Rollout:** (1) the contracts and this RFC; (2) the builder, `bundle-build.yml`, `bundle-sign`, the reordered `publish-ci.ts` and the dry run, merged with `RELEASE_BUNDLES` off; (3) the maintainer creates `release-signing` and its secret, runs the dry run and turns `RELEASE_BUNDLES` on; (4) the first bundle ships, preferably on a `next` prerelease. - **Rollback:** set `RELEASE_BUNDLES` off. Releases go on without assets in the same order; nothing in an installation depends on a bundle. +- **Amended 2026-11-29 (RFC-0048 step 5), `SecretName` gains `CLOUDHAL_UPLOAD_SECRET`:** verifiers before 0.12 refuse 0.12+ manifests; update the verifier with the CLI. A 0.12+ manifest lists the secret in `bindingTemplates.admin.secrets`, and an older `@cloudhal/release-verify` (or a portable copy of the schema) rejects the unknown enum value as an invalid manifest. The other direction holds: the new schema still verifies older bundles (CI's "Release verifier on the real v0.9.0 bundle"). `cloudhal deploy --release` is unaffected, because it deploys only the release of its own version with its own bundled verifier. Portable copies must also take the new `RELEASE_SCHEMA_FINGERPRINTS["release-manifest"]`. ## Security & policy impact