where('kind', 'backup_restore')"); $queryEnd = $queryStart === false ? false : strpos( $source, '$mode = \'portable_restore_finalizer\';', $queryStart ); $assert($queryStart !== false && $queryEnd !== false, 'Portable restore finalization claim is missing.'); $query = substr($source, $queryStart, $queryEnd - $queryStart); foreach ([ "'bra.state',\n 'finalization_pending'", "'bra.effect_resolution'", "['applied', 'not_applied']", "->where('bra.active_attempt', 1)", "'recovery_prepare_pending'", 'self::receivedEventExists($events)', ] as $needle) { $assert(str_contains($query, $needle), 'Portable restore finalization claim omitted: ' . $needle); } $policy = strpos( $source, 'CloudOperationRecoveryPolicy::allowsSystemResolution(' ); $prepareApplied = strpos( $source, 'CloudOperationRecoveryService::prepareApplied(' ); $prepareNotApplied = strpos( $source, 'CloudOperationRecoveryService::prepareNotApplied(' ); $assert($policy !== false && $prepareApplied !== false && $prepareNotApplied !== false && $policy < $prepareApplied && $policy < $prepareNotApplied, 'System fence policy is not enforced before PHP ledger preparation.'); $assert(str_contains( substr($source, $policy - 160, 500), '$fenceResolutionRequired' ), 'The early system-resolution policy is not scoped to active fences.'); echo "Cloud portable restore automatic recovery contract passed.\n";