Aspect Ordering & Precedence Rules
Ordering Rules
Aspects are applied in ascending order - Aspects with lower order values are applied before aspects with higher order values.
Lower order executes closer to the step boundary - When aspects are chained around a step, those with lower order values are positioned closer to the actual step execution.
Same position chaining - If multiple aspects target the same position (BEFORE_STEP or AFTER_STEP), they execute in order (lower order values closest to the step).
Default order is 0 - If no order is specified, aspects default to order 0.
Tie-breaking - When multiple aspects share the same order and position, execution order is deterministic but unspecified; implementations MUST preserve declaration order.
Order is signed - Order is a signed integer. Negative values are allowed and execute before zero-valued aspects.
Position precedence - BEFORE_STEP aspects always execute before the step, and AFTER_STEP aspects always execute after the step, regardless of order value.
Example
Consider these aspects applied to a single step:
- Aspect A: position=BEFORE_STEP, order=10
- Aspect B: position=BEFORE_STEP, order=5
- Aspect C: position=AFTER_STEP, order=0
- Aspect D: position=AFTER_STEP, order=1
The execution order would be:
- Aspect A executes (BEFORE_STEP, farthest from step)
- Aspect B executes (BEFORE_STEP, closest to step)
- Actual step executes
- Aspect D executes (AFTER_STEP, closest to step)
- Aspect C executes (AFTER_STEP, farthest from step)
This creates the following logical pipeline:
Input -> Aspect A -> Aspect B -> Step -> Aspect D -> Aspect C -> Output