How does a Rule access a variable defined in the event info? I'm looking at the Drupal Commerce module in Drupal 7, and it has a Rule to send an email notification that the order was completed after checkout.  Perusing the code in commerce_checkout.rules.inc, the hook_rules_event_info() has a variable of type commerce_order().  

How does Rules retrieve the tokens and the $order object?  Or how does the Commerce Order module define a variable type to use with Rules?
I was looking in the wrong place and thought about how Rules work the wrong way.  The event for when an Order entity is part of the Rule is triggered by the Commerce module on checkout.

rules_invoke_all('commerce_checkout_complete', $order);


And for the other entities, Rules already takes care of most by invoking events from its events.inc.