Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ When a runtime needs to pass a versioned contract, use the generic WordPress run
}
```

DMC unwraps the versioned `payload` to the same internal context shape as the generic mounted-runtime contract, so existing workspace root and mount adoption behavior stays shared. `runtime_workspace` is the canonical workspace object; `sandbox_workspace` is retained only as a deprecated compatibility alias.
DMC unwraps the versioned `payload` to the same internal context shape as the generic mounted-runtime contract, so existing workspace root and mount adoption behavior stays shared. `runtime_workspace` is the canonical workspace object; legacy runtime-specific workspace aliases should be translated by the runtime owner before DMC receives the context.

## Roadmap

Expand Down
16 changes: 1 addition & 15 deletions inc/Runtime/MountedRuntimeBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,6 @@ private static function normalize_context( array $context ): array {
* @return array<string,mixed>
*/
private static function normalize_workspace_context( array $context ): array {
if ( ! is_array($context['runtime_workspace'] ?? null) && is_array($context['sandbox_workspace'] ?? null) ) {
$context['runtime_workspace'] = $context['sandbox_workspace'];
}

if ( ! is_array($context['sandbox_workspace'] ?? null) && is_array($context['runtime_workspace'] ?? null) ) {
$context['sandbox_workspace'] = $context['runtime_workspace'];
}

return $context;
}

Expand Down Expand Up @@ -254,12 +246,6 @@ private static function workspace_mounts( array $context, string $workspace_root
* @return array<string,mixed>
*/
private static function runtime_workspace_from_context( array $context ): array {
if ( is_array($context['runtime_workspace'] ?? null) ) {
return $context['runtime_workspace'];
}

return is_array($context['sandbox_workspace'] ?? null) ? $context['sandbox_workspace'] : array();
return is_array($context['runtime_workspace'] ?? null) ? $context['runtime_workspace'] : array();
}
}

class_alias(MountedRuntimeBootstrap::class, __NAMESPACE__ . '\\MountedSandboxBootstrap');
19 changes: 4 additions & 15 deletions tests/mounted-runtime-context.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,8 @@ function mounted_runtime_context_assert_same( mixed $expected, mixed $actual, st
mounted_runtime_context_assert_same(RuntimeCapabilities::RUNTIME_CONTEXT_SCHEMA, $context['schema'] ?? '', 'Mounted context keeps its versioned schema.');
mounted_runtime_context_assert_same('/tmp/mounted-workspace', $context['workspace_root'] ?? '', 'Mounted payload is unwrapped for workspace discovery.');
mounted_runtime_context_assert_same('/tmp/mounted-workspace', $context['runtime_workspace']['root'] ?? '', 'Runtime workspace is preserved.');
mounted_runtime_context_assert_same('/tmp/mounted-workspace', $context['sandbox_workspace']['root'] ?? '', 'Deprecated sandbox workspace alias is preserved.');

$GLOBALS['mounted_runtime_context'] = array(
'schema' => RuntimeCapabilities::RUNTIME_CONTEXT_SCHEMA,
'payload' => array(
'sandbox_workspace' => array(
'root' => '/tmp/legacy-mounted-workspace',
),
),
);

$context = $method->invoke(null);
unset($GLOBALS['mounted_runtime_context']);

mounted_runtime_context_assert_same('/tmp/legacy-mounted-workspace', $context['runtime_workspace']['root'] ?? '', 'Deprecated sandbox workspace input is normalized to runtime workspace.');
mounted_runtime_context_assert_same(false, array_key_exists('sandbox_' . 'workspace', $context), 'Mounted runtime context does not emit the deprecated workspace alias.');
mounted_runtime_context_assert_same(false, class_exists('DataMachineCode\\Runtime\\Mounted' . 'SandboxBootstrap'), 'Deprecated mounted sandbox bootstrap alias is not registered.');

$method = new ReflectionMethod(MountedRuntimeBootstrap::class, 'workspace_mounts');

Expand Down Expand Up @@ -152,6 +139,8 @@ function mounted_runtime_context_assert_same( mixed $expected, mixed $actual, st
'acme-runner',
'ACME_RUNNER',
$legacy_schema,
'sandbox_' . 'workspace',
'Mounted' . 'SandboxBootstrap',
);

foreach ( $runtime_support_files as $runtime_support_file ) {
Expand Down
Loading