Hi @Muhammad Waseem , nice and useful article.

Please note that for embedded SQL, since some version 2020.1, when the Universal Query Cache was introduced, it's no longer true that "SQL statements are pre-compiled into the program during development", please check relevant documentation.
 

You can find more details and a discussion of this topic, including comments from @Dan Pascothe initial dynamic SQL developer, in the post A look at Dynamic SQL and Embedded SQL

 

To get the XML rule definition from SQL you can write/define a stored procedure that returns the XML rule definition, then....parse the XML. Something like:

Class Community.Rule.XDATA
{
ClassMethod GetXML(RuleName As %String) As %String(MAXLEN="") [ SqlProc ]
{
    Set xdataOBJ = ##class(%Dictionary.XDataDefinition).IDKEYOpen(RuleName,"RuleDefinition")
    Quit xdataOBJ.Data.Read($$$MaxLocalLength)
}
}

Then from SQL:

select Community_Rule.XDATA_GetXML('Your.Rule.Name')

From documentation:

General Rules

Every identifier must be unique within its context (for example, no two classes in a given namespace can have the same full name).

Identifiers preserve case: you must exactly match the case of a name; at the same time, two classes cannot have names that differ only in case. For example, the identifiers id1 and ID1 are considered identical for purposes of uniqueness.

@David.Satorres6134 , you asked:

We have reviewed the documentation but were unable to find a method or API that provides the correct compilation order for the cubes.

I gave the documentation links on how to provide the correct compilation order for classes.

In most cases the compiler does take care of dependencies and build/compile in correct order.
In my experience I have very, very rarely (maybe a couple of times) used DependsOn or CompileAfter Class keywords (I don't do cubes/DeepSee).

I'm not familiar with multiple cubes compilation, but evidently your implementation has some particular dependency that the compiler is unable to identify and take care of it.

Maybe  (just guessing here) you have some cross dependency that is "resolved" with multiple compilations?