Skip to content

feat(cli): RFC-0048 step 5, agent upload links on every host - #349

Merged
Madraka merged 2 commits into
mainfrom
claude/rfc48-step5-hosts
Nov 29, 2026
Merged

Madraka merged 2 commits into
mainfrom
claude/rfc48-step5-hosts

Conversation

@Madraka

@Madraka Madraka commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

RFC-0048 rollout step 5 (hosts) is the last step. It finishes agents' signed upload links on Cloudflare, self-host and cloudhal studio, labels them in Studio, and documents them.

CLOUDHAL_UPLOAD_SECRET

  • Cloudflare. cloudhal deploy generates it once into .cloudhal/deploy/secrets.json (0600) through SECRET_KEYS and gives it to the admin Worker. An existing project gets it on its next deploy (loadOrCreateSecrets fills in missing keys). The admin Worker already reads it (step 3).
  • Contract. The release manifest's SecretName gains CLOUDHAL_UPLOAD_SECRET, an additive enum value, so the release bundle's admin template lists it (scripts/release-bundle/standard.ts ADMIN_SECRETS, kept equal to SECRET_KEYS by release-bundle.test.ts).
    • Regenerated with pnpm gen: TS, Rust and release-verify's validators.
    • New fixtures: valid/release-manifest/admin-upload-secret.json and invalid/release-manifest/secret-name-unknown.json.
    • RELEASE_SCHEMA_FINGERPRINTS["release-manifest"] is updated. Heads-up: the test says portable copies outside this repo pin the same constant. Nothing in this repo does, but an external remote deployer would need the new value.
  • Self-host: optional, so existing installations start unchanged.
    • OPTIONAL_SECRETS in selfhost/settings.ts is read through _FILE too. When unset it becomes "", so workerd's fromEnvironment binding exists and the API falls back to the preview secret.
    • A value shorter than 32 characters is reported as a start-up problem.
    • cloudhal selfhost secrets generates it for new installations, and the compose file passes it through (${CLOUDHAL_UPLOAD_SECRET:-}).
    • Helm and Swarm are unchanged: a new required key would break existing stacks. The guide shows the optional _FILE line.

Compatibility of the manifest change

  • Verifiers before 0.12 refuse 0.12+ manifests; update the verifier with the CLI. A 0.12+ manifest lists CLOUDHAL_UPLOAD_SECRET in bindingTemplates.admin.secrets. An older @cloudhal/release-verify, or a portable copy of the schema, rejects the unknown enum value as an invalid manifest. The changeset says so, and RFC-0046 has an amendment line in its header and in "Compatibility & migration".
  • cloudhal deploy --release is unaffected: it deploys only the release of its own version, with its own bundled verifier.
  • Old bundles still verify with the new schema. CI's "Release verifier on the real v0.9.0 bundle" passed on fd496b4 (run). The follow-up commit changes only docs and the changeset.

cloudhal.json media.agentUploads / media.agentUploadBytes

  • Reading. packages/cli/src/config-media.ts reads them leniently: agentUploads: false, and agentUploadBytes as an integer from 1 to 100 MB. It doesn't take media over from the starter: it isn't in OWN_KEYS, so writeProjectConfig keeps the file's media as written.
  • Cloudflare. adminWorkerConfig writes them as the vars CLOUDHAL_AGENT_UPLOADS=off and CLOUDHAL_AGENT_UPLOAD_BYTES, for both cloudhal deploy (prepareAdmin) and deploy --release. The admin Worker maps them onto mcp.media (cloudflare/src/agent-uploads.ts).
  • Release key table. Both are deploy keys in config-build-keys.ts, so deploy --release accepts any value.
  • Self-host passes the same vars through (PASSED_VARS). cloudhal studio reads them from the project.

Studio labels (AGENTS.md rule 10)

  • KNOWN_TOOLS gains create_upload and complete_upload. ASSET_EVENTS gains asset.upload-received, the audit row of an accepted PUT.
  • English labels are in en.ts: "Create an upload link", "Complete an upload", "Receive an agent's upload".
  • The other 18 languages were drafted through pnpm i18n:export and imported with pnpm i18n:import, matching each catalog's existing words: "Importer" in French, "Agent" in Turkish, "智能体" in Chinese, noun forms in Polish. These are AI drafts awaiting review. No language is marked reviewed.

Docs

  • docs/guides/agent-uploads.md covers:
    • the flow and what a link allows;
    • hash commands per OS and the curl line;
    • the settings table and the secret, with its rotation;
    • logs: keeping ?sig= out of reverse proxy and ingress access logs (ingress-nginx, nginx, Traefik, Envoy, HAProxy, load balancers; for nginx, log $uri instead of $request), and wrangler tail, marked unverified, so treat tail output as containing links;
    • body size limits (Cloudflare plans; proxy defaults like client_max_body_size and ingress-nginx's proxy-body-size) and turning it off.
  • The self-host guide and the Cloudflare README list the new settings.
  • The threat model's "Agent uploads (RFC-0048)" rows are now "Mitigated", reviewed against steps 2–5. A leaked link's residual names outside logs. The Agent principal row is in the present tense.
  • RFC-0048 implementation notes for step 5: the manifest secret, optional on self-host, the config keys, the labels, and the eval.

The eval task: not added

The build eval (packages/api/src/build-eval.ts) runs Workers AI models through Build chat's page-building turn, which has neither the MCP upload tools nor a shell. A "300 KB cover from disk without base64" task needs an agent harness with a shell and an MCP client, which this repo doesn't have yet. The API's end-to-end test (agent-uploads-auth.test.ts, step 4) runs the same flow without a model. This is recorded in the RFC as a follow-up.

Size

node scripts/size-check.ts --update (no --allow-growth) tightened four entries:

  • createAdminWorker 248 → 247
  • createAdminWorker>fetch 190 → 189
  • elevationTools 228 → 223
  • runTool 244 → 217

Checks run locally

  • Clean: biome check . --diagnostic-level=error, size-check, mcp-tools-doc --check.
  • pnpm gen gives the committed generated files. pnpm drift before the commit showed only the intended enum diff.
  • tsc passes for core-contracts, release-verify, cli, cloudflare and apps/studio.
  • Tests:
    • core-contracts (622) and release-verify (87);
    • in cli, config-media, hardening-cli, config-build-keys, release-bundle, deploy, deploy-release, deploy-workers-builds and selfhost (51 in the last batch);
    • in cloudflare, agent-uploads;
    • in apps/docs, repo-docs;
    • the full apps/studio suite, which passed;
    • pnpm i18n:import's i18n tests (27).
  • Not run locally: cargo test and the workerd, D1 and docker-smoke suites. They run in CI.

Refs #250

🤖 Generated with Claude Code

Madraka and others added 2 commits November 29, 2026 14:17
- 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 <noreply@anthropic.com>
Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
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 <noreply@anthropic.com>
Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
@Madraka
Madraka merged commit 32a4c03 into main Nov 29, 2026
12 checks passed
@Madraka
Madraka deleted the claude/rfc48-step5-hosts branch November 29, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant