Skip to content

Allocate elastic Cloudflare sites through a D1 registry and wildcard hostnames #2078

Description

@chubes4

Parent: #1970

Goal

Replace the finite WORDPRESS_SITE_CONTEXTS allocation pool with an elastic site identity contract that can create N isolated preview sites without deploying a Worker or editing Worker configuration per site.

Architecture

  • Use one configured preview-domain suffix and derive canonical site_id directly from {siteId}.<preview-domain> before coordinator or storage access.
  • Keep anonymous published reads coordinator- and D1-free: deterministic wildcard parsing yields the R2 namespace, and absent publication state fails closed.
  • Store allocation, ownership, lifecycle state, canonical hostname, aliases, timestamps, and generation in D1.
  • Allocate collision-resistant site IDs and wildcard origins transactionally during POST /v1/sites.
  • Preserve the existing production hostname as the explicit default compatibility mapping.
  • Treat custom-domain aliases as a separate registry projection; they must not weaken deterministic preview-host routing.

Acceptance criteria

  • POST /v1/sites allocates a new site without a predeclared context entry or Worker redeployment.
  • Concurrent allocation is collision-safe and idempotent across isolates.
  • The same Worker serves at least 100 dynamically allocated hostnames with strict D1/R2/cache/credential isolation.
  • Unknown, malformed, mixed-case, suffix-confused, and generation-stale hostnames fail before state access.
  • Anonymous publication reads for the wildcard hostname do not query D1 or construct a coordinator.
  • Existing default production state remains byte- and namespace-compatible.
  • Local D1 gates prove allocation, import, publication, restart, edit, and cross-site denial for dynamically created sites.
  • No deployment is performed by this issue.

Current limitation

The current allocator selects only from WORDPRESS_SITE_CONTEXTS. Capacity therefore equals the number of contexts embedded in Worker environment configuration.

Related

AI assistance

OpenAI GPT-5.6 Sol via OpenCode inspected the current allocation and public-reader contracts and drafted this elastic identity slice with Chris Huber.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions