Skip to content

Integrate and production-harden the Cloudflare Worker backend #205

Description

@support371

Objective

Port the existing devin/1778454818-cloudflare-worker-backend implementation onto the current main branch, remediate its verification gaps, and prepare a safe Cloudflare deployment for GEM Enterprise.

Acceptance criteria

  • Cloudflare Worker backend is integrated from current main, not deployed from the stale branch.
  • Worker TypeScript check passes.
  • Unit/integration tests cover health, authentication failure, authorization failure, input validation, and fail-closed optional bindings.
  • Wrangler configuration uses explicit production and staging targets with a current compatibility date.
  • D1 migration is validated locally before any owner-approved remote application.
  • R2/KV-dependent routes fail closed until the bindings exist; no sensitive upload is enabled prematurely.
  • Deployment workflow runs validation on pull requests and deploys only after owner-approved configuration.
  • Production secrets remain in Cloudflare/GitHub secret stores and are never committed or logged.
  • Dry-run bundle succeeds and the deployment/rollback runbook is current.
  • Current frontend integration and canonical Vercel deployment remain unaffected.

Exclusions / safety gates

  • No paid service activation.
  • No direct commit to main.
  • No production D1 migration, Worker deployment, DNS/custom-domain change, or secret mutation without owner authorization and Cloudflare OAuth.
  • No enabling document/KYC uploads until private storage, validation, malware scanning, access control, audit logging, retention, and deletion are verified.

Known findings

  • Existing Worker branch last changed on 2026-05-11 and was never merged into current main.
  • TypeScript currently passes.
  • Wrangler dry-run currently bundles successfully.
  • Worker test command currently fails because there are no Worker tests and it resolves the root Vitest configuration.
  • Current deployment script warns because it does not select an explicit Wrangler environment.

Rollback

Keep the Worker isolated under cloudflare-worker/. Revert the integration PR or roll back the Cloudflare Worker version without changing the Vercel-hosted frontend or production domain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions