(#18508) Preserve order of insertion for resources

The order that resources are added into the catalog is needed in order to
ensure a less surprising order when applying resources on the agent. This
ensures that the order that resources are transmitted to the agent
preserves that insertion order.

In addition there are a few changes that were made as we worked to understand
the catalog compilation process and how resources are tracked.