Skip to content

Cloudflare: isolate fast immutable public reads from the PHP-WASM mutation runtime #2112

Description

@chubes4

Problem

The Cloudflare runtime has the right canonical-state and immutable-publication model, but the deployed public read path is not yet a viable preview foundation.

Observed on 2026-07-26 at https://wp-codebox-cloudflare-runtime.chubes.workers.dev/:

  • / is a publication-edge hit but takes roughly 0.4-0.7 seconds TTFB.
  • /architecture/ takes 45-101 seconds and returns 301 or 500.
  • /lifecycle/ takes 101-103 seconds and returns 500.
  • /api/ takes about 80 seconds and returns 404.
  • representative theme, core CSS, and Interactivity API assets take roughly 0.35-0.68 seconds each.

The active publication includes / but not the linked routes. servePublishedWordPressPage() returns null for a publication miss, so the request falls through to the coordinator and PHP-WASM mutation runtime. The public read handler also shares the monolithic Worker entrypoint and dependency graph with PHP-WASM.

This makes publication completeness implicit and turns a missing immutable artifact into an extremely slow dynamic request. It also prevents us from proving that public reads are independent of PHP, SQLite, D1, coordinators, and mutation availability.

Goal

Provide a generic, read-only Cloudflare runtime primitive that serves complete immutable WordPress publications quickly and cannot boot the mutation runtime. Keep destination products, caller clients, and deployment-specific UX outside WP Codebox.

Required behavior

  • Expose a lightweight public-read entrypoint/handler whose dependency and environment contract contains only immutable publication and asset read capabilities.
  • Public-reader requests must never initialize PHP-WASM, SQLite, D1, a revision coordinator, or mutation code.
  • Represent publication completeness and readiness explicitly. A publication advertised as ready must include its bounded canonical route set and the immutable assets required by those pages.
  • Handle absent routes or incomplete publications with a bounded, explicit response rather than falling through to dynamic WordPress.
  • Preserve the existing mutation/runtime endpoint for authenticated, administrative, preview, and intentional dynamic WordPress execution.
  • Preserve immutable generation/revision isolation and prevent old publication or asset cache entries from crossing a promoted generation.
  • Give immutable publication pages and assets revision-addressed cache identities and appropriate cache headers.
  • Keep Cloudflare-specific implementation inside runtime-cloudflare; expose only generic publication/read contracts where callers need them.
  • Add deterministic tests proving read-plane independence, complete publication routing, bounded misses, cache identity, and compatibility with existing mutation callers.

Acceptance evidence

  • npm run build
  • npm run test:cloudflare-runtime
  • npm run cloudflare:dry-run:d1 and any new public-reader Wrangler dry-run
  • A dependency or bundle assertion demonstrating that the public-reader entrypoint does not include the PHP-WASM runtime.
  • Local/reviewer-reproducible timing evidence for publication hits and misses. Production deployment and mutation are explicitly out of scope.

Context

This is foundational work for instant, durable preview URLs and asynchronous spawning. Studio, transfer workflows, caller clients, and destination-specific credential UX are intentionally out of scope.

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