$method->invoke(null, $value, $node); $root = $invoke([ 'id' => str_repeat('a', 32), 'kind' => 'apply', 'status' => 'running', 'started_at' => 1791501000, 'updated_at' => 1791501010, 'finished_at' => null, 'stderr' => 'must-not-cross-boundary', 'command' => 'must-not-cross-boundary', ], false); $assert($root === [ 'id' => str_repeat('a', 32), 'status' => 'running', 'started_at' => 1791501000, 'updated_at' => 1791501010, 'finished_at' => null, 'kind' => 'apply', ], 'Root operation projection is not exact or leaked an unreviewed field.'); $node = $invoke([ 'id' => str_repeat('a', 32), 'status' => 'running', 'phase' => 'apply', 'checkpoint' => 'future_checkpoint:/root/private', 'reason' => 'future_reason --private-key', 'started_at' => 1791501000, 'updated_at' => 1791501010, 'finished_at' => null, ], true); $assert(($node['checkpoint'] ?? null) === 'unknown' && ($node['reason'] ?? null) === 'unknown' && !in_array('future_checkpoint:/root/private', $node, true) && !in_array('future_reason --private-key', $node, true), 'Unknown node diagnostics were not replaced by fixed markers.'); $invalid = $invoke([ 'id' => '../not-an-operation', 'kind' => 'future_kind', 'status' => 'future_status', 'started_at' => true, 'updated_at' => '1791501010', 'finished_at' => -1, ], false); $assert($invalid === [ 'id' => null, 'status' => 'unknown', 'started_at' => null, 'updated_at' => null, 'finished_at' => null, 'kind' => 'unknown', ], 'Malformed root operation values were not safely normalized.'); $mutationMethod = new ReflectionMethod( CloudAdminFabricService::class, 'mutationOperation' ); $mutation = static fn ($value, array $kinds): array => $mutationMethod->invoke(null, $value, $kinds); $assert($mutation($root, ['apply']) === $root, 'A valid asynchronous apply receipt was rejected.'); foreach ([ 'missing' => null, 'invalid-id' => array_replace($root, ['id' => null]), 'wrong-kind' => array_replace($root, ['kind' => 'reconcile']), 'unknown-status' => array_replace($root, ['status' => 'unknown']), ] as $label => $receipt) { try { $mutation($receipt, ['apply']); } catch (CloudError $error) { $assert($error->httpStatus === 502, 'Malformed ' . $label . ' receipt returned the wrong status.'); continue; } throw new RuntimeException( 'Malformed ' . $label . ' receipt did not fail closed.' ); } echo "Administrator Fabric operation projection contracts passed.\n";