@@ -56,6 +56,103 @@ function cloudflare_seed_files( string $root ): array {
5656$ output_zip = $ assets . '/markdown-database-integration-canonical-seed.zip ' ;
5757$ output_manifest = $ assets . '/markdown-database-integration-canonical-seed.json ' ;
5858$ root = sys_get_temp_dir () . '/wp-codebox-canonical-mdi- ' . getmypid () . '- ' . bin2hex ( random_bytes ( 4 ) );
59+ $ front_page_content = <<<'HTML'
60+ <!-- wp:group {"tagName":"main","layout":{"type":"constrained"}} -->
61+ <main class="wp-block-group">
62+ <!-- wp:heading {"level":1} -->
63+ <h1 class="wp-block-heading">WordPress at the edge, with durable Markdown state</h1>
64+ <!-- /wp:heading -->
65+
66+ <!-- wp:paragraph {"fontSize":"large"} -->
67+ <p class="has-large-font-size">This bounded Cloudflare runtime runs WordPress and PHP as WebAssembly at the edge while keeping durable site state outside the disposable query database.</p>
68+ <!-- /wp:paragraph -->
69+
70+ <!-- wp:heading {"level":2} -->
71+ <h2 class="wp-block-heading">Architecture flow</h2>
72+ <!-- /wp:heading -->
73+
74+ <!-- wp:columns -->
75+ <div class="wp-block-columns"><!-- wp:column -->
76+ <div class="wp-block-column"><!-- wp:group {"layout":{"type":"constrained"}} -->
77+ <div class="wp-block-group"><!-- wp:heading {"level":3} -->
78+ <h3 class="wp-block-heading">Edge request</h3>
79+ <!-- /wp:heading --><!-- wp:paragraph -->
80+ <p>WordPress/PHP WebAssembly boots for the request.</p>
81+ <!-- /wp:paragraph --></div>
82+ <!-- /wp:group --></div>
83+ <!-- /wp:column -->
84+
85+ <!-- wp:column -->
86+ <div class="wp-block-column"><!-- wp:paragraph {"align":"center","fontSize":"x-large"} -->
87+ <p class="has-text-align-center has-x-large-font-size">→</p>
88+ <!-- /wp:paragraph --><!-- wp:group {"layout":{"type":"constrained"}} -->
89+ <div class="wp-block-group"><!-- wp:heading {"level":3} -->
90+ <h3 class="wp-block-heading">Disposable SQLite</h3>
91+ <!-- /wp:heading --><!-- wp:paragraph -->
92+ <p>SQLite is reconstructed as query state, not the durable source of truth.</p>
93+ <!-- /wp:paragraph --></div>
94+ <!-- /wp:group --></div>
95+ <!-- /wp:column -->
96+
97+ <!-- wp:column -->
98+ <div class="wp-block-column"><!-- wp:paragraph {"align":"center","fontSize":"x-large"} -->
99+ <p class="has-text-align-center has-x-large-font-size">→</p>
100+ <!-- /wp:paragraph --><!-- wp:group {"layout":{"type":"constrained"}} -->
101+ <div class="wp-block-group"><!-- wp:heading {"level":3} -->
102+ <h3 class="wp-block-heading">Canonical state</h3>
103+ <!-- /wp:heading --><!-- wp:paragraph -->
104+ <p>Markdown Database Integration exports canonical Markdown and JSON into immutable, content-addressed R2 objects and revision manifests.</p>
105+ <!-- /wp:paragraph --></div>
106+ <!-- /wp:group --></div>
107+ <!-- /wp:column -->
108+
109+ <!-- wp:column -->
110+ <div class="wp-block-column"><!-- wp:paragraph {"align":"center","fontSize":"x-large"} -->
111+ <p class="has-text-align-center has-x-large-font-size">→</p>
112+ <!-- /wp:paragraph --><!-- wp:group {"layout":{"type":"constrained"}} -->
113+ <div class="wp-block-group"><!-- wp:heading {"level":3} -->
114+ <h3 class="wp-block-heading">Serialized writes</h3>
115+ <!-- /wp:heading --><!-- wp:paragraph -->
116+ <p>A Durable Object serializes writes and atomically advances the current revision. A cold runtime hydrates that manifest and reconstructs SQLite.</p>
117+ <!-- /wp:paragraph --></div>
118+ <!-- /wp:group --></div>
119+ <!-- /wp:column --></div>
120+ <!-- /wp:columns -->
121+
122+ <!-- wp:heading {"level":2} -->
123+ <h2 class="wp-block-heading">Verified capabilities</h2>
124+ <!-- /wp:heading -->
125+
126+ <!-- wp:list -->
127+ <ul class="wp-block-list"><!-- wp:list-item -->
128+ <li>Log in to WordPress.</li>
129+ <!-- /wp:list-item --><!-- wp:list-item -->
130+ <li>Edit content with the block editor and publish it.</li>
131+ <!-- /wp:list-item --><!-- wp:list-item -->
132+ <li>Render the published page publicly.</li>
133+ <!-- /wp:list-item --><!-- wp:list-item -->
134+ <li>Recover the site after a cold start from the current revision manifest.</li>
135+ <!-- /wp:list-item --></ul>
136+ <!-- /wp:list -->
137+
138+ <!-- wp:heading {"level":2} -->
139+ <h2 class="wp-block-heading">Bounded by design</h2>
140+ <!-- /wp:heading -->
141+
142+ <!-- wp:list -->
143+ <ul class="wp-block-list"><!-- wp:list-item -->
144+ <li>One site namespace is currently configured.</li>
145+ <!-- /wp:list-item --><!-- wp:list-item -->
146+ <li>Requests for a site are serialized while a write lease is held.</li>
147+ <!-- /wp:list-item --><!-- wp:list-item -->
148+ <li>Each dynamic request currently pays PHP boot cost.</li>
149+ <!-- /wp:list-item --><!-- wp:list-item -->
150+ <li>Cold recovery hydrates the full revision manifest.</li>
151+ <!-- /wp:list-item --></ul>
152+ <!-- /wp:list -->
153+ </main>
154+ <!-- /wp:group -->
155+ HTML;
59156
60157try {
61158 mkdir ( $ root , 0755 , true );
@@ -71,6 +168,13 @@ function cloudflare_seed_files( string $root ): array {
71168 }
72169 $ pdo = new PDO ( 'sqlite: ' . $ database );
73170 $ pdo ->setAttribute ( PDO ::ATTR_ERRMODE , PDO ::ERRMODE_EXCEPTION );
171+ $ front_page = $ pdo ->prepare ( 'UPDATE wp_posts SET post_title = ?, post_name = ?, post_excerpt = ?, post_content = ?, post_status = ? WHERE ID = 2 AND post_type = ? ' );
172+ $ front_page ->execute ( array ( 'Cloudflare WordPress Runtime ' , 'cloudflare-wordpress-runtime ' , 'A bounded WordPress WebAssembly runtime with canonical Markdown state in R2. ' , $ front_page_content , 'publish ' , 'page ' ) );
173+ if ( 1 !== $ front_page ->rowCount () ) { throw new RuntimeException ( 'Unable to configure canonical front page ID 2. ' ); }
174+ $ options = $ pdo ->prepare ( "INSERT INTO wp_options (option_name, option_value, autoload) VALUES (?, ?, 'on') ON CONFLICT(option_name) DO UPDATE SET option_value = excluded.option_value " );
175+ foreach ( array ( 'blogname ' => 'Cloudflare WordPress Runtime ' , 'blogdescription ' => 'WordPress WebAssembly with canonical Markdown state ' , 'show_on_front ' => 'page ' , 'page_on_front ' => '2 ' ) as $ name => $ value ) {
176+ $ options ->execute ( array ( $ name , $ value ) );
177+ }
74178 $ runtime = WP_Markdown_Primary_Storage_Runtime::bootstrap_existing_cache ( array ( 'content_root ' => $ markdown_root , 'state_root ' => $ markdown_root ), new WP_SQLite_Connection ( $ pdo ), 'wordpress ' );
75179 $ driver = $ runtime ->get_driver ();
76180 $ theme_mods = $ pdo ->prepare ( "INSERT INTO wp_options (option_name, option_value, autoload) VALUES ('theme_mods_twentytwentyfive', ?, 'auto') ON CONFLICT(option_name) DO UPDATE SET option_value = excluded.option_value " );
0 commit comments