From 5c392ebc2c0c0ea3ea374c3129eb7b93180861cd Mon Sep 17 00:00:00 2001 From: "homeboy-ci[bot]" <266378653+homeboy-ci[bot]@users.noreply.github.com> Date: Sun, 21 Jun 2026 20:13:17 -0400 Subject: [PATCH] Remove Codebox runtime context vocabulary --- README.md | 4 +-- docs/CHANGELOG.md | 2 +- tests/mounted-runtime-context.php | 55 +++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4fac0f2..676abb7 100644 --- a/README.md +++ b/README.md @@ -299,11 +299,11 @@ This is intentionally simpler than detecting WP.com vs VIP vs self-hosted vs CI Mounted runtimes can self-configure DMC by passing a context through `$GLOBALS['mounted_runtime_context']`, `$GLOBALS['wordpress_runtime_context']`, `MOUNTED_RUNTIME_CONTEXT`, or `MOUNTED_RUNTIME_WORKSPACE_ROOT`. -WP Codebox sandboxes may instead pass a versioned contract through `$GLOBALS['wp_codebox_runtime_context']` or `WP_CODEBOX_RUNTIME_CONTEXT`: +When a runtime needs to pass a versioned contract, use the generic WordPress runtime schema: ```json { - "schema": "wp-codebox/runtime-context/v1", + "schema": "wordpress/runtime-context/v1", "payload": { "workspace_root": "/workspace", "runtime_workspace": { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a49b45c..599da4b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,7 +10,7 @@ All notable changes to Data Machine Code will be documented in this file. ## [0.48.16] - 2026-06-21 ### Changed -- Add Codebox runtime context contract +- Add mounted runtime context contract ## [0.48.15] - 2026-06-21 diff --git a/tests/mounted-runtime-context.php b/tests/mounted-runtime-context.php index 111e6af..32ae37c 100644 --- a/tests/mounted-runtime-context.php +++ b/tests/mounted-runtime-context.php @@ -81,4 +81,59 @@ function mounted_runtime_context_assert_same( mixed $expected, mixed $actual, st mounted_runtime_context_assert_same('/tmp/generic-wordpress-env-workspace', $context['workspace_root'] ?? '', 'Generic WordPress env context works.'); +$legacy_global_key = 'wp_' . 'code' . 'box_runtime_context'; +$legacy_env_key = 'WP_' . 'CODE' . 'BOX_RUNTIME_CONTEXT'; +$legacy_schema = 'wp-' . 'code' . 'box/runtime-context/v1'; +$GLOBALS[ $legacy_global_key ] = array( 'workspace_root' => '/tmp/legacy-global-workspace' ); +$generic_fallback_env_context = json_encode(array( 'workspace_root' => '/tmp/generic-fallback-workspace' )); +putenv('MOUNTED_RUNTIME_CONTEXT=' . $generic_fallback_env_context); + +$context = $method->invoke(null); +unset($GLOBALS[ $legacy_global_key ]); +putenv('MOUNTED_RUNTIME_CONTEXT'); + +mounted_runtime_context_assert_same('/tmp/generic-fallback-workspace', $context['workspace_root'] ?? '', 'Legacy vendor global is ignored in favor of generic runtime context.'); + +putenv($legacy_env_key . '=' . json_encode(array( 'workspace_root' => '/tmp/legacy-env-workspace' ))); +putenv('MOUNTED_RUNTIME_WORKSPACE_ROOT=/tmp/generic-env-fallback-workspace'); + +$context = $method->invoke(null); +putenv($legacy_env_key); +putenv('MOUNTED_RUNTIME_WORKSPACE_ROOT'); + +mounted_runtime_context_assert_same('/tmp/generic-env-fallback-workspace', $context['workspace_root'] ?? '', 'Legacy vendor env context is ignored in favor of generic runtime context.'); + +$GLOBALS['mounted_runtime_context'] = array( + 'schema' => $legacy_schema, + 'payload' => array( 'workspace_root' => '/tmp/legacy-schema-payload-workspace' ), +); + +$context = $method->invoke(null); +unset($GLOBALS['mounted_runtime_context']); + +mounted_runtime_context_assert_same('', $context['workspace_root'] ?? '', 'Unsupported legacy vendor schema payload is not unwrapped.'); + +$runtime_support_files = array( + dirname(__DIR__) . '/inc/Runtime/MountedRuntimeBootstrap.php', + dirname(__DIR__) . '/inc/Support/RuntimeCapabilities.php', + dirname(__DIR__) . '/README.md', +); +$forbidden_runtime_tokens = array( + $legacy_global_key, + $legacy_env_key, + 'CODE' . 'BOX_RUNTIME_CONTEXT_SCHEMA', + $legacy_schema, + 'Code' . 'box', + 'code' . 'box', +); + +foreach ( $runtime_support_files as $runtime_support_file ) { + $contents = file_get_contents($runtime_support_file); + foreach ( $forbidden_runtime_tokens as $forbidden_runtime_token ) { + if ( false !== strpos((string) $contents, $forbidden_runtime_token) ) { + throw new RuntimeException(sprintf('Forbidden runtime token %s found in %s.', $forbidden_runtime_token, $runtime_support_file)); + } + } +} + echo "Mounted runtime context regression passed.\n";