Multi-Step Cascading Allocations
Problem
Real allocations require ordered steps where output of step N becomes input to step N+1. Example:
- Step 1: Allocate IT costs to all departments by headcount
- Step 2: Allocate Facilities costs (which now include some IT) by square meters
- Step 3: Allocate shared services to business units by revenue
This is implemented as a dynamic N-step engine: the number of steps is not hard-coded. allocation_engine_multistep() derives max_steps at run time by querying MAX(step_order) from the rules (run_query) and unrolls exactly that many steps via Jinja. Adding a 4th (or Nth) step requires only a new rule row plus its driver values — no macro change.