When the grades are "dirty", needing update I believe you'll find the functions in lib/grade/grade_category.php, the functions that deal with it are generate_grades() and aggregate_grades().
General developer forum
where is the function that calculates aggregation total
This discussion has been locked so you can no longer reply to it.